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

Sun Microsystem Inc

Concepts

Enterprise JavaBeans v1.1, Final Release

Entity Bean Component Contract

state of the entity object from the database. After the first ejbLoad within a transaction, the container is not required to recognize that the state of the entity object in the database has been changed by another transaction, and it is not required to notify the instance of this change via another ejbLoad call.

The container must invoke this method in the transaction context determined by the transaction attribute of the business method that triggered the ejbLoad method.

public void ejbStore();

The container must invoke this method on the instance whenever it becomes necessary for the instance to synchronize its state in the database with the state of the instance’s fields. This synchronization always happens at the end of a transaction. However, the container may also invoke this method when it passivates the instance in the middle of a transaction, or when it needs to transfer the most recent state of the entity object to another instance for the same entity object in the same transaction (see Subsection 11.7).

The container must invoke this method in the same transaction context as the previously invoked ejbLoad or ejbCreate method.

public primary key type or collection ejbFind<METHOD>(...);

The container invokes the ejbFind<METHOD>(...) method on an instance when a client invokes a matching find<METHOD>(...) 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 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.

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 11.6.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 9.1.8 for information on collections.)

9.1.6 Operations allowed in the methods of the entity bean class

Table 4 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 4, the Container must throw the java.lang.IllegalStateException.

109

11/24/99

Sun Microsystems Inc.

Entity Bean Component Contract

Enterprise JavaBeans v1.1, Final Release

Concepts

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

11/24/99

110

Sun Microsystem Inc

Concepts

Enterprise JavaBeans v1.1, Final Release

Entity Bean Component Contract

Table 4

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

 

 

 

 

 

 

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

 

 

 

 

111

11/24/99