Difference between a normal class and java bean
Can anyone explain the difference between a normal java class and Java bean?
beans typically implement everything necessary for a particular functionality, and have no external dependencies. They live in a container and must be able to co-exist peacably (no fighting over database connections or credit card details)
typically they are used in enterprise applications to give some form of scalability.. to up the power of your application you just buy another computer, run the bean container on it, and let it put some beans in..
there isnt actually a lot of difference, because a class is supposed to be unitary and independent.. its just with beans, that they have to be. Beans also have well defined sematics for their recycling, and in enterpriuse apps, anything that is well defined and serving 100000 cuustomers is a Good Thing(TM)
Essentially there is no difference. Bean is just another Java class.
The minimum requirements for a class to be considered a Bean are:
1) It should implement the Serializable interface.
2) It should have public 'get' and 'set' methods that expose it's member variables.
All beans are classes. But all classes are not beans.
I assume you are talking about simple Java beans and not EJBs.
What Atlas said. Cjard looks to be getting into EJBs, and those things are scary!
There is a third requirement for simple Java beans.
3) It must implement a no argument (empty) constructor.
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL