First page Back Continue Last page Graphics
Using Contexts
EJBContext has methods to:
- Get the bean’s home object
- Get security information about the bean
- Get a user transaction
- Mark the current transaction for rollback
- See notes for complete listing...
SessionContext
adds one method:
EntityContext
adds two methods:
Notes:
The objects passed to setSessionContext() and setEntityContext() both implement the javax.ejb.EJBContext interface. It provides a number of methods that the bean instance will use from time to time. Here is the complete listing:
public interface EJBContext {
// Get a reference to the bean’s home
public EJBHome getEJBHome( );
// Security-related methods
public java.security.Principal getCallerPrincipal( );
public boolean isCallerInRole( java.lang.String roleName );
// Transaction-related methods
public UserTransaction getUserTransaction( )
throws IllegalStateException;
public void setRollbackOnly( ) throws IllegalStateException;
public boolean getRollbackOnly( ) throws IllegalStateException;
}
Continued...