| Contact

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.

Labels: , , ,

Translate into your language
Reader Comments
Comments Count: 3
Write your own opinion
Share with others
E-mail
Search More Articles
  1. Spring.NET uses object instead bean
  2. Yes, that's true. Spring.net uses "objects" and "object" while the other is using "beans" and "bean". Not sure why.
  3. Seems your argument is correct.

Post a Comment

We appreciate your opinions, suggestions and criticism.

ABOUT AUTHOR
Kamal Mettananada is a Software Architect, Java Explorer and Blogger. Digizol consists of computer related articles, tutorials, tips and other information.
ARCHIVES
Select Month:

Free counter and web stats

FEED SUBSCRIPTION
Subscribe to our feed using your online news reader, approximately 1-2 articles per week.
ABOUT US
^top^