Chapter 4. Developing Your First EJBs
Now that we’ve covered the concepts behind the various component models and container services provided by the specification, it’s time to start putting these lessons into practice. In this chapter we’ll introduce the terminology and syntax necessary to code, package, deploy, and test some functional EJBs.
Step 1: Preparation
Let’s briefly lay out some definitions and conventions, and then we’ll get to hacking away.
Definitions
EJBs are composed from the following.
Bean implementation class (session and message-driven beans)
This class, written by the bean provider, contains the
business logic for a session or message-driven bean. It is annotated
with the appropriate bean type: @javax.ejb.Stateless, @javax.ejb.Stateful, or @javax.ejb.MessageDriven. For
instance:
@javax.ejb.Stateless
public class MyFirstBean{...}is all that’s needed to declare an SLSB.
Bean instance (session and message-driven beans)
The EJB Container internally contains one or more instances
of the bean implementation class to service session or message-driven
invocations. These are not exposed to the client, but are instead
abstracted out by way of the client view. Entity
bean instances are POJOs that may be created directly by the client
using the new operator.
Client view (session and message-driven beans)
Because clients do not invoke upon bean instances directly, this is the contract with which a client will interact with the EJB. In the case of a session bean, the client view will ...