Use "object" instead of "bean" in Spring Configuration XML | About Publisher

Use "object" instead of "bean" in Spring Configuration XML

Spring configuration xml is used for defining the wiring between different object. It has the following format.


<beans>
<bean id=".." class="...">
...
</bean>
...
<beans>
Classes specified in the configuration file will be instantiated by Spring container. And those objects will be bound with each other accordingly. Any java class specified under attribute named "class" will be instantiated. There is no much limitations on the classes that can be used for this here. It does not need to be a JavaBean. It can be any POJO (plan old java object). The only requirement is that this class must be possible to instantiate.

Spring LogoSo why does this tags are named <beans> and <bean>? This seems to be misleading.

In Spring one way of binding objects is using the beaness of java classes. But that is not that only way to bind them together, constructor can be used to bind objects. So if configuration file used tags as follows, it would be more meaningful.

<objects>
<object id=".." class="...">
...
</object>
...
<objects>

Seems it is used only to express that beaness can also be used in initialization. Would you agree? May be we are not seeing the exact reason. This is completely open for discussion.
Share this article please, on :
Share on fb Tweet Share on G+

0 Response to "Use "object" instead of "bean" in Spring Configuration XML"

Post a Comment