From a list of behaviors, match them with the appropriate EntityContext
method responsible for that behavior.
A CONTAINER provides the entity bean instances with an EntityContext,
which gives the entity bean instance access to the instance’s context maintained by
the container. The EntityContext interface has the following
methods:
The getEJBObject method returns the entity bean’s REMOTE
[component] interface.
The getEJBHome method returns the entity bean’s REMOTE HOME
interface.
The getEJBLocalObject method returns the entity
bean’s LOCAL [component] interface.
The getEJBLocalHome method returns the entity bean’s
LOCAL HOME interface.
The getCallerPrincipal method returns the
java.security.Principal that identifies the invoker of the
bean instance’s EJB object.
The isCallerInRole method tests if the entity bean
instance’s caller has a particular role.
The setRollbackOnly method allows the instance to mark the
current transaction such that the only outcome of the transaction is
a rollback (EntityBeans support ONLY CMT).
The getRollbackOnly method allows the instance to
test if the current transaction has been marked for rollback.
(EntityBeans support ONLY CMT).
The getPrimaryKey method returns the entity bean’s primary
key.
The getUserTransaction method returns the
javax.transaction.UserTransaction interface.
Entity bean instances MUST NOT call this method. It is derived from
EJBContext interface, which is parent for contexts for
all 3 types of EJB, but it is used ONLY with BMT in Session Beans and
Messages Driven Beans.
public interface EntityContext extends EJBContext {
EJBLocalObject getEJBLocalObject() throws IllegalStateException;
EJBObject getEJBObject() throws IllegalStateException;
Object getPrimaryKey() throws IllegalStateException;
}
public interface EJBContext {
EJBHome getEJBHome();
EJBLocalHome getEJBLocalHome();
Principal getCallerPrincipal();
boolean isCallerInRole(String roleName);
UserTransaction getUserTransaction() throws IllegalStateException;
void setRollbackOnly() throws IllegalStateException;
boolean getRollbackOnly() throws IllegalStateException;
}