cuba.ejb
Class EJB3ComponentContext

java.lang.Object
  extended by cuba.AbstractComponentContext
      extended by cuba.ejb.AbstractEJBComponentContext
          extended by cuba.ejb.EJB3ComponentContext
All Implemented Interfaces:
ComponentContextI, ContextI

public class EJB3ComponentContext
extends AbstractEJBComponentContext


Nested Class Summary
 
Nested classes/interfaces inherited from interface cuba.ContextI
ContextI.Type
 
Field Summary
protected  java.util.Map<java.lang.String,java.lang.Object> defaultEnvironment
          Map of environment entries to be used if there is nothing else specified in the wrapped SessionContext.
 
Fields inherited from class cuba.ejb.AbstractEJBComponentContext
context
 
Constructor Summary
EJB3ComponentContext(javax.ejb.SessionContext context, EJB3Adapter adapter)
           
 
Method Summary
 ClientContextI getClientContext()
          Create a client context from a component context which provides external access to the same container which the current component resides in.
 java.lang.Object getComponent(java.lang.String name)
          Looks up a component refered to by a symbolic name.
 javax.sql.DataSource getDataSource(java.lang.String name)
          Looks up an SQL database refered to by a symbolic name.
 java.lang.Object getEnvironment(java.lang.String name)
          Looks up an environment entry refered to by a symbolic name.
 
Methods inherited from class cuba.ejb.AbstractEJBComponentContext
getCallerName, getLocalContext, getRollbackOnly, getTransaction, getType, isCallerInRole, popCall, pushCall, setRollbackOnly
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultEnvironment

protected java.util.Map<java.lang.String,java.lang.Object> defaultEnvironment
Map of environment entries to be used if there is nothing else specified in the wrapped SessionContext. This map is required because CUBA's EJB 3 support is completely based on code annotations which don't allow to specify values for environment lookups. The content is provided by the generated EJB 3 adapters which instanciate the component context objects and potentially provide the default environment as a static member, accessible through EJB3ComponentContext#_getDefaultEnvironment.

Constructor Detail

EJB3ComponentContext

public EJB3ComponentContext(javax.ejb.SessionContext context,
                            EJB3Adapter adapter)
Method Detail

getClientContext

public ClientContextI getClientContext()
Description copied from interface: ComponentContextI
Create a client context from a component context which provides external access to the same container which the current component resides in. This function is especially required to perform global lookups from inside the container, e.g. when integrating things like persistence management frameworks.

Returns:
The client context

getComponent

public java.lang.Object getComponent(java.lang.String name)
                              throws ConstructionException,
                                     ReferenceException
Description copied from interface: ContextI
Looks up a component refered to by a symbolic name. The lookup is performed either in a global name space or in a local one depending on the type of context used.

Specified by:
getComponent in interface ContextI
Specified by:
getComponent in class AbstractEJBComponentContext
Parameters:
name - The symbolic name of the component to look up
Returns:
A proxy object, implementing the component's interface. The return value must be casted to the required type.
Throws:
ConstructionException - if the container failed to provide the required component
ReferenceException - if the provided symbolic name cannot be resolved.

getDataSource

public javax.sql.DataSource getDataSource(java.lang.String name)
                                   throws ConstructionException,
                                          ReferenceException
Description copied from interface: ContextI
Looks up an SQL database refered to by a symbolic name. The lookup is performed either in a global name space or in a local one depending on the type of context used.

Specified by:
getDataSource in interface ContextI
Overrides:
getDataSource in class AbstractEJBComponentContext
Parameters:
name - The symbolic name of the SQL source to look up
Returns:
A proxy object, providing access to the database.
Throws:
ConstructionException - if the container failed to provide the required SQL database
ReferenceException - if the provided symbolic name cannot be resolved.

getEnvironment

public java.lang.Object getEnvironment(java.lang.String name)
                                throws ReferenceException
Description copied from class: AbstractEJBComponentContext
Looks up an environment entry refered to by a symbolic name.

Specified by:
getEnvironment in interface ComponentContextI
Overrides:
getEnvironment in class AbstractEJBComponentContext
Parameters:
name - The symbolic name of the environment entry to look up
Returns:
The enrtie's value. The return value must be casted to the required type.
Throws:
ReferenceException - if the provided symbolic name cannot be resolved.