org.jbpm.env.impl
Class DefaultEnvironment

java.lang.Object
  extended by org.jbpm.env.Environment
      extended by org.jbpm.env.impl.DefaultEnvironment
All Implemented Interfaces:
java.io.Serializable

public class DefaultEnvironment
extends Environment

Author:
Tom Baeyens
See Also:
Serialized Form

Field Summary
protected  java.lang.ClassLoader classLoader
           
static java.lang.String CONTEXTNAME_APPLICATION
          key of the application context in the environment
static java.lang.String CONTEXTNAME_BLOCK
          key of the block context in the environment
protected  java.util.Map<java.lang.String,Context> contexts
           
protected  DefaultEnvironmentFactory defaultEnvironmentFactory
           
protected  java.lang.String[] defaultSearchOrder
           
protected  java.util.ArrayList<java.lang.String> defaultSearchOrderList
           
static java.lang.String EVENT_CLOSEENVIRONMENT
          is fired when a environment created by this factory is being closed.
static java.lang.String EVENT_EXCEPTION
          is fired for each exception reported in an environment block with Environment.setException(Throwable).
static java.lang.String EVENT_OPENENVIRONMENT
          is fired when a new environment is being opened with this environment factory.
protected  java.lang.Throwable exception
           
protected  java.lang.String userId
           
 
Constructor Summary
DefaultEnvironment(DefaultEnvironmentFactory defaultEnvironmentFactory)
           
 
Method Summary
 void addContext(Context context)
           
 void close()
          closes the Environment by removing all its contexts.
<T> T
find(java.lang.Class<T> type, java.lang.String[] searchOrder)
           
<T> T
get(java.lang.Class<T> type)
          searches an object based on type.
 java.lang.Object get(java.lang.String name)
          searches a named object in all the contexts in the default search order.
 java.lang.Object get(java.lang.String name, java.lang.String[] searchOrder)
          searches a named object in all the contexts in the given search order.
 Context getApplicationContext()
           
 Context getBlockContext()
           
 java.lang.ClassLoader getClassLoader()
           
 Context getContext(java.lang.String contextName)
           
 EnvironmentFactory getEnvironmentFactory()
           
 java.lang.Throwable getException()
          retrieves the first exception that was reported in this environment block.
 Transaction getTransaction()
          convenience method for finding the Transaction.
 java.lang.String getUserId()
          get the authenticated user id
 void removeContext(java.lang.String contextName)
           
protected static void rethrow(java.lang.Throwable exception)
           
 void setClassLoader(java.lang.ClassLoader classLoader)
           
 void setException(java.lang.Throwable exception)
          for clients to indicate that an exception has occurred in this environment block.
 void setUserId(java.lang.String userId)
          set the authenticated user id
 java.lang.String toString()
           
 
Methods inherited from class org.jbpm.env.Environment
getCurrent, pop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONTEXTNAME_APPLICATION

public static final java.lang.String CONTEXTNAME_APPLICATION
key of the application context in the environment

See Also:
Constant Field Values

CONTEXTNAME_BLOCK

public static final java.lang.String CONTEXTNAME_BLOCK
key of the block context in the environment

See Also:
Constant Field Values

EVENT_EXCEPTION

public static final java.lang.String EVENT_EXCEPTION
is fired for each exception reported in an environment block with Environment.setException(Throwable).

See Also:
Constant Field Values

EVENT_CLOSEENVIRONMENT

public static final java.lang.String EVENT_CLOSEENVIRONMENT
is fired when a environment created by this factory is being closed. The info object is the environment that was just opened.

See Also:
Constant Field Values

EVENT_OPENENVIRONMENT

public static final java.lang.String EVENT_OPENENVIRONMENT
is fired when a new environment is being opened with this environment factory. The info object is the environment that was just opened.

See Also:
Constant Field Values

userId

protected java.lang.String userId

defaultEnvironmentFactory

protected DefaultEnvironmentFactory defaultEnvironmentFactory

contexts

protected java.util.Map<java.lang.String,Context> contexts

defaultSearchOrderList

protected java.util.ArrayList<java.lang.String> defaultSearchOrderList

defaultSearchOrder

protected java.lang.String[] defaultSearchOrder

classLoader

protected transient java.lang.ClassLoader classLoader

exception

protected java.lang.Throwable exception
Constructor Detail

DefaultEnvironment

public DefaultEnvironment(DefaultEnvironmentFactory defaultEnvironmentFactory)
Method Detail

getContext

public Context getContext(java.lang.String contextName)
Specified by:
getContext in class Environment

addContext

public void addContext(Context context)
Specified by:
addContext in class Environment

removeContext

public void removeContext(java.lang.String contextName)
Specified by:
removeContext in class Environment

getApplicationContext

public Context getApplicationContext()

getBlockContext

public Context getBlockContext()

getEnvironmentFactory

public EnvironmentFactory getEnvironmentFactory()
Specified by:
getEnvironmentFactory in class Environment

getUserId

public java.lang.String getUserId()
Description copied from class: Environment
get the authenticated user id

Specified by:
getUserId in class Environment

setUserId

public void setUserId(java.lang.String userId)
Description copied from class: Environment
set the authenticated user id

Specified by:
setUserId in class Environment

getClassLoader

public java.lang.ClassLoader getClassLoader()
Specified by:
getClassLoader in class Environment

setClassLoader

public void setClassLoader(java.lang.ClassLoader classLoader)
Specified by:
setClassLoader in class Environment

get

public java.lang.Object get(java.lang.String name)
Description copied from class: Environment
searches a named object in all the contexts in the default search order.

Specified by:
get in class Environment
Returns:
the object if it exists in the environment, null if there is no object with the given name in the environment.

get

public java.lang.Object get(java.lang.String name,
                            java.lang.String[] searchOrder)
Description copied from class: Environment
searches a named object in all the contexts in the given search order. The given search order doesn't have to include all contexts. It can be a subset of the contexts available.

Specified by:
get in class Environment
searchOrder - list of contexts names. The object will be searched in these contexts, in the given order.
Returns:
the object if it exists in the environment, null if there is no object with the given name in the specified searchOrder contexts.

get

public <T> T get(java.lang.Class<T> type)
Description copied from class: Environment
searches an object based on type. The search doesn take superclasses of the context elements into account.

Specified by:
get in class Environment
Returns:
the first object of the given type or null in case no such element was found.
See Also:
WireContext.get(Class)

find

public <T> T find(java.lang.Class<T> type,
                  java.lang.String[] searchOrder)

getTransaction

public Transaction getTransaction()
Description copied from class: Environment
convenience method for finding the Transaction.

Specified by:
getTransaction in class Environment

setException

public void setException(java.lang.Throwable exception)
Description copied from class: Environment
for clients to indicate that an exception has occurred in this environment block. Behaviour of method is configurable.

Specified by:
setException in class Environment

getException

public java.lang.Throwable getException()
Description copied from class: Environment
retrieves the first exception that was reported in this environment block.

Specified by:
getException in class Environment

close

public void close()
Description copied from class: Environment
closes the Environment by removing all its contexts. As a result of removing the contexts, the Context.setEnvironment(Environment) will be called with a null value for environment.

Specified by:
close in class Environment

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

rethrow

protected static void rethrow(java.lang.Throwable exception)
                       throws java.lang.Error
Throws:
java.lang.Error