XML-based configuration

The XML-based configuration was introduced in Spring 2.0, and enhanced and extended in Spring 2.5 and 3.0. The main reason for moving to XML-based configuration files was to make Spring XML configuration easier. The classic <bean/> based approach is good, but also adds some more configuration that can become complex in the big project.

Let's take a look at an example of an XML-based setup document with various bean definitions, including the scope, initialization technique, and destruction strategy, and then we'll discuss this. Here's a piece of code for bean.xml:

<!-- A simple bean definition -->
<bean id = "..." class = "...">
<!-- collaborators and configuration-->
</bean>

<!-- A bean example with prototype scope -->
<bean id = "..." class = "..." scope = "prototype">
<!-- collaborators and configuration-->
</bean>

<!-- A bean definition with initialization function -->
<bean id = "..." class = "..." init-function = "...">
<!-- collaborators and configuration-->
</bean>

<!-- A bean definition with destruction function -->
<bean id = "..." class = "..." destroy-function = "...">
<!-- collaborators and configuration for this bean go here -->
</bean>
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.254.61