org.objectweb.jonas_ejb.container
Class JContext

java.lang.Object
  extended by org.objectweb.jonas_ejb.container.JContext
All Implemented Interfaces:
javax.ejb.EJBContext
Direct Known Subclasses:
JEntityContext, JSessionContext

public abstract class JContext
extends java.lang.Object
implements javax.ejb.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
           
protected  javax.ejb.EnterpriseBean myinstance
           
protected  org.objectweb.transaction.jta.TransactionManager tm
           
 
Constructor Summary
protected JContext(JFactory bf, javax.ejb.EnterpriseBean i)
          Constructs a JContext
 
Method Summary
 java.security.Identity getCallerIdentity()
          Deprecated.  
 java.security.Principal getCallerPrincipal()
          Obtain the java.security.Principal that identifies the caller.
 javax.ejb.EJBHome getEJBHome()
          the enterprise bean's home interface.
 javax.ejb.EJBLocalHome getEJBLocalHome()
          Obtain the enterprise bean's local home interface.
 java.util.Properties getEnvironment()
          Deprecated.  
 boolean getRollbackOnly()
          Tests if the transaction has been marked for rollback only.
 int getState()
          Get the Instance State
abstract  javax.ejb.TimerService getTimerService()
          Get access to the EJB Timer Service.
 javax.transaction.UserTransaction getUserTransaction()
          Obtains the transaction demarcation interface.
 javax.resource.spi.work.WorkManager getWorkManager()
          Get the WorkManager
 boolean isCallerInRole(java.security.Identity role)
          Deprecated. Use boolean isCallerInRole(String roleName) instead. Tests if the caller has a given role.
 boolean isCallerInRole(java.lang.String roleName)
          Test if the caller has a given role.
 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 javax.ejb.EnterpriseBean myinstance

bf

protected final JFactory bf

tm

protected final org.objectweb.transaction.jta.TransactionManager tm
Constructor Detail

JContext

protected JContext(JFactory bf,
                   javax.ejb.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


getState

public int getState()
Get the Instance State

Throws:
java.lang.Exception

getWorkManager

public javax.resource.spi.work.WorkManager getWorkManager()
Get the WorkManager


getCallerIdentity

public java.security.Identity getCallerIdentity()
Deprecated. 

Obtains the java.security.Identity of the caller.

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

getCallerPrincipal

public java.security.Principal getCallerPrincipal()
                                           throws java.lang.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 javax.ejb.EJBContext
Returns:
The Principal object that identifies the caller.
Throws:
java.lang.IllegalStateException - no security context exists

getEJBHome

public javax.ejb.EJBHome getEJBHome()
                             throws java.lang.IllegalStateException
the enterprise bean's home interface.

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

getEJBLocalHome

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

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

getEnvironment

public java.util.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 javax.ejb.EJBContext
Returns:
The environment properties for the enterprise bean.

getRollbackOnly

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

Specified by:
getRollbackOnly in interface javax.ejb.EJBContext
Returns:
true if transaction will rollback
Throws:
java.lang.IllegalStateException - if state is 0

getTimerService

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

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

getUserTransaction

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

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

isCallerInRole

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

Specified by:
isCallerInRole in interface javax.ejb.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(java.lang.String roleName)
                       throws java.lang.IllegalStateException
Test if the caller has a given role.

Specified by:
isCallerInRole in interface javax.ejb.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:
java.lang.IllegalStateException - Security service not started

setRollbackOnly

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

Specified by:
setRollbackOnly in interface javax.ejb.EJBContext
Throws:
java.lang.IllegalStateException - in getRollbackOnly() method