The heart of Spring Framework is IoC container that provides Dependency Injection facility to the developers. IoC is the core modules of Spring Framework. Spring IoC is a very popular and innovative facility of Spring Framework and we will learn how to use Spring IoC step by step with proper example.
Spring IoC Fundamental
This session will illustrate you the Fundamentals of Spring IoC Framework.
- What is IoC?
Brief description of IoC and types of IoC in the world of java.
- Configuring Spring IoC beans and creating beans instances
Creating first Spring bean code and configure in with Spring IoC Container for dependency injection (DI)
- Using factory to instantiate Spring IoC beans
We can instantiate a bean using factory class or factory method in bean class. Both the options are available in Spring IoC. So, we will learn both the methods form following examples:
- Using initialization method to initialize a Spring IoC Bean
The example will illustrate the way to define an initialization method which Spring will call after instantiating the bean class.
Spring IoC Setter Injection
Spring IoC setter injection examples to show how to set properties using setter of the java class.
- Spring IoC Setter Value Injection
Example of a java pojo class in which we will use Spring Setter Injection method to set its properties.
- Spring IoC Setter Bean Ref Injection
Will describe the process of referring one Spring bean to another
Spring IoC Constructor Injection
Spring IoC Constructor Injection example to show how to configure a bean to use class constructor to set the values of properties.
- Spring IoC Constructor Value Injection
Example to show the method of using constructor of a class to directly inject the value of the property.
- Spring IoC Constructor Type Injection
Example to show the process of using class constructor of a class to inject the dependencies by defining the data type of the property.
- Spring IoC Constructor Index Injection
Example to show the method of setting dependencies husing index of the argument in bean constructor.
Working with collection instances
In many aspects, sometimes we have to inject collection instances like Set, Map or List. Spring IoC provides convenient approach to inject collection instances with the help of the configuration file.