A beginner's guide to Enterprise JavaBeans
An introductory overview of the Java server-side application component standard
By Mark Johnson, JavaWorld.com, 10/01/98
- Digg
- Reddit
- SlashDot
- Stumble
- del.icio.us
- Technorati
- dzone
Page 4 of 7
Enterprise JavaBeans goals
The EJB Spec tries to meet several goals at once:
- EJB is designed to make it easy for developers to create applications, freeing them from low-level system details of managing
transactions, threads, load balancing, and so on. Application developers can concentrate on business logic and leave the details
of managing the data processing to the framework. For specialized applications, though, it's always possible to get "under
the hood" and customize these lower-level services.
- The EJB Spec defines the major structures of the EJB framework, and then specifically defines the contracts between them. The responsibilities
of the client, the server, and the individual components are all clearly spelled out. (We'll go over what these structures
are in a moment.) A developer creating an Enterprise JavaBean component has a very different role from someone creating an
EJB-compliant server, and the specification describes the responsibilities of each.
- EJB aims to be the standard way for client/server applications to be built in the Java language. Just as the original JavaBeans
(or Delphi components, or whatever) from different vendors can be combined to produce a custom client, EJB server components
from different vendors can be combined to produce a custom server. EJB components, being Java classes, will of course run
in any EJB-compliant server without recompilation. This is a benefit that platform-specific solutions can't hope to offer.
- Finally, the EJB is compatible with and uses other Java APIs, can interoperate with non-Java apps, and is compatible with
CORBA.
How an EJB client/server system works
To understand how an EJB client/server system operates, we need to understand the basic parts of an EJB system: the EJB component,
the EJB container, and the EJB object.
The Enterprise JavaBeans component
An Enterprise JavaBean is a component, just like a traditional JavaBean. Enterprise JavaBeans execute within an EJB container, which in turn executes within an EJB server. Any server that can host an EJB container and provide it with the necessary services can be an EJB server. (This means that
many existing servers may be extended to be EJB servers, and in fact many vendors have achieved this, or have announced the
intention to do so.)
An EJB component is the type of EJB class most likely to be considered an "Enterprise JavaBean." It's a Java class, written
by an EJB developer, that implements business logic. All the other classes in the EJB system either support client access
to or provide services (like persistence, and so on) to EJB component classes.
The Enterprise JavaBeans container
The EJB container is where the EJB component "lives." The EJB container provides services such as transaction and resource
management, versioning, scalability, mobility, persistence, and security to the EJB components it contains. Since the EJB
container handles all of these functions, the EJB component developer can concentrate on business rules, and leave database
manipulation and other such fine details to the container. For example, if a single EJB component decides that the current
transaction should be aborted, it simply tells its container (in a manner defined by the EJB Spec, and the container is responsible for performing all rollbacks, or doing whatever is necessary to cancel a transaction in
progress. Multiple EJB component instances typically exist inside a single EJB container.
- Digg
- Reddit
- SlashDot
- Stumble
- del.icio.us
- Technorati
- dzone
Resources
- You can find out more about Enterprise JavaBeans in JavaWorld in Bryan Morgan's article "Enterprise JavaBeansComing soon to a server near you." Bryan discusses EJB distributed transactions
and CORBA compatibility http://www.javaworld.com/jw-06-1998/jw-06-distributed.html
- Enterprise JavaBeans was a hot topic at this year's JavaOne. Rich Kadel's JavaOne Today technical coverage of the topic can be found at http://www.javaworld.com/javaone98/j1-98-ejb.html
- Try your hand at writing your own EJB by following Michael Shoffner's Step by Step column "Write a session EJB" featured in JavaWorld http://www.javaworld.com/jw-07-1998/jw-07-step.html
- More introductory information about EJB, including a great description of the lifecycle of an EJB, appears in the NC World article "Enterprise JavaBeansIndustrial-strength Java" http://www.ncworldmag.com/ncworld/ncw-01-1998/ncw-01-ejbeans.html
- Another NC World article covering EJB is "Bean BasicsEnterprise JavaBeans Fundamentals" http://www.ncworldmag.com/ncworld/ncw-04-1998/ncw-04-ejbprog2.html
- Sun's home page for Enterprise JavaBeans technology can be found at http://java.sun.com/products/ejb/index.html
- You can download the EJB Specification, all 181 pages of it, at http://java.sun.com/products/ejb/docs.html
- Java Report Online has a great article by Richard Monson-Haefel that goes into more detail about how to use the EJB API. This article goes into
the concepts of developer "roles" that are laid out by the EJB Specification, and provides a good backgrounder for anyone considering tackling the spec itself http://www.sigs.com/jro/features/9803/oldlayout/haefel.html
- Read Mark Johnson's previous JavaBeans columns http://www.javaworld.com/topicalindex/jw-ti-beans.html
Never Mind!^By Anonymous on January 6, 2010, 9:04 pmi'm sorry. i didn't mention the different calls. so everything is fine.
Reply | Read entire comment
Wrong picture By Anonymous on January 6, 2010, 8:11 pmYou should insert a grafic about application servers under figure 2 ;) The rest is very well! Thx
Reply | Read entire comment
Thank you so much for making it simple and understandable!By Anonymous on December 14, 2009, 8:05 amThank you so much for making it simple and understandable!
Reply | Read entire comment
Fantastic articleBy Anonymous on December 7, 2009, 5:36 amNice article to give basic knowledge about EJBs. gud for the ones starting at EJBs.
Reply | Read entire comment
EJBs overviewBy Anonymous on October 17, 2009, 7:19 amProvided a basic understanding of EJB-s. Details of implementation were missing, though I believe that is out of scope for the article.
Reply | Read entire comment
View all comments