Spring IoC container is responsible for create, wire, configure and manage objects during their complete life cycle. It uses configuration metadata for create, configure and manage objects. Configuration metadata can be represented by spring configuration xml file or annotations.
Types of Spring IoC container:
- 1. BeanFactory
2. ApplicationContext
BeanFactory:
BeanFactory org.springframework.beans.factory.BeanFactory is the interface and XmlBeanFactory is an implementation class of it. It is a simple container which provides the basic support for dependency injection.
Syntax to use BeanFactory:
ApplicationContext:
ApplicationContext org.springframework.context.ApplicationContext is the interface and ClassPathXmlApplicationContext is an implementation class of it. ApplicationContext container includes all functionality of the BeanFactory container with some extra functionality like internationalization, event listeners etc.
Syntax to use ApplicationContext:
Note: As ApplicationContext provides extra functionality including all given by BeanFactory it is better to use ApplicationContext container.
No comments:
Post a Comment