Okay But I tried it. I just found separate infos about both of them but not really the connection. They named these two concepts in a very similar way so I guess that there is some connection.
I've found the following description: Components (JavaBeans) are reusable software programs that you can develop and assemble easily to create sophisticated applications.
So I guess that they are some kind of bricks that can be easily put together to create more advanced parts.
But the definition says: A Java Bean is a reusable software component that can be manipulated visually in a builder tool.
I thought that Enterprise JavaBeans are a special case of JavaBeans. Like some kind of bricks but used to build JEE applications, and maybe they leaded out from JavaBeans by adding some "enterprise" functionality and concepts. But I never heard about EJB manipulated visually in a builder tool..
1. Is it like: JavaBeans are used to build some client-side interface, like a standalone JSE application, and Enterprise JavaBeans are used to build some server-side business functionality in JEE application?
2. There are some conventions for JavaBeans. Are they also mandatory for EJB?
JavaBeans: A reusable component . Here a reusable component signifies that this class or bean could be re used again and again without any code changes.
Enterprise javaBeans: A java Bean or class which is used at Enterprise Level. Enterpise level means it includes client, server, middle ,database etc. Let us say a client javaclass wants to invoke another java class which is present in server then the class/bean which is present at the server is called Enterprise java beans, so Enterpise java beans have to follow certain norms to be used as remote class.
At same time if the cleint javaclass tries to call method of of another javaclass/bean which is in the same location(i,e client itslef) it is simply called as javaBeans .
There is almost no connection beteen Java bean and enterprise java bean. Why i used the term "almost" is because the similarity that java bean and ejb have can be found between any two non related classes. Similarity between Java Bean and EJB: Both Java Bean and EJB are specification as well as a framework of APIs. Thats it, no similarity other than this. Difference between Java Bean and EJB: Basic difference lies between the set of features that they are supposed to support (as i said earlier Java Bean and EJB both provide specification also). Java Bean class is supposed to support component introspection, properties, events and persistence. Component developed according to this specification is called beans. From a developers perspective, a bean is a java class object that encapsulates data in the form of instance variables. These variables are "properties" of the bean. The class also provides getter and setter methods for each variable to access and mutate these properties. A typical java bean class looks like below:
Now let us come to enterprise Java bean. For large enterprise applicatins in a distributed environment we need several issues to be taken care. Like RMI, Load balancing, transparent failover, backend integrations, transaction, security etc etc to name a few. Can you imagince the effort it will take if you write these services yourself. For this reason we have servers that provide these services (better call middleware services) as readymade component. We call these servers as Application server(e.g. IBM Websphere, BEA Weblogic server etc). However these Application servers are supposed to follow the specifications of EJB. Then only the EJB API will be able to talk to these servers and take advantage of the services provided by them. Thus EJB is a component framework that simplifies the process of building enterprise class distributed applications in Java. Now you can appreciate how large is the scope of EJB as compated to java beab (infact there is no comparison). Obviously EJB requires Application server and they are deployable components which is not true for java bean. You don't require application server to make use of java bean. Bottomline is that the only similarity between a Java Bean and Enterprise Java Bean is there name!
Joined: Feb 15, 2007
Thank you both for your help!
Joined: Aug 07, 2008
But i think there is relation between java beans and enterprise java beans. In java a "bean" means a "reusable component" so both java beans and enterprise java beans are reusable components. The difference is that EJB along with EJB container takes care of security ,transaction etc as you have already explained where as a java bean is just a normal java class having get and set methods. Let me know if it is incorrect. Both have same purpose "reuse" of code.
Joined: Aug 04, 2008
Hi aleem, You are correct that bean basically imply reusability. But this is not the sufficient reason to compare the two concepts. For example there are other reusable softwares in java but you can not compare them with java bean or EJB. The purpose of reusability and the way EJB and Java Beans are used are so unrelated that it doesn't make sense to compare the two. Suppose tomorrow you develop a reusable application component. Will you compare this with existing java bean technology even if the two are nowhere related. Infact we fall in trap of comparing EJB and Java bean simply because of there name, otherwise there are so many concepts of reusabilty we don't even bothor to compare because there name does not contain the word bean!!