EJB : Java Glossary
home E words local find no local find frame, full screen Google search web for topic jump to footer translate with Babelfish by Roedy Green ©1996-2008 Canadian Mind Products
Go to : punctuation 0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z (all)
EJB
Enterprise Java Beans. EJBs are used mainly by large corporations. They are not something to concern the fledgling Java programmer. They are complicated. I can only give an arm waving overview that won’t enlighten much. You have to study them in detail before you even begin to understand what they are for. EJBs are probably the most difficult part of Java.

Here is a rule of thumb. If your application is so complicated that it will have to be distributed over several servers, have a look at EJB. If not, use a simpler technology.

Enterprise beans don’t have a GUI interface. Enterprise Java Beans speak CORBA IIOP for their RMI. Session Beans maintain conversational context for one client. Entity beans cache data for one row of a database. Entity beans also provide a simple persistent object database, indexed by a primary key. The Entity bean learns its primary key at create time, and may persist indefinitely. Beans make it easier to implement transaction logic with commit/rollback. The transaction processing logic helps keeps beans from interfering with each other. EJBs use JNDI to find objects. They use RMI (regular or IIOP Corba) to communicate between servers. They use JTA for transaction management.

The point of EJB is to fob much of the work of concurrency, transaction handling and persistence off on the container so the beans can concentrate on business logic.

There are several types of beans. This diagram outlines them:

bean types

Beans communicate via two proxy objects, one that implements the bean’s home (bean-finding) interface and one that implements its remote (business-logic) interface. The indirection allows the EJB container to intercept the calls and add functionality such as persistence.

Bean Flavours

EJBs come in a number of flavors.
  1. Entity beans

    Entity beans are used to represent data in a database. There are two flavors of entity beans, bean managed persistence (BMP) and container managed persistence (CMP). With CMP the container handles generating all the SQL. With BMP you have to write the SQL. A typical simple use-case is that a single instance of an entity bean represents a row in a database. Many people have soured on entity beans and prefer a simpler approach like Hibernate. In fact, the new EJB specifications endeavor to make entity beans more like Hibernate.
  2. Session beans

    Session beans are essentially service providers. A typical use-case is to encapsulate high-level business logic. For example, a session bean for a bank might implement an electronic transfer. Session beans can be stateful or stateless. A stateful session bean maintains a conversational state between itself and the client. A stateless session bean does not; a client might get completely different bean instances from one call to the next, even with the same handle.
  3. Message Driven Beans (MDB)

    Message driven beans are capable of responding to JMS messages. (The other types of beans are not able to do this do to the restrictions of the bean container.) MDB work asynchronously, the other bean types are synchronous. MDB can post JMS messages and that can be used as a “return value” of sorts.

Advantages of EJBs

Using EJBs gives you a number of things. The biggest thing is the server environment. You do not need to implement all the things that go with a server, like threading, polling, security, etc.

Using EJBs also takes away a number of things. You are not allowed to do certain things within the EJB container. E.g., you should not create threads, do file IO, listen on a socket, etc.

Books

book_cover recommend book⇒Building Java Enterprise Applications Volume I: Architecture
 paperback
ISBN10:0-596-00123-1
ISBN13:978-0-596-00123-0
publisher:O’Reilly recommended
published:2002-03
by:Brett McLaughlin
Aimed at experienced developers. Filled with particularly good advice on using EJBs and LDAP directory services Highly recommended. First volume of a three volume set on J2EE.
Canadian flag amazon.ca. amazon.com. American flag
Canadian flag chapters.indigo.ca . powells.com American flag
French flag amazon.fr. barnesandnoble.com American flag
German flag amazon.de. download O’Reilly Safari American flag
UK flag amazon.co.uk.   

book_cover recommend book⇒Enterprise Java Beans
 paperback
ISBN10:1-56592-605-6
ISBN13:978-1-56592-605-9
publisher:O’Reilly recommended
published:1999-06
by:Richard Monson-Haefel
Canadian flag amazon.ca. amazon.com. American flag
Canadian flag chapters.indigo.ca . powells.com American flag
French flag amazon.fr. barnesandnoble.com American flag
German flag amazon.de. download O’Reilly Safari American flag
UK flag amazon.co.uk.   
There are many different ways of using EJBs, sometimes called idioms.
BEA Weblogic make one of the best known EJB servers
EJB 3 spec
EJBoss
Hibernate
IBM essay on EJBs: There are many other essays at the IBM site
J2EE
JAAS
JDBC
JMS
JNDI
JSP
JTA
MVC
OpenEJB
Pramati EJB 2.0
RMI
Servlet

CMP_homejump to top
CMP logo
feedback Please email your feedback for publication, errors, omissions, broken/redirected link reports
and suggestions to improve this page to Roedy Green : feedback email
made with CSS
HTML Checked!
ICRA ratings logo
mindprod.com IP:[65.110.21.43]
Your face IP:[38.103.63.18] Spread the Net
You are visitor number 17,802.
You can get a fresh copy of this page from: or possibly from your local J: drive (Java virtual drive/Mindprod website mirror)
http://mindprod.com/jgloss/ejb.html J:\mindprod\jgloss\ejb.html