View RSS Feed

Application Context

Spring Application Context

  1. Spring IoC Containers

    by , 07-07-2012 at 06:41 PM
    The Spring framework core is the Spring container. The Spring IoC container will:

    • Create objects
    • Wire those created objects
    • Configure thos objects
    • Manage complete lifecycle of the object

    An application is made up of components and these components are managed by the Sping container using dependency injection. These objects are also known as Spring Bean objects.

    The configuration metadata is read by the Spring container in ...
  2. Spring ApplicationContext Container

    by , 07-07-2012 at 06:39 PM
    The advanced spring container is the Application Context. Just like the BeanFactory, it can perform the similar operations like wiere beans together, loading of bean definitions and upon request dispense bean. Following enterprise specific functionality is provided:

    • From properties file, it can resolve textual messages.
    • Application events are published to event listeners.

    The ApplicationContext interface defines this container.

    The BeanFactory ...
  3. Spring Application Context

    by , 07-07-2012 at 06:38 PM
    The application configuration is provided and configured by a central interface in spring called ApplicationContext.

    Following functionalities are provided by the Spring ApplicationContext.

    • The ListableBeanFactory inherited Bean factory methods are provided by the ApplicationContext. Also it will help the application to avoid use of singletons in their applications.
    • The MessageSoruce interface provides the functionality to support internationalization and ...
  4. Writing AOP in Spring

    by , 11-16-2011 at 06:35 PM
    In this last installment of Spring AOP, we will provide an example of how to use AOP in Spring.
    In the listing below, we add a car to an order.

    Java Code:
    package com.acme.springexamples.main;
    import com.acme.springexamples.service.CarService;
    import com.acme.springexamples.service.OrderService;
    public class Main { public static void main(String[] args) {
    	ApplicationContext context = 
    		new ClassPathXmlApplicationContext("META-INF/spring/*.xml");
  5. Listening for Events in Spring

    by , 11-16-2011 at 05:39 PM
    During the application life cycle, the ApplicationContext will publish a handful of events that tell interested listeners what’s going on. All of these events are all subclasses of the abstract class org.springframework.context.ApplicationEvent. A couple of these subclasses are:
    • ContextClosedEvent—Published when the application context is closed
    • ContextRefreshedEvent—Published when the application context is initialized or refreshed
    • RequestHandledEvent—Published within a web application

    Updated 11-30-2011 at 05:12 AM by Spring Framework

    Application Context , Event
  6. How to Write a BeanPostProcessing in Spring

    by , 11-16-2011 at 05:28 PM
    In the previous tip we talked about special beans in Spring. One of the Spring’s special beans that I had mentioned was using the BeanPostProcessor interface in order to cut into the bean’s life cycle and review or alter its configuration. In this tip, I will show you how to wire one. As mentioned in the previous tip I mentioned that the BeanPostProcessor provides two methods to alter the bean after it has been created and wired:

    Java Code:
    Object postProcessBeforeInitialization(Object bean,
  7. How to Autowire a Spring Bean

    by , 11-16-2011 at 05:23 PM
    In previous tips, we have shown how to wire bean’s properties using the <property> element. There is an alternative approach that can be used. It’s called autowiring. In this approach, Spring will wire your beans automatically if you set the autowire property on each <bean> on each of the beans that you want to autowire. There are four types of autowiring that Spring uses:

    • byName—Spring will attempt to find a bean in the container whose name (or ID) is the same as the
  8. Wiring Sets, Maps and Properties in Spring

    by , 11-16-2011 at 05:19 PM
    Similarly to lists, there are times when you will need to map to other types of collections. In this tip, I will outline what you need to do to wire sets, maps and properties. The key to remember is that you want to wire your bean to the same type that is being used in the class definition. So if your bean has a java.util.Set property to guarantee uniqueness in the collection, you want to use the same definition in the xml definition.

    So for example, if you want to use a java.util.Set, ...
  9. Understanding the Difference Between Singleton vs. Prototyping of Spring Beans

    by , 11-16-2011 at 05:13 PM
    When you configure a new Spring beanBy default, all Spring beans are singletons. When the container dispenses a bean, it will always give the exact same instance of the bean. But sometimes you want the application context to return a unique instance for each time you request a specific bean. In this case, you would want to do is to define a prototype bean. When you define a prototype means that you define a blueprint of the bean. Every subsequent bean for this requested bean will be based on this ...
  10. Contextualized Dependency Lookup in Spring

    by , 11-16-2011 at 01:16 PM
    At its core, Inversion of Control (IoC), and therefore Dependency Injection (DI) offers a mechanism for provisioning component dependencies and managing these dependencies throughout their lifecycles. A component that requires certain dependencies is often referred to as the dependent object or, in the case of IoC, the target. Generally, IoC can be broken down into two subtypes: Dependency Injection and Dependency Lookup. With Dependency Lookup IoC, a component must obtain a reference to a dependency. ...
  11. Looking at the Spring Application Context

    by , 11-15-2011 at 03:13 PM
    In order to take advantage of the full power of the Spring framework, you need to use Spring’s most advanced container, the application context. The ApplicationContext is similar to a BeanFactory. Both load bean definitions, wire beans together, and dispense beans upon request. But an ApplicationContext also does the following:
    • Application contexts provide a generic way to load other resources, such as images.
    • Application contexts can publish events to beans that are registered as listeners.
    • Application

    Updated 11-30-2011 at 12:46 PM by Spring Framework

    Application Context