Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.
Spring ioc container work based on dependency injection.
Class is one type of DataType we use this class datatype in our class to call the appropriate methods to complete the task.In jenerally we create the class object and supplay to that class but in spring we configure in bean xml file.It create automatically by container and supplay to that class.
We create a bean class object it will not have any lifecycle states but spring container create the bean class object it have lifecyle states.We control the connections of databse based on that lifecyle process.
Containers manages the whole life cycle of the objects,Spring basically have 3 kinds of container i.e., Core container(Bean Factory),Advance Container(Application Context),Web Container(finds applicability in MVC frameworks).So container manages,wires,services all the dependencies which bean class do have.
The Spring IoC creates the objects, wire them together, configure them, and manage their complete lifecycle from creation till destruction.
The Spring container uses dependency injection (DI) to manage the components that make up an application.
The BeanFactory and ApplicationContext interface are the two types of conatiner. A BeanFactory just initiates and configures beans. An ApplicationContext also does that, and also provides more supporting infrastructure likesimple integration with Spring's AOP, message resource handling (for I18N), event propagation.
Example -
ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
where , applicationContext.xml is the config file where beans has been decalred.
The Spring container provides the IoC principle through two packages - org.springframework.beans and org.springframework.context. The BeanFactory and ApplicationContext interface are the two available options. A BeanFactory just initiates and configures beans. An ApplicationContext also does that, and also provides more supporting infrastructure that enables lots of enterprise specific features such as Aspect Oriented Programming and transaction.