Terminology and Components of Spring IOC
1. Bean- An object which is created and managed by IOC Container is a Bean.
2. BeanFactory- is an interface which describe the functionality of a basic IOC Container. Any
class which implements this interface represents as an IOC Container.
3. XMLBeanFactory- is a framework provided class which implements BeanFactory Interface; an
Object of XMLBeanFactory requires Bean Configuration File i.e. A XML Document.
4. Resource- is an interface it provides methods of managing the beans Configuration. Different
implementations of this interface are provided by the framework.
a. ClassPathResource- It is used when the configuration file/required file is in class path (A
default path for placing the classes that is “build” in case of desktop/console application
and WEB-INF in case of Web Application). This is mostly used in Web Application
because developer doesn’t know the exact path when the application is deployed on
server. Its default searching approach is class path.
b. FileSystemResource- it also works the same but approach is different in the sense of
searching the files. The default loading mechanism to finding the resource of
FileSystemResource is it looks in the file system.
5. Configuration File- Configuration file is used to provide the configuration to Beans in
conventional XML format. In addition to XML Beans Configuration can also be provided
through annotations.
Steps:
1. A resource Object is created from the configuration file.
2. Configuration File is parsed and beans conjuration and dependencies information is
stored in Object form.
3. BeansFactory (IOC Container) object is created and reference of the Resource Object is
provided to it.
4. The Bean is requested from the bean factory.
5. Beans Configuration is requested from the Resource Object.
6. Configuration & Dependency Information of the bean is provided to the Bean Factory.
7. Using the information Beans is created and its dependencies are satisfied.
Note: First three steps are performed only once in an application i.e. Both Resource
& Bean Factory have application scope.
1. Bean- An object which is created and managed by IOC Container is a Bean.
2. BeanFactory- is an interface which describe the functionality of a basic IOC Container. Any
class which implements this interface represents as an IOC Container.
3. XMLBeanFactory- is a framework provided class which implements BeanFactory Interface; an
Object of XMLBeanFactory requires Bean Configuration File i.e. A XML Document.
4. Resource- is an interface it provides methods of managing the beans Configuration. Different
implementations of this interface are provided by the framework.
a. ClassPathResource- It is used when the configuration file/required file is in class path (A
default path for placing the classes that is “build” in case of desktop/console application
and WEB-INF in case of Web Application). This is mostly used in Web Application
because developer doesn’t know the exact path when the application is deployed on
server. Its default searching approach is class path.
b. FileSystemResource- it also works the same but approach is different in the sense of
searching the files. The default loading mechanism to finding the resource of
FileSystemResource is it looks in the file system.
5. Configuration File- Configuration file is used to provide the configuration to Beans in
conventional XML format. In addition to XML Beans Configuration can also be provided
through annotations.
Steps:
1. A resource Object is created from the configuration file.
2. Configuration File is parsed and beans conjuration and dependencies information is
stored in Object form.
3. BeansFactory (IOC Container) object is created and reference of the Resource Object is
provided to it.
4. The Bean is requested from the bean factory.
5. Beans Configuration is requested from the Resource Object.
6. Configuration & Dependency Information of the bean is provided to the Bean Factory.
7. Using the information Beans is created and its dependencies are satisfied.
Note: First three steps are performed only once in an application i.e. Both Resource
& Bean Factory have application scope.
Comments
Post a Comment