Name

EJBContext

Synopsis

The EJBContext interface is the base interface for context objects provided to EJB objects by their containers. The EJBContext represents runtime context information that the EJB object can use during method calls to check on environment variables, query the identity of the caller, etc.

The getCallerIdentity() and isCallerInRole() methods are provided to allow the EJB object to check on the identity of the caller, if it is known. The getEnvironment() method provides a Properties list with any environment variables that the EJB container exports to its EJB objects. The getEJBHome() method returns an instance of the EJB object’s home interface, which allows the EJB object to query about its own type, implementing classes, etc. The rest of the EJBContext methods are related to transaction support. The getUserTransaction() method is the EJB object’s access to the container-provided implementation of the javax.transaction.UserTransaction interface. The getRollbackOnly() method tells the EJB object if it is operating within a transaction that has been rolled back, and the setRollbackOnly() method sets the current enclosing transaction, if any, to be rolled back.

public interface EJBContext {
// Property Accessor Methods (by property name)
   public abstract java.security.Principal getCallerPrincipal(   // 1.1
        );  
   public abstract EJBHome getEJBHome();  
   public abstract EJBLocalHome getEJBLocalHome();               // 2.0
   public abstract boolean getRollbackOnly( ) throws java.lang.IllegalStateException; ...

Get Java Enterprise in a Nutshell, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.