EJB : Java Glossary

go to home page E words local find full screen, hide local find menu Google search web for more information on this topic jump to foot of page translate this page with Babelfish 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) ©1996-2009 Roedy Green, Canadian Mind Products
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⇒Enterprise JavaBeans 3.0, Fifth Edition
 paperback
ISBN13:978-0-596-00978-6impressioncounter
publisher:O’Reilly recommended
published:2006-05-16
by:Bill Burke, Richard Monson-Haefel
covers JBOSS. Also high level information for managers and tips on design.
UK flag abe books.co.uk abe books.ca Canadian flag
UK flag amazon.co.uk. amazon.ca. Canadian flag
German flag abe books.de chapters.indigo.ca. Canadian flag
German flag amazon.de. abe books.com American flag
French flag abe books.fr amazon.com. American flag
French flag amazon.fr. barnes and noble.com American flag
Italian flag abe books.it powells.com American flag
Spanish flag iberlibro.com sony e-books American flag
Australian flag abe books anz download o’reilly safari American flag

book cover recommend book⇒Building Java Enterprise Applications Volume I: Architecture
 paperback
ISBN13:978-0-596-00123-0impressioncounter
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 EE.
UK flag abe books.co.uk abe books.ca Canadian flag
UK flag amazon.co.uk. amazon.ca. Canadian flag
German flag abe books.de chapters.indigo.ca. Canadian flag
German flag amazon.de. abe books.com American flag
French flag abe books.fr amazon.com. American flag
French flag amazon.fr. barnes and noble.com American flag
Italian flag abe books.it powells.com American flag
Spanish flag iberlibro.com sony e-books American flag
Australian flag abe books anz download o’reilly safari American flag

book cover recommend book⇒Enterprise Java Beans
 paperback
ISBN13:978-1-56592-605-9impressioncounter
publisher:O’Reilly recommended
published:1999-06
by:Richard Monson-Haefel
UK flag abe books.co.uk abe books.ca Canadian flag
UK flag amazon.co.uk. amazon.ca. Canadian flag
German flag abe books.de chapters.indigo.ca. Canadian flag
German flag amazon.de. abe books.com American flag
French flag abe books.fr amazon.com. American flag
French flag amazon.fr. barnes and noble.com American flag
Italian flag abe books.it powells.com American flag
Spanish flag iberlibro.com sony e-books American flag
Australian flag abe books anz download o’reilly safari American flag
There are many different ways of using EJBs, sometimes called idioms.
BEA Weblogic make one of the best known EJB servers
EE
EJB 3 spec
EJBoss
Hibernate
IBM essay on EJBs: There are many other essays at the IBM site
JAAS
JDBC
JMS
JNDI
JSP
JTA
MVC
OpenEJB
Pramati EJB 2.0
RMI
Servlet

CMP homejump to top You can get the freshest copy of this page from: or possibly from your local J: drive (Java virtual drive/mindprod.com website mirror)
http://mindprod.com/jgloss/ejb.html J:\mindprod\jgloss\ejb.html
CMP logofeedback Please email your feedback for publication, errors, omissions, typos, formatting errors, ambiguities, unclear wording, broken/redirected link reports, suggestions to improve this page or comments to Roedy Green : feedback email
mindprod.com IP:[65.110.21.43]
view BlogYour face IP:[38.107.191.104]
You are visitor number 21,255.