The bean factory is merely an object pool where objects are created and managed by
configuration. For small applications, this is sufficient, but enterprise applications
demand more. Application context builds on the foundations laid by the bean factory to
provide services like the following:
• Support for message resources required for internationalization
• Support for aspect-oriented programming (AOP) and hence declarative transac-
tion, security, and instrumentation support
• Registering event listeners in the bean factory
• Creating application layer-specific context such as WebApplicationContext for use
in web applications
The Spring application context can be created like a bean factory and without any
alteration in the configuration file, as shown in Listing 2-12.
Listing 2-12. SpringInitializer.java : Starting an Application Context
ApplicationContext context = new å
ClassPathXmlApplicationContext looks for a spring-config.xml file in the classpath and
initializes the application context. Similarly, a servlet listener can be registered to initial-
ize application context in a web application—commonly called web application context .
The listener looks for the configuration file at a specific location within the web applica-
tion archive to start the web application context.
So far, I have given a very basic and simplistic introduction to Spring IOC and DI fea-
tures. For a detailed treatment of the subject, refer to the Spring 2.5 documentation