org.apache.tuscany.sca.core.scope
Interface ScopeContainer<KEY>

Type Parameters:
KEY - the type of IDs that this container uses to identify its contexts. For example, for COMPOSITE scope this could be the URI of the composite component, or for HTTP Session scope it might be the HTTP session ID.
All Superinterfaces:
java.util.EventListener, RuntimeEventListener
All Known Implementing Classes:
AbstractScopeContainer, CompositeScopeContainer, ConversationalScopeContainer, HttpSessionScopeContainer, RequestScopeContainer, StatelessScopeContainer

public interface ScopeContainer<KEY>
extends RuntimeEventListener

Manages the lifecycle and visibility of instances associated with a an RuntimeComponent.


Field Summary
static int CONFIG_ERROR
           
static int ERROR
           
static int INITIALIZED
           
static int INITIALIZING
           
static int RUNNING
           
static int STOPPED
           
static int STOPPING
           
static int UNINITIALIZED
           
 
Method Summary
 void addWrapperReference(KEY existingContextId, KEY newContextId)
          Allows a component to be registered against more than one context id.
 InstanceWrapper getAssociatedWrapper(KEY contextId)
          Returns an implementation instance associated with the current scope context.
 int getLifecycleState()
          Returns the lifecycle state
 Scope getScope()
          Returns the Scope that this container supports.
 InstanceWrapper getWrapper(KEY contextId)
          Returns an instance wrapper associated with the current scope context, creating one if necessary
 void registerWrapper(InstanceWrapper wrapper, KEY contextId)
          Register an existing instance against a context id.
 void remove(KEY contextId)
          Removes an identified component implementation instance associated with the current context from persistent storage
 void returnWrapper(InstanceWrapper wrapper, KEY contextId)
          Return a wrapper after use (for example, after invoking the instance).
 void start()
          Starts the Lifecycle.
 void startContext(KEY contextId)
          Start a new context with the supplied ID.
 void stop()
          Stops the Lifecycle.
 void stopContext(KEY contextId)
          Stop the context with the supplied ID.
 
Methods inherited from interface org.apache.tuscany.sca.event.RuntimeEventListener
onEvent
 

Field Detail

CONFIG_ERROR

static final int CONFIG_ERROR
See Also:
Constant Field Values

UNINITIALIZED

static final int UNINITIALIZED
See Also:
Constant Field Values

INITIALIZING

static final int INITIALIZING
See Also:
Constant Field Values

INITIALIZED

static final int INITIALIZED
See Also:
Constant Field Values

RUNNING

static final int RUNNING
See Also:
Constant Field Values

STOPPING

static final int STOPPING
See Also:
Constant Field Values

STOPPED

static final int STOPPED
See Also:
Constant Field Values

ERROR

static final int ERROR
See Also:
Constant Field Values
Method Detail

getScope

Scope getScope()
Returns the Scope that this container supports.

Returns:
the Scope that this container supports

startContext

void startContext(KEY contextId)
Start a new context with the supplied ID.

Parameters:
contextId - an ID that uniquely identifies the context.

stopContext

void stopContext(KEY contextId)
Stop the context with the supplied ID.

Parameters:
contextId - an ID that uniquely identifies the context.

getWrapper

InstanceWrapper getWrapper(KEY contextId)
                           throws TargetResolutionException
Returns an instance wrapper associated with the current scope context, creating one if necessary

Parameters:
contextId - the id for the scope context
Returns:
the wrapper for the target instance
Throws:
TargetResolutionException - if there was a problem instantiating the target instance

addWrapperReference

void addWrapperReference(KEY existingContextId,
                         KEY newContextId)
                         throws TargetResolutionException
Allows a component to be registered against more than one context id. This is required in the case of stateful callbacks where we want to identify the originating client component instance as the callback target but we don't want to reuse the clients original conversation id

Parameters:
existingContextId - an id that identifies an existing component instance
newContextId - a new id against which this component will also be registered
Throws:
TargetResolutionException

registerWrapper

void registerWrapper(InstanceWrapper wrapper,
                     KEY contextId)
                     throws TargetResolutionException
Register an existing instance against a context id. This is needed for a stateful callback where the service reference for the forward call contains a callback object that is not a service reference.

Parameters:
wrapper - the instance wrapper for the instance to be registered
contextId - the id for the scope context
Throws:
TargetResolutionException

getAssociatedWrapper

InstanceWrapper getAssociatedWrapper(KEY contextId)
                                     throws TargetResolutionException
Returns an implementation instance associated with the current scope context. If no instance is found, a TargetNotFoundException is thrown.

Parameters:
contextId - the id for the scope context
Returns:
the wrapper for the target instance
Throws:
TargetResolutionException - if there was a problem instantiating the target instance

returnWrapper

void returnWrapper(InstanceWrapper wrapper,
                   KEY contextId)
                   throws TargetDestructionException
Return a wrapper after use (for example, after invoking the instance).

Parameters:
wrapper - the wrapper for the target instance being returned
contextId - the id for the scope context
Throws:
TargetDestructionException - if there was a problem returning the target instance

remove

void remove(KEY contextId)
            throws TargetDestructionException
Removes an identified component implementation instance associated with the current context from persistent storage

Parameters:
contextId - the identifier of the context to remove.
Throws:
TargetDestructionException

getLifecycleState

int getLifecycleState()
Returns the lifecycle state

See Also:
UNINITIALIZED, INITIALIZING, INITIALIZED, RUNNING, STOPPING, STOPPED

start

void start()
Starts the Lifecycle.


stop

void stop()
Stops the Lifecycle.