Application context is an advanced container that provides several enterprise-level functionalities, some of which are:
Providing a means for resolving text messages, including support for internationalization of those messages.
Providing a generic way to load file resources, such as images.
Publishing events to beans, which are registered as listeners
Has been built upon the concept of the bean factory container.
Provides other functionalities, such as easy integration with Spring AOP features and support for internationalization.
Is defined by the org.springframework.context.
ApplicationContext interface.
In addition, it inherits all the capabilities of the BeanFactory interface, such as:
Creating the beans.
Associating them with each other.
Dispersing them to the users as per requests.
The Spring framework provides the following commonly used implementations of the application context container:
ClassPathXmlApplicationContext
FileSystemXmlApplicationContext
XmlWebApplicationContext
A major difference between the application context container and the bean factory container:
The bean factory container loads all the beans lazily, which means that the beans are created only when you call the getBean() method.
The application context container does not wait for the getBean() method to be called; it preloads all the beans as soon as the application context starts up.
Files Required For Spring Application Are
Spring Jar Files
MyApp Class
Triangle Class
Spring.xml
First Create New Java Project SpringDemo1 in Eclipse
Copy jar files to project and add jar files to build path
Create MyApp class in org.manish.javasafari package
Create Triangle class in org.manish.javasafari package
Add code to Tringle Class
Create spring.xml file in src folder and add code to it
Add code to MyApp class
In MyApp class we are not hard coding triangle object instead using bean factory for creating object from configuration file i.e. spring.xml.This is how we are decoupling dependency.