org.objectweb.easybeans.container.session
Class EasyBeansSessionContext<BeanType extends EasyBeansSB>

java.lang.Object
  extended by org.objectweb.easybeans.container.EasyBeansEJBContext
      extended by org.objectweb.easybeans.container.session.EasyBeansSessionContext<BeanType>
Type Parameters:
BeanType - Could be a stateless or stateful.
All Implemented Interfaces:
EJBContext, SessionContext

public class EasyBeansSessionContext<BeanType extends EasyBeansSB>
extends EasyBeansEJBContext
implements SessionContext

Defines the Session Context used by Stateless and Stateful beans.

Author:
Florent Benoit

Field Summary
private  BeanType bean
          Reference to the bean.
private  javax.transaction.Transaction beanTransaction
          Transaction used by this bean.
 
Constructor Summary
EasyBeansSessionContext(BeanType bean)
          Build a new Session context.
 
Method Summary
 BeanType getBean()
          Gets the bean of this context.
 javax.transaction.Transaction getBeanTransaction()
          Gets the transaction used by this bean.
<T> T
getBusinessObject(java.lang.Class<T> businessInterface)
          Obtain an object that can be used to invoke the current bean through the given business interface.
 javax.ejb.EJBLocalObject getEJBLocalObject()
          Obtain a reference to the EJB local object that is associated with the instance.
 javax.ejb.EJBObject getEJBObject()
          Obtain a reference to the EJB object that is currently associated with the instance.
 java.lang.Class getInvokedBusinessInterface()
          Obtain the business interface through which the current business method invocation was made.
 javax.xml.rpc.handler.MessageContext getMessageContext()
          Obtain a reference to the JAX-RPC MessageContext.
 void setBeanTransaction(javax.transaction.Transaction beanTransaction)
          Sets the transaction used by this bean.
 
Methods inherited from class org.objectweb.easybeans.container.EasyBeansEJBContext
getCallerIdentity, getCallerPrincipal, getEJBHome, getEJBLocalHome, getEnvironment, getRollbackOnly, getTimerService, getUserTransaction, isCallerInRole, isCallerInRole, lookup, setRollbackOnly, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.ejb.EJBContext
getCallerIdentity, getCallerPrincipal, getEJBHome, getEJBLocalHome, getEnvironment, getRollbackOnly, getTimerService, getUserTransaction, isCallerInRole, isCallerInRole, lookup, setRollbackOnly
 

Field Detail

bean

private BeanType extends EasyBeansSB bean
Reference to the bean.


beanTransaction

private javax.transaction.Transaction beanTransaction
Transaction used by this bean. (Used by stateful bean).

Constructor Detail

EasyBeansSessionContext

public EasyBeansSessionContext(BeanType bean)
Build a new Session context.

Parameters:
bean - the bean on which we are linked.
Method Detail

getBeanTransaction

public javax.transaction.Transaction getBeanTransaction()
Gets the transaction used by this bean.

Returns:
the bean transaction.

setBeanTransaction

public void setBeanTransaction(javax.transaction.Transaction beanTransaction)
Sets the transaction used by this bean.

Parameters:
beanTransaction - the bean transaction.

getBean

public BeanType getBean()
Gets the bean of this context.

Returns:
bean used by this context.

getEJBLocalObject

public javax.ejb.EJBLocalObject getEJBLocalObject()
                                           throws java.lang.IllegalStateException
Obtain a reference to the EJB local object that is associated with the instance. An instance of a session enterprise Bean can call this method at anytime between the ejbCreate() and ejbRemove() methods, including from within the ejbCreate() and ejbRemove() methods. An instance can use this method, for example, when it wants to pass a reference to itself in a method argument or result.

Specified by:
getEJBLocalObject in interface SessionContext
Returns:
The EJB local object currently associated with the instance.
Throws:
java.lang.IllegalStateException - - Thrown if the instance invokes this method while the instance is in a state that does not allow the instance to invoke this method, or if the instance does not have a local interface.

getEJBObject

public javax.ejb.EJBObject getEJBObject()
                                 throws java.lang.IllegalStateException
Obtain a reference to the EJB object that is currently associated with the instance. An instance of a session enterprise Bean can call this method at anytime between the ejbCreate() and ejbRemove() methods, including from within the ejbCreate() and ejbRemove() methods. An instance can use this method, for example, when it wants to pass a reference to itself in a method argument or result.

Specified by:
getEJBObject in interface SessionContext
Returns:
The EJB object currently associated with the instance.
Throws:
java.lang.IllegalStateException - - Thrown if the instance invokes this method while the instance is in a state that does not allow the instance to invoke this method, or if the instance does not have a remote interface.

getMessageContext

public javax.xml.rpc.handler.MessageContext getMessageContext()
                                                       throws java.lang.IllegalStateException
Obtain a reference to the JAX-RPC MessageContext. An instance of a stateless session bean can call this method from any business method invoked through its web service endpoint interface.

Specified by:
getMessageContext in interface SessionContext
Returns:
The MessageContext for this web service invocation.
Throws:
java.lang.IllegalStateException - - Thrown if this method is invoked while the instance is in a state that does not allow access to this method.

getBusinessObject

public <T> T getBusinessObject(java.lang.Class<T> businessInterface)
                    throws java.lang.IllegalStateException
Obtain an object that can be used to invoke the current bean through the given business interface.

Specified by:
getBusinessObject in interface SessionContext
Type Parameters:
T - the interface of the bean
Parameters:
businessInterface - One of the local business interfaces or remote business interfaces for this session bean.
Returns:
The business object corresponding to the given business interface.
Throws:
java.lang.IllegalStateException - - Thrown if this method is invoked with an invalid business interface for the current bean.

getInvokedBusinessInterface

public java.lang.Class getInvokedBusinessInterface()
                                            throws java.lang.IllegalStateException
Obtain the business interface through which the current business method invocation was made.

Specified by:
getInvokedBusinessInterface in interface SessionContext
Returns:
the business interface through which the current business method invocation was made.
Throws:
java.lang.IllegalStateException - - Thrown if this method is called and the bean has not been invoked through a business interface.