Tuscany Core

org.apache.tuscany.core.context.scope
Class CompositeScopeContext

java.lang.Object
  extended by org.apache.tuscany.core.context.impl.AbstractLifecycle
      extended by org.apache.tuscany.core.context.scope.CompositeScopeContext
All Implemented Interfaces:
java.util.EventListener, Lifecycle, RuntimeEventListener, ScopeContext

public class CompositeScopeContext
extends AbstractLifecycle
implements ScopeContext

Manages the lifecycle of composite component contexts, i.e. contexts which contain child contexts

Version:
$Rev: 400246 $ $Date: 2006-05-06 02:18:32 -0400 (Sat, 06 May 2006) $
See Also:
CompositeContext

Field Summary
 
Fields inherited from class org.apache.tuscany.core.context.impl.AbstractLifecycle
lifecycleState, name
 
Fields inherited from interface org.apache.tuscany.core.context.Lifecycle
CONFIG_ERROR, ERROR, INITIALIZED, INITIALIZING, RUNNING, STARTED, STOPPED, STOPPING, UNINITIALIZED
 
Constructor Summary
CompositeScopeContext(EventContext eventContext)
           
 
Method Summary
 Context getContext(java.lang.String ctxName)
          Returns a context bound to the given name or null if the component does not exist.
 Context getContextByKey(java.lang.String ctxName, java.lang.Object key)
          Returns a context bound to the given name and scoped to the given key or null if the context does not exist
 java.lang.Object getInstance(QualifiedName qName)
           
 boolean isCacheable()
          Returns whether implementation instances may be held for the duration of an wire
 void onEvent(Event event)
           
 void registerFactories(java.util.List<ContextFactory<Context>> configurations)
          Registers the context factory used to construct instance contexts for the scope
 void registerFactory(ContextFactory<Context> configuration)
          Adds a context factory to the scope
 void removeContext(java.lang.String ctxName)
          Removes a context with the given name, determining the scope key from the thread context
 void removeContextByKey(java.lang.String ctxName, java.lang.Object key)
          Removes a context bound to the given name and scope key
 void start()
          Starts the Lifecycle.
 void stop()
          Stops the Lifecycle.
 
Methods inherited from class org.apache.tuscany.core.context.impl.AbstractLifecycle
addListener, addListener, getLifecycleState, getListeners, getName, publish, removeListener, setName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.tuscany.core.context.Lifecycle
getLifecycleState, getName, setName
 

Constructor Detail

CompositeScopeContext

public CompositeScopeContext(EventContext eventContext)
Method Detail

start

public void start()
           throws ScopeInitializationException
Description copied from interface: Lifecycle
Starts the Lifecycle.

Specified by:
start in interface Lifecycle
Throws:
ScopeInitializationException

stop

public void stop()
          throws ScopeRuntimeException
Description copied from interface: Lifecycle
Stops the Lifecycle.

Specified by:
stop in interface Lifecycle
Throws:
ScopeRuntimeException

registerFactories

public void registerFactories(java.util.List<ContextFactory<Context>> configurations)
Description copied from interface: ScopeContext
Registers the context factory used to construct instance contexts for the scope

Specified by:
registerFactories in interface ScopeContext

registerFactory

public void registerFactory(ContextFactory<Context> configuration)
Description copied from interface: ScopeContext
Adds a context factory to the scope

Specified by:
registerFactory in interface ScopeContext

isCacheable

public boolean isCacheable()
Description copied from interface: ScopeContext
Returns whether implementation instances may be held for the duration of an wire

Specified by:
isCacheable in interface ScopeContext

getInstance

public java.lang.Object getInstance(QualifiedName qName)
                             throws TargetException
Specified by:
getInstance in interface ScopeContext
Throws:
TargetException

getContext

public Context getContext(java.lang.String ctxName)
Description copied from interface: ScopeContext
Returns a context bound to the given name or null if the component does not exist. The returned context is bound to a key determined from the thread context.

Specified by:
getContext in interface ScopeContext

getContextByKey

public Context getContextByKey(java.lang.String ctxName,
                               java.lang.Object key)
Description copied from interface: ScopeContext
Returns a context bound to the given name and scoped to the given key or null if the context does not exist

Specified by:
getContextByKey in interface ScopeContext

removeContext

public void removeContext(java.lang.String ctxName)
                   throws ScopeRuntimeException
Description copied from interface: ScopeContext
Removes a context with the given name, determining the scope key from the thread context

Specified by:
removeContext in interface ScopeContext
Throws:
ScopeRuntimeException

removeContextByKey

public void removeContextByKey(java.lang.String ctxName,
                               java.lang.Object key)
                        throws ScopeRuntimeException
Description copied from interface: ScopeContext
Removes a context bound to the given name and scope key

Specified by:
removeContextByKey in interface ScopeContext
Throws:
ScopeRuntimeException

onEvent

public void onEvent(Event event)
Specified by:
onEvent in interface RuntimeEventListener

Tuscany Core

-