Whenever I come across the word Spring, the word bean is inevitably around the corner. Is there are any strong relation between the two ? Is it a part of Java glossary ? Or is it just a terminology bandied about by the Spring team. What exactly is this bean ?
From Wikipedia
JavaBeans are reusable software components for Java. Practically, they are classes written in the Java programming language conforming to a particular convention. They are used to encapsulate many objects into a single object (the bean), so that they can be passed around as a single bean object instead of as multiple individual objects.
As can be seen from the above definition a Java Bean is a Java Class which follows a very simple set of rules.
Java Beans as a terminology was defined by Sun Microsystems in December 1996. For more sophisticated applications that demanded advanced features like transaction support, security etc, Sun introduced Enterprise Java Beans in March 1998. While Java beans were simple classes, EJBs were more powerful, more feature rich and unfortunately much much more complex. In fact the only similarity between the two was their name.
The early EJBs weren't actually a favorite with developers. The complicated development process led to a fall in its popularity among the java developer community.
It was at this time that Spring came up. Spring was based on the concept of Java Beans. It provided developers with the luxury of building entire applications as a set of beans. It took the responsibility of creating, configuring and managing these beans thereby helping us create very complex enterprise applications. It provided the simple Bean classes with the power of Enterprise Java Beans.
Over the years newer versions of Spring have appeared. As we use them we realize that as Spring has progressed, so has its interpretation of a Bean. For e.g. the Bean Specification states that we must define setter-getter for all our Bean properties. But the arrival of @Autowired annotation has ensured that Spring can manage our Bean even if we don't provide any setter-getter. Default Constructors also isn't mandatory for our (Spring) beans anymore. So within Spring the bean definition rules have been relaxed.
As far as Spring goes:
A Bean is an object that is managed by the Spring Container. The Bean may or may not follow all the rules of Java Beans. Spring however will still be able to work with the class.
From Wikipedia
JavaBeans are reusable software components for Java. Practically, they are classes written in the Java programming language conforming to a particular convention. They are used to encapsulate many objects into a single object (the bean), so that they can be passed around as a single bean object instead of as multiple individual objects.
As can be seen from the above definition a Java Bean is a Java Class which follows a very simple set of rules.
Java Beans as a terminology was defined by Sun Microsystems in December 1996. For more sophisticated applications that demanded advanced features like transaction support, security etc, Sun introduced Enterprise Java Beans in March 1998. While Java beans were simple classes, EJBs were more powerful, more feature rich and unfortunately much much more complex. In fact the only similarity between the two was their name.
The early EJBs weren't actually a favorite with developers. The complicated development process led to a fall in its popularity among the java developer community.
It was at this time that Spring came up. Spring was based on the concept of Java Beans. It provided developers with the luxury of building entire applications as a set of beans. It took the responsibility of creating, configuring and managing these beans thereby helping us create very complex enterprise applications. It provided the simple Bean classes with the power of Enterprise Java Beans.
Over the years newer versions of Spring have appeared. As we use them we realize that as Spring has progressed, so has its interpretation of a Bean. For e.g. the Bean Specification states that we must define setter-getter for all our Bean properties. But the arrival of @Autowired annotation has ensured that Spring can manage our Bean even if we don't provide any setter-getter. Default Constructors also isn't mandatory for our (Spring) beans anymore. So within Spring the bean definition rules have been relaxed.
As far as Spring goes:
A Bean is an object that is managed by the Spring Container. The Bean may or may not follow all the rules of Java Beans. Spring however will still be able to work with the class.
No comments:
Post a Comment