com.bm.utils.substitues
Class FakedSessionContext

java.lang.Object
  extended by com.bm.utils.substitues.FakedSessionContext
All Implemented Interfaces:
EJBContext, SessionContext

public class FakedSessionContext
extends java.lang.Object
implements SessionContext

Represnts a dummy implementation for a session context. Later we can implements more functionality here.

Author:
Daniel Wiese

Constructor Summary
FakedSessionContext()
           
 
Method Summary
<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.
 java.security.Identity getCallerIdentity()
          
 java.security.Principal getCallerPrincipal()
          
 EJBHome getEJBHome()
          
 EJBLocalHome getEJBLocalHome()
          
 EJBLocalObject getEJBLocalObject()
          Obtain a reference to the EJB local object that is associated with the instance.
 EJBObject getEJBObject()
          Obtain a reference to the EJB object that is currently associated with the instance.
 java.util.Properties getEnvironment()
          
 java.lang.Class getInvokedBusinessInterface()
          Obtain the business interface through which the current business method invocation was made.
 MessageContext getMessageContext()
          Obtain a reference to the JAX-RPC MessageContext.
 boolean getRollbackOnly()
          Check if current transaction is marked as rollback only.
 TimerService getTimerService()
          Gets the timer service.
 javax.transaction.UserTransaction getUserTransaction()
          Gets the current transaction.
 boolean isCallerInRole(java.security.Identity role)
          
 boolean isCallerInRole(java.lang.String roleName)
          Check if the given role is in the roles of the current caller's principal.
 java.lang.Object lookup(java.lang.String name)
          Search the given name in java:comp/env ENC environment.
 void setRollbackOnly()
          Sets the current transaction in rollback only mode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FakedSessionContext

public FakedSessionContext()
Method Detail

getBusinessObject

public <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.

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.

getEJBLocalObject

public EJBLocalObject getEJBLocalObject()
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.

getEJBObject

public EJBObject getEJBObject()
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.

getInvokedBusinessInterface

public java.lang.Class getInvokedBusinessInterface()
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.

getMessageContext

public MessageContext getMessageContext()
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.

getCallerPrincipal

public java.security.Principal getCallerPrincipal()

Specified by:
getCallerPrincipal in interface EJBContext
Returns:
the caller principal object.

getEJBHome

public EJBHome getEJBHome()

Specified by:
getEJBHome in interface EJBContext
Returns:
the Home(remote) interface of the bean. throws IllegalStateException if home is not retrieved

getEJBLocalHome

public EJBLocalHome getEJBLocalHome()

Specified by:
getEJBLocalHome in interface EJBContext
Returns:
the local home interface of the bean. throws IllegalStateException if local home is not retrieved

getEnvironment

public java.util.Properties getEnvironment()

Specified by:
getEnvironment in interface EJBContext
Returns:
deprecated

getRollbackOnly

public boolean getRollbackOnly()
Check if current transaction is marked as rollback only.

Specified by:
getRollbackOnly in interface EJBContext
Returns:
true if current tx is in rollback mode.

getTimerService

public TimerService getTimerService()
Gets the timer service.

Specified by:
getTimerService in interface EJBContext
Returns:
an instance of the timer service.

getUserTransaction

public javax.transaction.UserTransaction getUserTransaction()
Gets the current transaction.

Specified by:
getUserTransaction in interface EJBContext
Returns:
the transaction object

isCallerInRole

public boolean isCallerInRole(java.security.Identity role)

Specified by:
isCallerInRole in interface EJBContext
Parameters:
role - deprecated
Returns:
deprecated

isCallerInRole

public boolean isCallerInRole(java.lang.String roleName)
Check if the given role is in the roles of the current caller's principal.

Specified by:
isCallerInRole in interface EJBContext
Parameters:
roleName - the role to check.
Returns:
true if it is included, else false.

lookup

public java.lang.Object lookup(java.lang.String name)
Search the given name in java:comp/env ENC environment.

Specified by:
lookup in interface EJBContext
Parameters:
name - the name to search
Returns:
null if not found, else an instance of the object found.

setRollbackOnly

public void setRollbackOnly()
Sets the current transaction in rollback only mode.

Specified by:
setRollbackOnly in interface EJBContext

getCallerIdentity

public java.security.Identity getCallerIdentity()

Specified by:
getCallerIdentity in interface EJBContext
Returns:
deprecated


Copyright © 2008. All Rights Reserved.