Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Enterprise JavaBeans™ Specification, Version 2.0 - Sun Microsystems.pdf
Скачиваний:
14
Добавлен:
24.05.2014
Размер:
2.71 Mб
Скачать

Sun Microsystems Inc.

Entity Bean Component Contract for Bean Managed PersistenceEnterprise JavaBeans 2.0, Public Draft Overview of Bean Managed

with any entity object identity) for the execution of the ejbFind<METHOD>(...) method. If there is no instance in the pooled state, the container creates one and calls the setEntityContext(...) method on the instance before dispatching the finder method.

Before invoking the ejbFind<METHOD>(...) method, the container must first synchronize the state of any entity bean instances that are participating in the same transaction context as is used to execute the ejbFind<METHOD>(...) by invoking the ejbStore() method on those entity bean instances.

After the ejbFind<METHOD>(...) method completes, the instance remains in the pooled state. The container may, but is not required to, activate the objects that were located by the finder using the transition through the ejbActivate() method.

The container must invoke the ejbFind<METHOD>(...) method in the transaction context determined by the transaction attribute of the matching find(...) method, as described in subsection 16.7.2.

If the ejbFind<METHOD> method is declared to return a single primary key, the container creates an entity EJBObject reference for the primary key and returns it to the client. If the ejbFind<METHOD> method is declared to return a collection of primary keys, the container creates a collection of entity EJBObject references for the primary keys returned from ejbFind<METHOD>, and returns the collection to the client. (See Subsection 11.1.8 for information on collections.)

public type ejbHome<METHOD>(...);

The container invokes the ejbHome<METHOD>(...) method on an instance when a client invokes a matching <METHOD>(...) home method on the entity bean’s home interface. The container must pick an instance that is in the pooled state (i.e. the instance is not associated with any entity object identity) for the execution of the ejbHome<METHOD>(...) method. If there is no instance in the pooled state, the container creates one and calls the setEntityContext(...) method on the instance before dispatching the home method.

After the ejbHome<METHOD>(...) method completes, the instance remains in the pooled state.

The container must invoke the ejbHome<METHOD>(...) method in the transaction context determined by the transaction attribute of the matching <METHOD>(...) home method, as described in subsection 16.7.2.

11.1.6 Operations allowed in the methods of the entity bean class

Table 7 defines the methods of an entity bean class in which the enterprise bean instances can access the methods of the javax.ejb.EntityContext interface, the java:comp/env environment naming context, resource managers, and other enterprise beans.

If an entity bean instance attempts to invoke a method of the EntityContext interface, and the access is not allowed in Table 7, the Container must throw the java.lang.IllegalStateException.

If an entity bean instance attempts to access a resource manager or an enterprise bean, and the access is not allowed in Table 7, the behavior is undefined by the EJB architecture.

5/31/00

228

Sun Microsystems Inc

Overview of Bean Managed Entity Persistence Enterprise JavaBeans 2.0, Public Draft

Entity Bean Component Contract for Bean

Table 7

Operations allowed in the methods of an entity bean

 

 

 

 

 

 

Bean method

Bean method can perform the following operations

 

 

 

 

 

 

 

 

 

 

constructor

-

 

 

 

 

 

 

setEntityContext

EntityContext methods: getEJBHome

 

 

unsetEntityContext

JNDI access to java:comp/env

 

 

 

 

 

 

 

 

 

 

EntityContext methods: getEJBHome, getCallerPrincipal, getRollbackOnly,

 

 

 

isCallerInRole, setRollbackOnly

 

 

ejbCreate

JNDI access to java:comp/env

 

 

 

 

 

 

Resource manager access

 

 

 

Enterprise bean access

 

 

 

 

 

 

 

EntityContext methods: getEJBHome, getCallerPrincipal, getRollbackOnly,

 

 

 

isCallerInRole, setRollbackOnly, getEJBObject, getPrimaryKey

 

 

ejbPostCreate

JNDI access to java:comp/env

 

 

 

 

 

 

Resource manager access

 

 

 

Enterprise bean access

 

 

 

 

 

 

 

EntityContext methods: getEJBHome, getCallerPrincipal, getRollbackOnly,

 

 

 

isCallerInRole, setRollbackOnly, getEJBObject, getPrimaryKey

 

 

ejbRemove

JNDI access to java:comp/env

 

 

 

 

 

 

Resource manager access

 

 

 

Enterprise bean access

 

 

 

 

 

 

 

EntityContext methods: getEJBHome, getCallerPrincipal, getRollbackOnly,

 

 

 

isCallerInRole, setRollbackOnly

 

 

ejbFind

JNDI access to java:comp/env

 

 

ejbHome

Resource manager access

 

 

 

 

 

 

Enterprise bean access

 

 

 

 

 

 

ejbActivate

EntityContext methods: getEJBHome, getEJBObject, getPrimaryKey

 

 

ejbPassivate

JNDI access to java:comp/env

 

 

 

 

 

 

 

 

 

 

EntityContext methods: getEJBHome, getCallerPrincipal, getRollbackOnly,

 

 

 

isCallerInRole, setRollbackOnly, getEJBObject, getPrimaryKey

 

 

ejbLoad

JNDI access to java:comp/env

 

 

ejbStore

Resource manager access

 

 

 

 

 

 

Enterprise bean access

 

 

 

 

 

 

 

EntityContext methods: getEJBHome, getCallerPrincipal, getRollbackOnly,

 

 

 

isCallerInRole, setRollbackOnly, getEJBObject, getPrimaryKey

 

 

business method

JNDI access to java:comp/env

 

 

from remote interface

Resource manager access

 

 

 

 

 

 

Enterprise bean access

 

 

 

 

229

5/31/00