Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Bean vs EJB

 
Aaron Roberts
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IIRC an EJB is an Enhanced Java Bean? In a nutshell, how does an EJB differ from a Java Bean?
A bean is pretty much just the getters and setters for fields off of an html form correct?
Does an EJB contain more program logic?
Regards,
Aaron R>
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Strictly a JavaBean is a component designed for GUI programming. The term predates J2EE and specifies a self-contained software component, i.e. it will contain both properties and methods to publish changes in those properties (typically event driven and using introspection). The term has been co-opted in the J2EE world to basically mean a class which represents some data - it has accessor and mutator methods which would be used by (for example) JSP to disply the data in a web application. So you are right, it is pretty much "the getters and setters for fields off of an html form"
An Enterprise Java Bean is a completely different type of component. The key difference with any other Java class is it they are designed to work in a distributed, multi-user environment. EJBs can only exist within an EJB container (Weblogic, Websphere, JBoss etc.), and they provide certain behaviour that is usually required for this type of software component: transaction management, (implicit) thread management, declaritive security, clustering etc.
Have a look at the J2EE tutorial on Sun's site for an introduction.
 
Aaron Roberts
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the info! That was exactly what I needed to know. Know I don't have to worry that my beans are the wrong type of bean just because I didn't understand the terminology.
Regards,
Aaron R>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic