• Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB versus JavaBean

 
Winston Smith
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I've recently searched this forum in an effort to learn the difference between an EJB and a "normal" JavaBean, so to speak. I've gained insight into EJB, but the idea that JavaBeans are client-side and EJBs are server-side? This is confusing, as I've been developing with normal JavaBeans for the past few months, and they are certainly implemented on the server-side. Does this fact alone classify them as EJBs? Eventhough I am not using the J2EE framework, or the EJB package? What exactly is a client-side JavaBean?
Thanks for your attention,
WS
 
Kishore Dandu
Ranch Hand
Posts: 1934
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Compared to a JavaBean(which has the basic premise of usable across multiple situations like JSP), EJBs have complex resposibility of enabling user session, representing the actual model of the system, enabling legacy access, abstracting different levels of the multilevel system on the server side and making sure of the transaction integrity and enable messaging(synchronous or asynchronous).
Dan
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Winston Smith:
... but the idea that JavaBeans are client-side and EJBs are server-side?

As you pointed out, this is not the correct distinction. A JavaBean is just a class that conforms to some very basic standards: get/set accessors for its attributes, optional operations (methods) that act on the data, property change listening and vetoing. Beyond that, you're free to work with JavaBeans in any manner that makes sense for your application.
Enterprise JavaBeans are JavaBeans with many more restrictions as well as a predefined usage pattern. The main difference is that EJBs are managed by an EJB container; you don't create them yourself. Another major difference is that they were designed to be distributed components that you wire together to achieve functionality.
The container provides a standard set of services to your EJBs: transactional sematics, pooling, lookup, load-balancing, fault-tolerance, etc. Your wouldn't normally ask yourself, "Should I use a JavaBean or an EJB for this?" as they handle different problems.
For example, while you could use a JavaBean to hold the values entered through a form, you'd use EJBs to read/write the form values to a database in a transactional (all or nothing) manner.
 
Malli Raman
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Both are used as a component models in the Jav application. But the way usage is different. i.e Java Beans is used for INTRA process communication and Enterprise Java Beans is used for INTER process communication (Distributed Object applications). And moreover EJB will take care of security, transactions, resource pooling also. You can say like that Java Beans can be used in the Server side as well as in the Client Side but EJB is only used for Server side.
Regards,
M.S.Raman
 
Winston Smith
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks everyone for your input. It has been very helpful.
WS
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Winston Smith,
Welcome to JavaRanch!
We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy. Obviously fictitious do not qualify.
Thanks Pardner! Hope to see you 'round the Ranch!
 
Seetesh Hindlekar
Ranch Hand
Posts: 244
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!