J2EE (Enterprise Endition) Java Beans
Java beans run within (are managed by) an EJB Container maintained by
an application server (j2ee.exe in the Sun J2EE Reference Platform).
It uses interfaces in the J2EE extension javax.ejb.EnterpriseBean,
which is extended by several bean libraries:
- SessionBean
- EntityBean
- MessageDrivenBean (Mail service)
Session beans execute a particular business task on behalf of a single client.
Session beans are non-persistent.
When a client finishes with a session bean, the bean goes away.
There are 2 kinds of session beans:
- Stateless Session beans are used to cache and manage
infrequently changed data.
They must be updated explicitly.
- Stateful Session beans, which "most architects avoid if at all possible."[1]
Entity beans represent business objects in a data store, usually in a relational database system.
Entity bean methods model the behaviors of the business objects they represent.
There are 2 kinds of beans which load and save data:
- Container-managed persistence (CMP) entity bean
for declarative transaction management.
- Bean-managed persistence (BMP) entity bean
Entity beans can be accessed concurrently by
multiple clients and they are persistent by definition.
So they are pooled.
Entity beans are the only dedicated data access components in J2EE and
also the most questionable part of J2EE,
Their non-J2EE alternatives include Hibernate and JDO.
Message beans are not associated with any client
since they simply handle messages as they arrive.
EJBs may not spawn threads, access files directly, use graphics or sockets.
Local interfaces in EJB 2.0 is one attempt to improve overall performance: local interfaces provide for beans in the same container to interact locally without involving RMI.
Run client
Instead of java.exe, EJB clients are run with a client program
which enforces user password authentication.
The Sun J2EE Reference Platform provides the runclient.exe program:
runclient -client xx.ear -name xx.class
WebLogic Server 8.1
supports a true J2EE application thin client in
a small footprint (400 KB) standard wlclient.jar and
wljmsclient.jar for JMS.
These are provided in the /server/lib subdirectory of the
weblogic81 installation directory.
In previous versions of WebLogic Server,
a Java client required the full WebLogic Server JAR on the client machine.
This client JAR file also contains a Main-Class
entry in its META-INF/MANIFEST.MF file to specify the entry point for the program.
Application clients directly access Enterprise JavaBeans
running in the business tier, and may, as appropriate communicate through HTTP with servlets
running in the Web tier.
The client doesn't invoke EJB methods directly, but
through a remote interface proxy exposed by
EJB remote objects which contain business methods
such as “getPubNames()”.
RMI/IIOP remoting is an outstanding remoting technology with EJB.
There are better alternatives for thread pooling web services remoting
because a web container provides thread pooling and
there’s no need to duplicate it in the business object tier.
| |
Buy Java beans:
- IBM alphaBeans
- JClass Enterprise Suite from KL Group
- StudioJ from Rogue Wave Software
$21 EJB Design Patterns: Advanced Patterns, Processes, and Idioms
(Wiley, February 2002. 288 pages)
by Floyd Marinescu, Ed Roman.
$27 Mastering Enterprise JavaBeans (2nd Edition)
(John Wiley, December 14, 2001. 672 pages)
by Ed Roman, Scott W. Ambler, Tyler Jewell, Floyd Marinescu
$42 Professional EJB
(Wrox Press: July 2001. 1200 pages)
by P G Sarang, Kyle Gabhart, Andre Tost, Tim McAllister, Rahim Adatia, Matjaz Juric, Ted Osborne, Faiz Arni, Jeremiah Lott, Vaidyanathan Nagarajan, Craig A. Berry, Dan O'Connor, John Griffin, Aaron Mulder, Dave Young
$35 Developing EJB 2.0 Components
(Prentice Hall: March 2002. 654 pages)
by Pravin V. Tulachan
| |
|