org.apache.tuscany.sca.core.scope
Class ConversationalScopeContainer

java.lang.Object
  extended by org.apache.tuscany.sca.core.scope.AbstractScopeContainer<java.lang.Object>
      extended by org.apache.tuscany.sca.core.scope.ConversationalScopeContainer
All Implemented Interfaces:
java.util.EventListener, ConversationListener, ScopeContainer<java.lang.Object>, RuntimeEventListener

public class ConversationalScopeContainer
extends AbstractScopeContainer<java.lang.Object>
implements ConversationListener

A scope context which manages atomic component instances keyed on ConversationID


Field Summary
 
Fields inherited from class org.apache.tuscany.sca.core.scope.AbstractScopeContainer
component, lifecycleState, scope, wrappers
 
Fields inherited from interface org.apache.tuscany.sca.core.scope.ScopeContainer
CONFIG_ERROR, ERROR, INITIALIZED, INITIALIZING, RUNNING, STOPPED, STOPPING, UNINITIALIZED
 
Constructor Summary
ConversationalScopeContainer(Store aStore, RuntimeComponent component)
           
 
Method Summary
 void addWrapperReference(java.lang.Object existingContextId, java.lang.Object contextId)
          This method allows a new context id to be registered alongside an existing one.
 void conversationEnded(ExtendedConversation conversation)
          The conversation is ended
 void conversationExpired(ExtendedConversation conversation)
          The conversation is expired
 void conversationStarted(ExtendedConversation conversation)
          The conversation is started
 ConversationManager getConversationManager()
           
protected  InstanceWrapper getInstanceWrapper(boolean create, java.lang.Object contextId)
           
 InstanceWrapper getWrapper(java.lang.Object contextId)
          Returns an instance wrapper associated with the current scope context, creating one if necessary
 void registerWrapper(InstanceWrapper wrapper, java.lang.Object contextId)
          Register an existing instance against a context id.
 void remove(java.lang.Object contextId)
          Default implementation of remove which does nothing
 void setConversationManager(ConversationManager conversationManager)
           
 
Methods inherited from class org.apache.tuscany.sca.core.scope.AbstractScopeContainer
checkInit, createInstanceWrapper, getAssociatedWrapper, getComponent, getLifecycleState, getScope, isEagerInit, onEvent, returnWrapper, setComponent, setLifecycleState, start, startContext, stop, stopContext, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConversationalScopeContainer

public ConversationalScopeContainer(Store aStore,
                                    RuntimeComponent component)
Method Detail

getInstanceWrapper

protected InstanceWrapper getInstanceWrapper(boolean create,
                                             java.lang.Object contextId)
                                      throws TargetResolutionException
Throws:
TargetResolutionException

getWrapper

public InstanceWrapper getWrapper(java.lang.Object contextId)
                           throws TargetResolutionException
Description copied from interface: ScopeContainer
Returns an instance wrapper associated with the current scope context, creating one if necessary

Specified by:
getWrapper in interface ScopeContainer<java.lang.Object>
Overrides:
getWrapper in class AbstractScopeContainer<java.lang.Object>
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

public void addWrapperReference(java.lang.Object existingContextId,
                                java.lang.Object contextId)
                         throws TargetResolutionException
This method allows a new context id to be registered alongside an existing one. This happens in one case, when a conversation includes a stateful callback. The client component instance must be registered against all outgoing conversation ids so that the component instance can be found when the callback arrives

Specified by:
addWrapperReference in interface ScopeContainer<java.lang.Object>
Overrides:
addWrapperReference in class AbstractScopeContainer<java.lang.Object>
Parameters:
existingContextId - the context id against which the component is already registered
context - this should be a conversation object so that the conversation can b stored and reset when the component instance is removed
Throws:
TargetResolutionException

registerWrapper

public void registerWrapper(InstanceWrapper wrapper,
                            java.lang.Object contextId)
                     throws TargetResolutionException
Description copied from interface: ScopeContainer
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.

Specified by:
registerWrapper in interface ScopeContainer<java.lang.Object>
Overrides:
registerWrapper in class AbstractScopeContainer<java.lang.Object>
Parameters:
wrapper - the instance wrapper for the instance to be registered
contextId - the id for the scope context
Throws:
TargetResolutionException

remove

public void remove(java.lang.Object contextId)
            throws TargetDestructionException
Description copied from class: AbstractScopeContainer
Default implementation of remove which does nothing

Specified by:
remove in interface ScopeContainer<java.lang.Object>
Overrides:
remove in class AbstractScopeContainer<java.lang.Object>
Parameters:
contextId - the identifier of the context to remove.
Throws:
TargetDestructionException

conversationEnded

public void conversationEnded(ExtendedConversation conversation)
Description copied from interface: ConversationListener
The conversation is ended

Specified by:
conversationEnded in interface ConversationListener
See Also:
ConversationListener.conversationEnded(org.apache.tuscany.sca.core.conversation.ExtendedConversation)

conversationExpired

public void conversationExpired(ExtendedConversation conversation)
Description copied from interface: ConversationListener
The conversation is expired

Specified by:
conversationExpired in interface ConversationListener
See Also:
ConversationListener.conversationExpired(org.apache.tuscany.sca.core.conversation.ExtendedConversation)

conversationStarted

public void conversationStarted(ExtendedConversation conversation)
Description copied from interface: ConversationListener
The conversation is started

Specified by:
conversationStarted in interface ConversationListener
See Also:
ConversationListener.conversationStarted(org.apache.tuscany.sca.core.conversation.ExtendedConversation)

getConversationManager

public ConversationManager getConversationManager()
Returns:
the conversationManager

setConversationManager

public void setConversationManager(ConversationManager conversationManager)
Parameters:
conversationManager - the conversationManager to set