com.uwyn.rife.continuations
Class ContinuationContext<T extends ContinuableObject>

java.lang.Object
  extended by com.uwyn.rife.continuations.ContinuationContext<T>
All Implemented Interfaces:
Cloneable

public class ContinuationContext<T extends ContinuableObject>
extends Object
implements Cloneable

Contains all contextual data of one particular continuation.

It also provides some static retrieval methods to be able to access active continuations.

Active continuations are managed in a ContinuationManager so that they can be easily retrieved.

Since:
1.6
Version:
$Revision: 3813 $
Author:
Geert Bevin (gbevin[remove] at uwyn dot com)
See Also:
ContinuationManager

Method Summary
 void addRelatedId(String id)
          [PRIVATE AND UNSUPPORTED] Associates the ID of another continuation to this continuation.
static void clearActiveContext()
          Clears the active currently continuation context for the executing thread.
 ContinuationContext clone()
          [PRIVATE AND UNSUPPORTED] Creates a cloned instance of this continuation context, this clone is not a perfect copy but is intended to be a child continuation and all context data is setup for that.
static ContinuationContext createOrResetContext(Object executingInstance)
          [PRIVATE AND UNSUPPORTED] Creates a new continuation context or resets its expiration time.
 void deactivate()
          Makes sure that this ContinuationContext is not the active one.
 CallState getActiveCallState()
          Retrieves the call state that is active during this continuation.
static ContinuationContext getActiveContext()
          Retrieves the currently active continuation for the executing thread.
static String getActiveContextId()
          Retrieves the identifier of the currently active continuation for the current thread.
 Object getCallAnswer()
          Retrieves the answer that the call continuation stored in this context.
 T getContinuable()
          Returns the object instance in which this continuation was executing.
 CallState getCreatedCallState()
          Retrieves this continuation's call continuation creation state.
 String getId()
          Retrieves the continuation ID.
 int getLabel()
          [PRIVATE AND UNSUPPORTED] Retrieves the number of the bytecode label where the continuation has to resume execution from.
static ContinuationContext getLastContext()
          Retrieves the last active continuation for the executing thread.
 ContinuationStack getLocalStack()
          [PRIVATE AND UNSUPPORTED] Retrieves the local operand stack of this continuation.
 ContinuationStack getLocalVars()
          [PRIVATE AND UNSUPPORTED] Retrieves the local variable stack of this continuation.
 ContinuationManager getManager()
          Retrieves the manager of this ContinuationContext.
 ContinuationContext getParentContext()
          Retrieves the parent ContinuationContext of this ContinuationContext instance.
 String getParentContextId()
          Retrieves the unique identifier of the parent continuation of this ContinuationContext instance.
 String getParentId()
          Retrieves the ID of this continuation's parent.
 boolean isPaused()
          Indicates whether this continuation is actually paused and can be resumed.
 void registerContext()
          Registers this continuation in its manager, so that it can be retrieved later.
 void remove()
          Removes this ContinuationContext instance from its ContinuationManager.
 void removeContextTree()
          Removes the entire continuation tree that this ContinuationContext instance belongs to from its ContinuationManager.
 void setActiveCallState(CallState callState)
          Sets the active call state for this continuation.
static void setActiveContext(ContinuationContext context)
          Replaces the active continuation context for the executing thread.
 void setCallAnswer(Object answer)
          Set the answer to a call continuation.
 void setCreatedCallState(CallState createdCallState)
          Sets the call continuation's state when a new call continuation is created.
 void setLabel(int label)
          [PRIVATE AND UNSUPPORTED] Set the number of the bytecode label where the continuation has to resume execution from.
 void setParentId(String id)
          [PRIVATE AND UNSUPPORTED] Set the ID of this continuation's parent.
 void setPaused(boolean paused)
          [PRIVATE AND UNSUPPORTED] Sets whether the continuation if paused.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createOrResetContext

public static ContinuationContext createOrResetContext(Object executingInstance)
[PRIVATE AND UNSUPPORTED] Creates a new continuation context or resets its expiration time.

This method is used by the instrumented bytecode that provides continuations support, it's not intended for general use.

Returns:
a new ContinuationContext, or the active one with its expiration time being reset
Since:
1.6

clearActiveContext

public static void clearActiveContext()
Clears the active currently continuation context for the executing thread.

Since:
1.6

getActiveContextId

public static String getActiveContextId()
Retrieves the identifier of the currently active continuation for the current thread.

Returns:
the identifier of the currently active continuation as a unique string; or

null if no continuation is currently active

Since:
1.6
See Also:
getActiveContext()

getActiveContext

public static ContinuationContext getActiveContext()
Retrieves the currently active continuation for the executing thread.

Returns:
the currently active continuation; or

null if no continuation is currently active

Since:
1.6
See Also:
getActiveContextId()

setActiveContext

public static void setActiveContext(ContinuationContext context)
Replaces the active continuation context for the executing thread.

Parameters:
context - the new ContinuationContext that will be active; or null if no continuation context should be active
Since:
1.6
See Also:
setActiveContext(com.uwyn.rife.continuations.ContinuationContext)

getLastContext

public static ContinuationContext getLastContext()
Retrieves the last active continuation for the executing thread.

Returns:
the last active continuation; or

null if no continuation was active

Since:
1.6

getManager

public ContinuationManager getManager()
Retrieves the manager of this ContinuationContext.

Returns:
this continuation's manager instance
Since:
1.6

registerContext

public void registerContext()
Registers this continuation in its manager, so that it can be retrieved later.

Since:
1.6

deactivate

public void deactivate()
Makes sure that this ContinuationContext is not the active one.

Since:
1.6

remove

public void remove()
Removes this ContinuationContext instance from its ContinuationManager.

Since:
1.6

removeContextTree

public void removeContextTree()
Removes the entire continuation tree that this ContinuationContext instance belongs to from its ContinuationManager.

Since:
1.6

getParentContextId

public String getParentContextId()
Retrieves the unique identifier of the parent continuation of this ContinuationContext instance.

Returns:
the parent's identifier as a unique string; or

null if this ContinuationContext has no parent

Since:
1.6
See Also:
getParentContext()

getParentContext

public ContinuationContext getParentContext()
Retrieves the parent ContinuationContext of this ContinuationContext instance.

Returns:
the parent ContinuationContext; or

null if this ContinuationContext has no parent

Since:
1.6
See Also:
getParentContextId()

getCallAnswer

public Object getCallAnswer()
Retrieves the answer that the call continuation stored in this context.

Returns:
the call continuation's answer; or

null if no answer was provided or the corresponding continuation wasn't a call continuation

Since:
1.6

setPaused

public void setPaused(boolean paused)
[PRIVATE AND UNSUPPORTED] Sets whether the continuation if paused.

This method is used by the internals that provide continuations support, it's not intended for general use.

Parameters:
paused - true if the continuation is paused; or

false otherwise

Since:
1.6
See Also:
isPaused()

isPaused

public boolean isPaused()
Indicates whether this continuation is actually paused and can be resumed.

Returns:
true if the continuation is paused; or

false otherwise

Since:
1.6

setLabel

public void setLabel(int label)
[PRIVATE AND UNSUPPORTED] Set the number of the bytecode label where the continuation has to resume execution from.

This method is used by the instrumented bytecode that provides continuations support, it's not intended for general use.

Parameters:
label - the number of the resumed bytecode label
Since:
1.6

getLabel

public int getLabel()
[PRIVATE AND UNSUPPORTED] Retrieves the number of the bytecode label where the continuation has to resume execution from.

This method is used by the instrumented bytecode that provides continuations support, it's not intended for general use.

Returns:
the number of the resumed bytecode label; or

-1 if no label number has been set

Since:
1.6

getLocalVars

public ContinuationStack getLocalVars()
[PRIVATE AND UNSUPPORTED] Retrieves the local variable stack of this continuation.

This method is used by the instrumented bytecode that provides continuations support, it's not intended for general use.

Returns:
this continuation's local variable stack
Since:
1.6

getLocalStack

public ContinuationStack getLocalStack()
[PRIVATE AND UNSUPPORTED] Retrieves the local operand stack of this continuation.

This method is used by the instrumented bytecode that provides continuations support, it's not intended for general use.

Returns:
this continuation's local operand stack
Since:
1.6

getId

public String getId()
Retrieves the continuation ID.

Note that this ID is not necessarily present in the manager and that trying to retrieve a continuation afterwards from its ID is never guaranteed to give a result.

Returns:
the unique ID of this continuation.
Since:
1.6

getParentId

public String getParentId()
Retrieves the ID of this continuation's parent.

Returns:
the ID of this continuation's parent continuation; or

null if this continuation has no parent.

Since:
1.6

addRelatedId

public void addRelatedId(String id)
[PRIVATE AND UNSUPPORTED] Associates the ID of another continuation to this continuation.

This method is used by the instrumented bytecode that provides continuations support, it's not intended for general use.

Parameters:
id - the ID of another continuation that's related to this continuation
Since:
1.6

setParentId

public void setParentId(String id)
[PRIVATE AND UNSUPPORTED] Set the ID of this continuation's parent.

This method is used by the instrumented bytecode that provides continuations support, it's not intended for general use.

Parameters:
id - the ID of this continuation's parent
Since:
1.6
See Also:
getParentId()

getContinuable

public T getContinuable()
Returns the object instance in which this continuation was executing.

Returns:
this continuation's active object
Since:
1.6

setCreatedCallState

public void setCreatedCallState(CallState createdCallState)
Sets the call continuation's state when a new call continuation is created.

This state initiates a call continuation and should be set when a new call happens, after that it should never be changed.

Parameters:
createdCallState - this call continuation's creation state
Since:
1.6
See Also:
getCreatedCallState()

getCreatedCallState

public CallState getCreatedCallState()
Retrieves this continuation's call continuation creation state.

If this returns a non-null value, you can detect from it that this was a call continuation.

Returns:
this continuation
Since:
1.6
See Also:
setCreatedCallState(CallState)

setActiveCallState

public void setActiveCallState(CallState callState)
Sets the active call state for this continuation.

This mainly passes on the call state that was created during a call continuation. It allows quick retrieval of the active call state when an answer occurs.

Parameters:
callState - the active call state
Since:
1.6
See Also:
setCreatedCallState(CallState)

getActiveCallState

public CallState getActiveCallState()
Retrieves the call state that is active during this continuation.

Returns:
the active CallState; or

null if no call state was active for this continuation


setCallAnswer

public void setCallAnswer(Object answer)
Set the answer to a call continuation.

Parameters:
answer - the object that will be the call continuation's answer; or null if there was no answer
Since:
1.6

clone

public ContinuationContext clone()
                          throws CloneNotSupportedException
[PRIVATE AND UNSUPPORTED] Creates a cloned instance of this continuation context, this clone is not a perfect copy but is intended to be a child continuation and all context data is setup for that.

This method is used by the instrumented bytecode that provides continuations support, it's not intended for general use.

Overrides:
clone in class Object
Returns:
a clone of this continuation for use as a child continuation
Throws:
CloneNotSupportedException
Since:
1.6


Copyright © 2001-2007 Uwyn sprl/bvba. All Rights Reserved.