spring bean

A spring bean represents an object that is created, configured and managed by spring container. A spring bean is created by configuration metadata passed to the spring container which tells the container about bean creation, bean lifecycle and bean dependencies.

Spring bean properties:

Bean PropertiesDescription
1. classIt is mandatory and specify the bean class which is used to create the bean.
2. nameIt specifies the bean unique identifier.
3. scopeIt specifies the scope of the objects created from a particular bean definition.
4. constructor-argIt is used to inject the dependencies.
5. propertiesIt is used to inject the dependencies.
6. autowiring modeIt is used to inject the dependencies.
7. lazy-initialization modeIt tells the IoC container to create a bean instance when it is first requested, rather than at startup.
8. initialization methodIt is a callback method to be called just after all necessary properties on the bean have been set by the container.
9. destruction methodIt is a callback to be called when the container containing the bean is destroyed.

Syntax using XML based configuration file:

<bean id="..." class="..." lazy-init="true">
//bean configuration
</bean>

No comments: