TPTP 4.2.0 Platform Project
Public API Specification

org.eclipse.hyades.collection.correlation
Class BaseApplicationImpl

java.lang.Object
  extended byorg.eclipse.hyades.collection.correlation.BaseApplicationImpl
All Implemented Interfaces:
IApplication
Direct Known Subclasses:
IiopProfiler, ServiceRegistryTester

public abstract class BaseApplicationImpl
extends java.lang.Object
implements IApplication

This is the base application implementation with the basic correlator management funcitons in place.


Field Summary
protected  IContextHandler handler
           
 
Constructor Summary
BaseApplicationImpl()
           
 
Method Summary
protected  CorrelatorAssociation createCorrelatorAssociation()
          Creates a correlator association either by drawing an existing instance from the association pool, or by instantiating a new instance.
 ICorrelatorData createCorrelatorData()
          Creates an initialized copy of ICorrelatorData.
protected  CorrelatorStack createCorrelatorStack(java.util.Comparator key)
          Creates a new stack for this key, and adds it to the existing collection of correlator stacks.
 void deregisterHandler()
          Deregisters any current event handler.
protected  void destroyCorrelatorStack(java.util.Comparator key)
          Removes the stack for this key from the collection of correlator stacks.
protected  CorrelatorStack findCorrelatorStack(java.util.Comparator key)
          Tries to locate the correlator stack for this key.
 ICorrelatorData getActiveCorrelatorByKey(java.util.Comparator key)
          Returns the most recent correlator for this key in this application.
 CorrelatorAssociation handleCall(java.util.Comparator key)
          Is exactly the same as handleCall(key, null).
 CorrelatorAssociation handleCall(java.util.Comparator key, ICorrelatorData parent)
          Creates and handles the call context by forwarding the current active correlator data for the key to the destination of a remote invocation.
 CorrelatorAssociation handleReturn(java.util.Comparator key, ICorrelatorData parent)
          Is exactly the same as handleReturn(key, parent, null).
 CorrelatorAssociation handleReturn(java.util.Comparator key, ICorrelatorData parent, ICorrelatorData child)
          Creates and handles the return context by receiving the current active correlator data for the key from the destination of a remote invocation.
protected  long incrementCounter()
          Increments and returns the application counter, which can be used to determine the total ordering of events on a single instance of this application cross multiple threads.
 void initialize()
          Initializes this application so that it is ready to be (re-)used.
abstract  BaseCorrelatorDataImpl instantiateCorrelator()
          Instantiates a new instance of the correlator.
 CorrelatorAssociation popChild(java.util.Comparator key)
          Creates and handles the pop-child context by popping the child correlator off the correlator stack for the key.
 CorrelatorAssociation popParent(java.util.Comparator key)
          Is exactly the same as popParent(key, null).
 CorrelatorAssociation popParent(java.util.Comparator key, ICorrelatorData parent)
          Creates and handles the pop-parent context by popping the parent correlator off the correlator stack for the key.
 CorrelatorAssociation pushChild(java.util.Comparator key, ICorrelatorData child)
          Creates and handles the push-child context by pushing the child correlator onto the correlator stack for the key.
 CorrelatorAssociation pushParent(java.util.Comparator key, ICorrelatorData parent)
          Is exactly the same as pushParent(key, parent, null).
 CorrelatorAssociation pushParent(java.util.Comparator key, ICorrelatorData parent, ICorrelatorData child)
          Creates and handles the push-parent context by pushing the parent correlator onto the correlator stack for the key.
 void registerHandler(IContextHandler handler)
          Registers a context event handler with the application, so that all later events are handled through this handler.
 void releaseAssociation(CorrelatorAssociation association)
          Releases an application-specific correlator association for later re-use.
 void returnCorrelatorData(ICorrelatorData correlator)
          Returns a correlator to the pool for later reuse.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.hyades.collection.correlation.IApplication
getId, getVersion
 

Field Detail

handler

protected IContextHandler handler
Constructor Detail

BaseApplicationImpl

public BaseApplicationImpl()
Method Detail

instantiateCorrelator

public abstract BaseCorrelatorDataImpl instantiateCorrelator()
Instantiates a new instance of the correlator. Sub-classes must override this method so that the correlator pool can obtain new correlators when correlators are needed and the pool is empty.

Returns:
a newly-created instance of the correlator.

initialize

public void initialize()
Description copied from interface: IApplication
Initializes this application so that it is ready to be (re-)used.

Specified by:
initialize in interface IApplication
See Also:
IApplication.initialize()

createCorrelatorData

public ICorrelatorData createCorrelatorData()
Description copied from interface: IApplication
Creates an initialized copy of ICorrelatorData.

Specified by:
createCorrelatorData in interface IApplication
Returns:
a fresh copy of the application-specific correlator.
See Also:
IApplication.createCorrelatorData()

returnCorrelatorData

public void returnCorrelatorData(ICorrelatorData correlator)
Returns a correlator to the pool for later reuse.

Parameters:
correlator - the correlator to be returned

createCorrelatorAssociation

protected CorrelatorAssociation createCorrelatorAssociation()
Creates a correlator association either by drawing an existing instance from the association pool, or by instantiating a new instance.

Returns:
an instance of correlator association.

handleCall

public CorrelatorAssociation handleCall(java.util.Comparator key,
                                        ICorrelatorData parent)
Description copied from interface: IApplication
Creates and handles the call context by forwarding the current active correlator data for the key to the destination of a remote invocation. This context occurs before a remote invocation request is sent, and should be followed by a later return context handled by IApplication.handleReturn(Comparator, ICorrelatorData). The context handler should be IContextHandler.handleSend(CorrelatorAssociation). This API is created in attempt to pass more information to the engine so that a richer set of contexts can be handled.

Specified by:
handleCall in interface IApplication
Parameters:
key - the key to the context to be created
parent - the parent of the context representing the local context
Returns:
the context created.
See Also:
IApplication.handleCall(Comparator, ICorrelatorData)

handleCall

public CorrelatorAssociation handleCall(java.util.Comparator key)
Description copied from interface: IApplication
Is exactly the same as handleCall(key, null).

Specified by:
handleCall in interface IApplication
Parameters:
key - the key to the context to be created
Returns:
the context created.
See Also:
IApplication.handleCall(Comparator)

handleReturn

public CorrelatorAssociation handleReturn(java.util.Comparator key,
                                          ICorrelatorData parent,
                                          ICorrelatorData child)
Description copied from interface: IApplication
Creates and handles the return context by receiving the current active correlator data for the key from the destination of a remote invocation. This context occurs after a remote invocation reply is received, and should be following an earlier call context handled by #handleCall(Comparator, ICorrelator). The context handler should be IContextHandler.handleReturn(CorrelatorAssociation). This API is created in attempt to pass more information to the engine so that a richer set of contexts can be handled.

Specified by:
handleReturn in interface IApplication
Parameters:
key - the key to the context to be created
parent - the updated correlator data for the parent from the destination
child - the correlator data for the child
Returns:
the context created.
See Also:
IApplication.handleReturn(Comparator, ICorrelatorData, ICorrelatorData)

handleReturn

public CorrelatorAssociation handleReturn(java.util.Comparator key,
                                          ICorrelatorData parent)
Description copied from interface: IApplication
Is exactly the same as handleReturn(key, parent, null).

Specified by:
handleReturn in interface IApplication
Parameters:
key - the key to the context to be created
parent - the updated correlator data for the parent from the destination
Returns:
the context created.
See Also:
IApplication.handleReturn(Comparator, ICorrelatorData)

pushChild

public CorrelatorAssociation pushChild(java.util.Comparator key,
                                       ICorrelatorData child)
Description copied from interface: IApplication
Creates and handles the push-child context by pushing the child correlator onto the correlator stack for the key. This context occurs before a local inocation takes place, and should be followed by a later pop-child context handled by IApplication.popChild(Comparator). The context handler is IContextHandler.handleEntry(CorrelatorAssociation).

Specified by:
pushChild in interface IApplication
Parameters:
key - the key to the context stack
child - the correlator data for the child
Returns:
the context created.
See Also:
IApplication.pushChild(Comparator, ICorrelatorData)

popChild

public CorrelatorAssociation popChild(java.util.Comparator key)
Description copied from interface: IApplication
Creates and handles the pop-child context by popping the child correlator off the correlator stack for the key. This context occurs after a local inocation has finished, and should be following an earlier push-child context handled by IApplication.pushChild(Comparator, ICorrelatorData). The context handler is IContextHandler.handleExit(CorrelatorAssociation).

Specified by:
popChild in interface IApplication
Parameters:
key - the key to the context stack
Returns:
the context created.
See Also:
IApplication.popChild(Comparator)

pushParent

public CorrelatorAssociation pushParent(java.util.Comparator key,
                                        ICorrelatorData parent,
                                        ICorrelatorData child)
Description copied from interface: IApplication
Creates and handles the push-parent context by pushing the parent correlator onto the correlator stack for the key. This context occurs after a remote request is received at the server but before the actual local inocation takes place, and should be followed by a later pop-parent context handled by IApplication.popParent(Comparator). The context handler is IContextHandler.handleReceive(CorrelatorAssociation). This API is created in attempt to pass more information to the engine so that a richer set of contexts can be handled.

Specified by:
pushParent in interface IApplication
Parameters:
key - the key to the context stack
parent - the correlator data for the parent
child - the correlator data for the child
Returns:
the context created.
See Also:
IApplication.pushParent(Comparator, ICorrelatorData, ICorrelatorData)

pushParent

public CorrelatorAssociation pushParent(java.util.Comparator key,
                                        ICorrelatorData parent)
Description copied from interface: IApplication
Is exactly the same as pushParent(key, parent, null).

Specified by:
pushParent in interface IApplication
Parameters:
key - the key to the context stack
parent - the correlator data for the parent
Returns:
the context created.
See Also:
IApplication.pushParent(Comparator, ICorrelatorData)

popParent

public CorrelatorAssociation popParent(java.util.Comparator key,
                                       ICorrelatorData parent)
Description copied from interface: IApplication
Creates and handles the pop-parent context by popping the parent correlator off the correlator stack for the key. This context occurs after the local invocation has finished but before the reply is sent to the client, and should be following an earlier push-parent context handled by IApplication.pushParent(Comparator, ICorrelatorData). The context handler is IContextHandler.handleReply(CorrelatorAssociation). This API is created in attempt to pass more information to the engine so that a richer set of contexts can be handled.

Specified by:
popParent in interface IApplication
Parameters:
key - the key to the context stack
parent - the correlator data for the parent
Returns:
the context created.
See Also:
IApplication.popParent(Comparator, ICorrelatorData)

popParent

public CorrelatorAssociation popParent(java.util.Comparator key)
Description copied from interface: IApplication
Is exactly the same as popParent(key, null).

Specified by:
popParent in interface IApplication
Parameters:
key - the key to the context stack
Returns:
the context created.
See Also:
IApplication.popParent(Comparator)

incrementCounter

protected long incrementCounter()
Increments and returns the application counter, which can be used to determine the total ordering of events on a single instance of this application cross multiple threads. Since this counter can be shared by multiple threads, it must be synchronized.

Returns:
the current application counter, plus 1.

getActiveCorrelatorByKey

public ICorrelatorData getActiveCorrelatorByKey(java.util.Comparator key)
Description copied from interface: IApplication
Returns the most recent correlator for this key in this application. If there is no correlator data for the key, a null pointer will be returned.

Specified by:
getActiveCorrelatorByKey in interface IApplication
Parameters:
key - the key for which the most recent correlator data in this application is to be located
Returns:
the most recent correlator data for this key in this application, or null if no such data exists.
See Also:
IApplication.getActiveCorrelatorByKey(Comparator)

createCorrelatorStack

protected CorrelatorStack createCorrelatorStack(java.util.Comparator key)
Creates a new stack for this key, and adds it to the existing collection of correlator stacks. It is the responsibility of the caller of this method to ensue that there is no stack already created for this key.

Returns:
a newly-created correlator stack.

destroyCorrelatorStack

protected void destroyCorrelatorStack(java.util.Comparator key)
Removes the stack for this key from the collection of correlator stacks. If there is no match, nothing is done to the collection.


findCorrelatorStack

protected CorrelatorStack findCorrelatorStack(java.util.Comparator key)
Tries to locate the correlator stack for this key.

Parameters:
key - the key for the target correlator stack
Returns:
the correlator stack for this key, or null if none is found.

releaseAssociation

public void releaseAssociation(CorrelatorAssociation association)
Description copied from interface: IApplication
Releases an application-specific correlator association for later re-use. This method does not release any correlators themselves automatically, and applications must therefore release these correlators manually.

Specified by:
releaseAssociation in interface IApplication
Parameters:
association - a valid application-specific context
See Also:
IApplication.releaseAssociation(CorrelatorAssociation)

registerHandler

public void registerHandler(IContextHandler handler)
Registers a context event handler with the application, so that all later events are handled through this handler.

Parameters:
handler - a context event handler

deregisterHandler

public void deregisterHandler()
Deregisters any current event handler.


TPTP 4.2.0 Platform Project
Public API Specification