• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Beans Vs EJBs

 
Ramakrishnan Viswanathan
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

What is the difference between a Java Bean and an Enterprise Java Bean? I read an article which said "Java Beans are development components, EJBs are deployable components" ... but I do not understand the difference.
Can someone please explain?

Thanks in advance
Ram
 
Reza Rav.
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is not appropriate place to ask this Question but
assume EJB are some kind of java beans that have more features because they live on Application server ,so EJB server give you some services like: Transaction management, Networking, Security and... that all perform on your EJB(Bean with more capability)
 
S Santhosh
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EJBs are deployment components means, when you develop an EJB you intend to use it on a(any) J2EE server. Like Java class can be run on any OS(with JVM), EJB can be deployed(read like installed) on any j2ee server. So when you develop a reusable EJBs(for say Payroll or Inventory management) these can be reused(if written/designed properly) on any server. EJBs also can used services provided by J2EE server like security, transaction control,object Pooling, life cycle management etc and you dont have to code for any of these services

Now javabeans, only similarity is then both have beens in name and are both written in java and have almost the same coding convention. Thats it.
Javabeans were more used to develop GUI components, the convention followed is it has attributes and getter/setter. These run on JVM where as EJBs run on j2ee server(read container)...

This is the most basic difference... Hope you got my point but if not read a few articles and should see this repeated in better words may be more understandable way
Santhosh
[ September 08, 2005: Message edited by: San Sreeds ]
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The above posts pretty much sum it up.

Here is the quote from Paul Sanghera's SCBCD Exam Study Kit p.23

"The differences between JavaBeans and Enterprise JavaBeans are listed here:
  • JavaBeans run in the JVM, while Enterprise JavaBeans run in an EJB-compliant container and use the low-level services provided by the container and the server.
  • Both JavaBeans and Enterprise JavaBeans are written in Java. However, enterprise beans take the meaning of reusability to a new level. The behavior of the enterprise beans may be changed without ever changing the code and recompiling it, for example, with the use of deployment descriptors.
  • JavaBeans are much simpler, while enterprise beans can be much more sophisticated and designed to implement often-complex server-side business logic.***
  • JavaBeans are often used in the presentation tier, for example, to build a GUI component, while Enterprise JavaBeans are used in the business tier to implement business logic.***

  • All of these distinguishing features of Enterprise JavaBeans simplify the development of distributed, transactional, secure, and portable enterprise applications. Note that JavaBeans and Enterprise Javabeans are not alternatives to each other. JavaBeans generally serve the presentation tier, and Enterprise JavaBeans serve the business tier."

    I think the folks responsible for Hibernate would tend to "disagree" with the items that I marked with *** - as JavaBean style objects are used in Hibernate systems to "implement often-complex server-side business logic" in the "business tier" - but the above certainly reflect's Sun's J2EE view.
    [ September 08, 2005: Message edited by: Peer Reynders ]
     
    Ramakrishnan Viswanathan
    Ranch Hand
    Posts: 90
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks to all for the elaborate explanations.

    Regards
    Ram
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic