org.ow2.jonas.lib.ejb21
Class JContext

java.lang.Object
  extended by org.ow2.jonas.lib.ejb21.JContext
All Implemented Interfaces:
EJBContext
Direct Known Subclasses:
JEntityContext, JSessionContext

public abstract class JContext
extends Object
implements EJBContext

This class implements javax.ejb.EJBContext class. It may be extended in JSessionContext or JEntityContext

Author:
Philippe Coq, Philippe Durieux, Jeff Mesnil (security), Florent Benoit (JACC security)

Field Summary
protected  JFactory bf
           
static int CTX_STATE_ACTIVE
           
static int CTX_STATE_COMMITTING
           
static int CTX_STATE_FINDING
           
static int CTX_STATE_INITIAL
          State of this Context This state is used to know if some operation is allowed or not in this context.
static int CTX_STATE_PASSIVE
           
protected  EnterpriseBean myinstance
           
protected  TransactionManager tm
           
 
Constructor Summary
protected JContext(JFactory bf, EnterpriseBean i)
          Constructs a JContext
 
Method Summary
 Identity getCallerIdentity()
          Deprecated.  
 Principal getCallerPrincipal()
          Obtain the java.security.Principal that identifies the caller.
 EJBHome getEJBHome()
          the enterprise bean's home interface.
 EJBLocalHome getEJBLocalHome()
          Obtain the enterprise bean's local home interface.
 Properties getEnvironment()
          Deprecated.  
 boolean getRollbackOnly()
          Tests if the transaction has been marked for rollback only.
 int getState()
          Get the Instance State
abstract  TimerService getTimerService()
          Get access to the EJB Timer Service.
 UserTransaction getUserTransaction()
          Obtains the transaction demarcation interface.
 WorkManager getWorkManager()
          Get the WorkManager
 boolean isCallerInRole(Identity role)
          Deprecated. Use boolean isCallerInRole(String roleName) instead. Tests if the caller has a given role.
 boolean isCallerInRole(String roleName)
          Test if the caller has a given role.
 Object lookup(String name)
          Lookup object with given name.
 void setActive()
           
 void setCommitting()
           
 void setFinding()
           
 void setPassive()
           
 void setRollbackOnly()
          Marks the current transaction for rollback.
 void setState(int newState)
          Set the instance State
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myinstance

protected EnterpriseBean myinstance

bf

protected final JFactory bf

tm

protected final TransactionManager tm

CTX_STATE_INITIAL

public static final int CTX_STATE_INITIAL
State of this Context This state is used to know if some operation is allowed or not in this context. May be used also for debugging.

See Also:
Constant Field Values

CTX_STATE_PASSIVE

public static final int CTX_STATE_PASSIVE
See Also:
Constant Field Values

CTX_STATE_ACTIVE

public static final int CTX_STATE_ACTIVE
See Also:
Constant Field Values

CTX_STATE_COMMITTING

public static final int CTX_STATE_COMMITTING
See Also:
Constant Field Values

CTX_STATE_FINDING

public static final int CTX_STATE_FINDING
See Also:
Constant Field Values
Constructor Detail

JContext

protected JContext(JFactory bf,
                   EnterpriseBean i)
Constructs a JContext

Parameters:
bf - - the BeanFactory
i - - the bean instance
Method Detail

setState

public void setState(int newState)
Set the instance State


setPassive

public void setPassive()

setActive

public void setActive()

setCommitting

public void setCommitting()

setFinding

public void setFinding()

getState

public int getState()
Get the Instance State

Throws:
Exception

getWorkManager

public WorkManager getWorkManager()
Get the WorkManager


getCallerIdentity

public Identity getCallerIdentity()
Deprecated. 

Obtains the java.security.Identity of the caller.

Specified by:
getCallerIdentity in interface EJBContext
Returns:
The Identity object that identifies the caller.

getCallerPrincipal

public Principal getCallerPrincipal()
                             throws IllegalStateException
Obtain the java.security.Principal that identifies the caller. throws a java.lang.IllegalStateException if there is no security context available

Specified by:
getCallerPrincipal in interface EJBContext
Returns:
The Principal object that identifies the caller.
Throws:
IllegalStateException - no security context exists

getEJBHome

public EJBHome getEJBHome()
                   throws IllegalStateException
the enterprise bean's home interface.

Specified by:
getEJBHome in interface EJBContext
Returns:
The enterprise bean's home interface.
Throws:
IllegalStateException - - if the enterprise bean does not have a local home interface.

getEJBLocalHome

public EJBLocalHome getEJBLocalHome()
                             throws IllegalStateException
Obtain the enterprise bean's local home interface.

Specified by:
getEJBLocalHome in interface EJBContext
Returns:
The enterprise bean's local home interface.
Throws:
IllegalStateException - if the enterprise bean does not have a local home interface.

getEnvironment

public Properties getEnvironment()
Deprecated. 

Obtains the enterprise bean's environment properties for EJB 1.0 style. (Conform to EJB 1.1 specification for a container chooses to provide support for EJB 1.0 style environment properties. Cf EJB 1.1 Chapter 14.5, pages 216-217) Note: If the enterprise bean has no environment properties, this method returns an empty java.util.Properties object. This method never returns null.

Specified by:
getEnvironment in interface EJBContext
Returns:
The environment properties for the enterprise bean.

getRollbackOnly

public boolean getRollbackOnly()
                        throws IllegalStateException
Tests if the transaction has been marked for rollback only.

Specified by:
getRollbackOnly in interface EJBContext
Returns:
true if transaction will rollback
Throws:
IllegalStateException - if state is 0

getTimerService

public abstract TimerService getTimerService()
                                      throws IllegalStateException
Get access to the EJB Timer Service.

Specified by:
getTimerService in interface EJBContext
Returns:
the EJB Timer Service
Throws:
IllegalStateException - Thrown if the instance is not allowed to use this method (e.g. if the bean is a stateful session bean)

getUserTransaction

public UserTransaction getUserTransaction()
                                   throws IllegalStateException
Obtains the transaction demarcation interface.

Specified by:
getUserTransaction in interface EJBContext
Returns:
The UserTransaction interface that the enterprise bean instance can use for transaction demarcation.
Throws:
IllegalStateException - Thrown if the instance container does not make the UserTransaction interface available to the instance. (not bean managed)

isCallerInRole

public boolean isCallerInRole(Identity role)
Deprecated. Use boolean isCallerInRole(String roleName) instead. Tests if the caller has a given role.

Specified by:
isCallerInRole in interface EJBContext
Parameters:
role - - The java.security.Identity of the role to be tested.
Returns:
True if the caller has the specified role.

isCallerInRole

public boolean isCallerInRole(String roleName)
                       throws IllegalStateException
Test if the caller has a given role.

Specified by:
isCallerInRole in interface EJBContext
Parameters:
roleName - The name of the security role. The role must be one of the security-role-ref that is defined in the deployment descriptor.
Returns:
True if the caller has the specified role.
Throws:
IllegalStateException - Security service not started

setRollbackOnly

public void setRollbackOnly()
                     throws IllegalStateException
Marks the current transaction for rollback. The transaction will become permanently marked for rollback.

Specified by:
setRollbackOnly in interface EJBContext
Throws:
IllegalStateException - in getRollbackOnly() method

lookup

public Object lookup(String name)
Lookup object with given name.

Specified by:
lookup in interface EJBContext
Parameters:
name - given name
Returns:
result of the lookup


Copyright © 2010 OW2 Consortium. All Rights Reserved.