Write a session EJB
Find out how EJB frees developers from the complexity of middleware development by providing complete infrastructure support
By Michael Shoffner, JavaWorld.com, 07/01/98
- Digg
- Reddit
- SlashDot
- Stumble
- del.icio.us
- Technorati
- dzone
Enterprise JavaBeans (EJB) 1.0 is the exciting new enterprise component model for Java. EJB is exciting because it brings
modern, powerful capabilities to enterprise middleware written in Java.
No longer do you need to write every bit of infrastructure for the middleware tier of a Java application or (if you're lucky)
modify previous code for this purpose. Instead, EJB handles that process for you -- all you have to do is write the actual
business logic you are trying to implement.
In this article, we'll see how EJB is able to work such miracles. We'll begin with a brief background on the component software
model, then we'll zero in on EJB itself. Once you have your bearings, we'll revisit the Forum application of columns past
(see Resources for links to all previous Step by Step columns) and port its middleware tier to an enterprise bean.
The component software model
The component software model is based on the idea of creating reusable components that plug into containers. This model is
rapidly gaining popularity in the software development community because it addresses several important development goals:
reuse, high-level development focus, development automation via tools, and simplified deployment. JavaBeans, EJB, and ActiveX/COM
are examples of component models.
Component models come in two basic flavors -- client-side and enterprise. Client-side component models such as JavaBeans are
specialized to handle presentation and user interface issues. Enterprise component models such as EJB are concerned with providing
infrastructure for transactions-oriented middleware components.
Using one of the component model specs, component developers write component "building blocks" that implement business logic.
Application developers hook up these pre-built components into finished applications, which may themselves be components.
This building block approach facilitates off-the-shelf reuse of code packaged as components. Containers provide services so
that component developers can write high-level business logic instead of infrastructure such as networking code. Development
automation is achieved through development environments that allow the application developer to assemble components, usually
using a visual metaphor.
The enterprise component model
Enterprise component models such as EJB and ActiveX/MTS bring the component model of development to middleware. Enterprise
middleware development is notoriously complicated -- it involves not only business logic, but concurrency and scaling issues,
as well as gluing together incompatible systems on incompatible platforms.
Enterprise component models solve middleware development complexity by factoring all of this infrastructure into containers
and servers. This allows the middleware developer to focus on writing the business logic, without having to worry about synchronization,
scalability, transaction integrity, networking, distributed object frameworks, and other related matters.
In other words, the enterprise component model offers developers the following advantages:
- Digg
- Reddit
- SlashDot
- Stumble
- del.icio.us
- Technorati
- dzone
Resources
- Download the complete source as a zip file http://www.javaworld.com/jw-07-1998/step/jw-07-step.zip
- Download the complete source as a gzipped tar file http://www.javaworld.com/jw-07-1998/step/jw-07-step.tar.gz
- EJB development libraries and documentation
- Previous Step by Step articles
- "Draw textured spheres" -- Learn a few basics of computer graphics programming -- texture mapping, shading, and perspective -- and how to display
your creation with Java's java.awt.image package.
- "Write your own MOM!" -- Write your own general-purpose, message-oriented middleware.
- "Release your inner poetUse servlets to create a collaborative poetry app" -- Add two facilities for collaboration to an otherwise humdrum applet.
- "Add the power of CORBA to our distributed whiteboard" -- Find out how to transport serialized Java objects to and from an applet client and a Java server using CORBA.
- "Networking our whiteboard with servlets" -- Find out how to easily replace the RMI and sockets networking layers with servlets.
- "Networking our whiteboard with Java 1.1" -- Find out how easy it is to network our whiteboard with servers, sockets, and RMI.
- "Draw the worldCreate networked whiteboards with Java 1.1" -- Learn how to easily write a whiteboard using the new features of JDK 1.1.
- "Increase the functionality in your distributed client/server apps" -- Create the most elegant communications and storage solutions for your client/server apps with RMI and object serialization.
- "Building a bevy of beansCreate reusable JavaBeans components" -- With the basics of beans in the bag, you're now ready to see how easy it is to develop more advanced beans.
- "Building a bevy of beans" -- JavaBeans has transformed Java from a simple language to a powerful RAD platform; learn how you can get the most from
this new Java paradigm.
- "Chart your way to custom graph components" -- Learn to build a graph framework and custom graph components.
- " Scale an application from two to three tiers with JDBC" -- Learn how we can use JDBC to convert our Forum server application into a middleware layer.
- "Moving to JDK 1.1Using the delegation event model to create custom AWT components" -- Learn how a move to JDK 1.1 affects the way you create custom components.
- "Creating custom components" -- Learn how easy it is to create specialized components, reuse them, and keep your application-level code cleaner with
internal event handling.
- "Write your own threaded discussion forumPart 2" -- Learn how to implement a simple communications protocol to get a forum discussion group up and running.
- "Write your own threaded discussion forumPart 1" -- Use a forum to make your Web site more interactive, provide customer support, and more.
- "Stepping through a site navigator applet" -- Enhance your Web site with a convenient, hierarchical interface.
- "Stepping through an image map applet" -- Spice up any Web site with this reusable Java code.