![Red Hat Application Server Скачать руководство пользователя страница 93](http://html.mh-extra.com/html/red-hat/application-server/application-server_manual_1427406093.webp)
Chapter 8. Developing Entity Beans
85
8.5. The Enterprise Bean Class
The EJB implementation class implements the bean’s business methods of the component interface
and the methods dedicated to the EJB environment, the interface of which is explicitly defined in
the EJB specification. The class must implement the
javax.ejb.EntityBean
interface, must be
defined as public, cannot be
abstract
for CMP 1.1, and must be abstract for CMP 2.0 (in this case,
the abstract methods are the get and set accessor methods of the bean’s cmp and cmr fields). Following
is a list of the EJB-environment dedicated methods that the EJB provider must develop.
The first set of methods are those corresponding to the create and find methods of the Home interface:
•
public PrimaryKeyClass
ejbCreate
(...);
This method is invoked by the container when a client invokes the corresponding create operation
on the enterprise Bean’s home interface. The method should initialize instance’s variables from
the input arguments. The returned object should be the primary key of the created instance. For
bean-managed persistence, the bean provider should develop here the JDBC code to create the
corresponding data in the database. For container-managed persistence, the container will perform
the database insert
after
the ejbCreate method completes and the return value should be
null
.
•
public void
ejbPostCreate
(...);
There is a matching ejbPostCreate method (same input parameters) for each ejbCreate method. The
container invokes this method after the execution of the matching ejbCreate(...) method. During the
ejbPostCreate method, the object identity is available.
•
public
,
PrimaryKeyClass or Collection
-
ejbFind
.
method
/
(...); // for bean
managed persistence only
The container invokes this method on a bean instance that is not associated with any particular
object identity (some kind of class method ...) when the client invokes the corresponding method
on the Home interface. The implementation uses the arguments to locate the requested object(s)
in the database and returns a primary key (or a collection thereof). Currently, collections will be
represented as
java.util.Enumeration
objects or
java.util.Collection
. The mandatory
FindByPrimaryKey
method takes as argument a primary key type value and returns a primary
key object (it verifies that the corresponding entity exists in the database). For
container-managed
persistence
, the bean provider does not have to write these finder methods; they are generated
at deployment time by the EJB platform tools. The information needed by the EJB platform for
automatically generating these finder methods should be provided by the bean programmer. The
EJB 1.1 specification does not specify the format of this finder method description; for
JOnAS
,
the CMP 1.1 finder methods description should be provided in the JOnAS-specific deployment
descriptor of the Entity Bean (as an SQL query). Refer to Section 8.7
Configuring Database Access
for Container-Managed Persistence
. The EJB 2.0 specification defines a standard way to describe
these finder methods, that is, in the standard deployment descriptor, as an EJB-QL query. Also
refer to Section 8.7
Configuring Database Access for Container-Managed Persistence
. Then, the
methods of the
javax.ejb.EntityBean
interface must be implemented:
•
public void
setEntityContext
(EntityContext ic);
Used by the container to pass a reference to the EntityContext to the bean instance. The container
invokes this method on an instance after the instance has been created. Generally, this method is
used to store this reference in an instance variable.
•
public void
unSetEntityContext
();
Unset the associated entity context. The container calls this method before removing the instance.
This is the last method the container invokes on the instance.
•
public void
ejbActivate
();
The container invokes this method when the instance is taken out of the pool of available in-
stances to become associated with a specific EJB object. This method transitions the instance to
the ready state.
Содержание Application Server
Страница 1: ...Red Hat Application Server JOnAS User Guide ...
Страница 8: ......
Страница 22: ...14 Chapter 1 Java Open Application Server JOnAS a J2EE Platform ...
Страница 58: ...50 Chapter 3 JOnAS Configuration ...
Страница 66: ...58 Chapter 5 JOnAS Class Loader Hierarchy ...
Страница 78: ...70 Chapter 6 JOnAS Command Reference ...
Страница 80: ......
Страница 86: ...78 Chapter 7 Developing Session Beans ...
Страница 136: ...128 Chapter 9 Developing Message Driven Beans ...
Страница 142: ...134 Chapter 10 Defining the Deployment Descriptor ...
Страница 148: ...140 Chapter 11 Transactional Behavior of EJB Applications ...
Страница 158: ...150 Chapter 14 EJB Packaging ...
Страница 162: ...154 Chapter 15 Application Deployment and Installation Guide ...
Страница 164: ......
Страница 176: ...168 Chapter 18 WAR Packaging ...
Страница 178: ......
Страница 184: ...176 Chapter 20 Defining the Client Deployment Descriptor ...
Страница 186: ...178 Chapter 21 Client Packaging ...
Страница 188: ......
Страница 192: ...184 Chapter 23 EAR Packaging ...
Страница 194: ......
Страница 200: ...192 Chapter 24 JOnAS Services ...
Страница 204: ...196 Chapter 25 JOnAS and the Connector Architecture ...
Страница 222: ...214 Chapter 27 Ant EJB Tasks Using EJB JAR ...
Страница 234: ...226 Chapter 29 Web Services with JOnAS ...
Страница 236: ......
Страница 260: ...252 Chapter 34 How to use Axis in JOnAS ...
Страница 270: ...262 Chapter 36 Web Service Interoperability between JOnAS and BEA WebLogic ...
Страница 296: ......