com.uwyn.rife.continuations.basic
Class BasicContinuableRunner

java.lang.Object
  extended by com.uwyn.rife.continuations.basic.BasicContinuableRunner

public class BasicContinuableRunner
extends Object

Basic implementation of a 'continuable runner' that will execute the continuable objects and correctly handle the continuations-related exceptions that are triggered.

This runner is probably only applicable to the most simple of use-cases, but by reading its source it should be relatively easy to adapt of extend it for purposes that don't fall inside its scope.

Since:
1.6
Version:
$Revision: 3850 $
Author:
Geert Bevin (gbevin[remove] at uwyn dot com)

Constructor Summary
BasicContinuableRunner(ContinuationConfigInstrument configInstrument)
          Create a new runner instance.
BasicContinuableRunner(ContinuationConfigInstrument configInstrument, ClassLoader classloader)
          Create a new runner instance with a custom classloader.
 
Method Summary
 String answer(String continuationId, Object callAnswer)
          Resumes the execution of a call continuation.
 void beforeExecuteEntryMethodHook(ContinuableObject object)
          Hook method that will be executed right before executing the entry method of a continuable object, when the default implementation of executeContinuable(com.uwyn.rife.continuations.ContinuableObject) is used.
 BasicContinuableRunner callTargetRetriever(CallTargetRetriever callTargetRetriever)
          Sets the call target retriever that will be used when a call continuation is triggered.
 BasicContinuableRunner cloneContinuations(boolean cloneContinuations)
          Configures the runner to clone continuations or not.
 void executeContinuable(ContinuableObject object)
          Executes the continuable object by looking up the entrance method and invoking it.
 CallTargetRetriever getCallTargetRetriever()
          Retrieves the call target retriever that will be used when a call continuation is triggered.
 ClassLoader getClassLoader()
          Retrieves the classloader that is used by this runner.
 boolean getCloneContinuations()
          Indicates whether continuations should be cloned when they are resumed.
 ContinuationConfigInstrument getConfigInstrumentation()
          Retrieves the instrumentation configuration that is used by this runner.
 ContinuableObject getCurrentContinuable()
          Retrieves the continuable that is active for the executing thread.
 ContinuationManager getManager()
          Retrieves the manager that is used by the continuation runner.
 String resume(String continuationId)
          Resumes the execution of a paused continuation.
 String run(String continuationId)
          Executes a continuation whether it's paused or not.
 void setCallTargetRetriever(CallTargetRetriever callTargetRetriever)
          Sets the call target retriever that will be used when a call continuation is triggered.
 void setCloneContinuations(boolean cloneContinuations)
          Configures the runner to clone continuations or not.
 String start(String className)
          Starts the execution of a new instance of the provided class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicContinuableRunner

public BasicContinuableRunner(ContinuationConfigInstrument configInstrument)
Create a new runner instance.

Parameters:
configInstrument - the instance of the instrumentation configuration that will be used for the transformation
Since:
1.6

BasicContinuableRunner

public BasicContinuableRunner(ContinuationConfigInstrument configInstrument,
                              ClassLoader classloader)
Create a new runner instance with a custom classloader.

Parameters:
configInstrument - the instance of the instrumentation configuration that will be used for the transformation
classloader - the classloader that will be used to load the continuable classes, this is for example an instance of BasicContinuableClassLoader
Since:
1.6
Method Detail

start

public String start(String className)
             throws Throwable
Starts the execution of a new instance of the provided class.

Parameters:
className - the name of the class that will be executed
Returns:
the ID of the resulting paused continuation; or

null if no continuation was paused

Throws:
Throwable - when an error occurs
Since:
1.6

resume

public String resume(String continuationId)
              throws Throwable
Resumes the execution of a paused continuation.

Parameters:
continuationId - the ID of the continuation that will be resumed
Returns:
the ID of the resulting paused continuation; or

null if no continuation was paused or if the provided ID couldn't be found

Throws:
Throwable - when an error occurs
Since:
1.6

answer

public String answer(String continuationId,
                     Object callAnswer)
              throws Throwable
Resumes the execution of a call continuation.

Parameters:
continuationId - the ID of the continuation that will be resumed
callAnswer - the call answer object
Returns:
the ID of the resulting paused continuation; or

null if no continuation was paused or if the provided ID couldn't be found

Throws:
Throwable - when an error occurs
Since:
1.6.1

run

public String run(String continuationId)
           throws Throwable
Executes a continuation whether it's paused or not. This is supposed to only be used for answer continuations.

Parameters:
continuationId - the ID of the existing continuation context that will be executed
Returns:
the ID of the resulting paused continuation; or

null if no continuation was paused or if the provided ID couldn't be found

Throws:
Throwable - when an error occurs
Since:
1.6

executeContinuable

public void executeContinuable(ContinuableObject object)
                        throws Throwable
Executes the continuable object by looking up the entrance method and invoking it.

This method can be overridden in case the default behavior isn't approriate.

Parameters:
object - the continuatioble that will be executed
Throws:
Throwable - when an unexpected error occurs
Since:
1.6.1

beforeExecuteEntryMethodHook

public void beforeExecuteEntryMethodHook(ContinuableObject object)
Hook method that will be executed right before executing the entry method of a continuable object, when the default implementation of executeContinuable(com.uwyn.rife.continuations.ContinuableObject) is used.

This can for example be used to inject a continuable support object in case the main continuable class only implements the marker interface without having any of the support methods (see ContinuationConfigInstrument.getContinuableSupportClassName()).

Parameters:
object - the continuable object that will be executed
Since:
1.6
See Also:
executeContinuable(com.uwyn.rife.continuations.ContinuableObject)

getConfigInstrumentation

public ContinuationConfigInstrument getConfigInstrumentation()
Retrieves the instrumentation configuration that is used by this runner.

Returns:
this runner's instrumentation configuration
Since:
1.6

getClassLoader

public ClassLoader getClassLoader()
Retrieves the classloader that is used by this runner.

Returns:
this runner's classloader
Since:
1.6

cloneContinuations

public BasicContinuableRunner cloneContinuations(boolean cloneContinuations)
Configures the runner to clone continuations or not.

Parameters:
cloneContinuations - true if continuations should be cloned when they are resumed; or

false if they should not be cloned

Returns:
this runner instance
Since:
1.6
See Also:
setCloneContinuations(boolean), getCloneContinuations()

setCloneContinuations

public void setCloneContinuations(boolean cloneContinuations)
Configures the runner to clone continuations or not.

Parameters:
cloneContinuations - true if continuations should be cloned when they are resumed; or

false if they should not be cloned

Since:
1.6
See Also:
cloneContinuations(boolean), getCloneContinuations()

getCloneContinuations

public boolean getCloneContinuations()
Indicates whether continuations should be cloned when they are resumed.

Returns:
true if continuations should be cloned when they are resumed; or

false if they should not be cloned

Since:
1.6
See Also:
cloneContinuations(boolean), setCloneContinuations(boolean)

callTargetRetriever

public BasicContinuableRunner callTargetRetriever(CallTargetRetriever callTargetRetriever)
Sets the call target retriever that will be used when a call continuation is triggered.

Parameters:
callTargetRetriever - the call target retriever that will be used
Returns:
this runner instance
Since:
1.6
See Also:
setCallTargetRetriever(com.uwyn.rife.continuations.basic.CallTargetRetriever), getCallTargetRetriever()

setCallTargetRetriever

public void setCallTargetRetriever(CallTargetRetriever callTargetRetriever)
Sets the call target retriever that will be used when a call continuation is triggered.

Parameters:
callTargetRetriever - the call target retriever that will be used
Since:
1.6
See Also:
callTargetRetriever(com.uwyn.rife.continuations.basic.CallTargetRetriever), getCallTargetRetriever()

getCallTargetRetriever

public CallTargetRetriever getCallTargetRetriever()
Retrieves the call target retriever that will be used when a call continuation is triggered.

Returns:
this runner's call target retriever
Since:
1.6
See Also:
callTargetRetriever(com.uwyn.rife.continuations.basic.CallTargetRetriever), setCallTargetRetriever(com.uwyn.rife.continuations.basic.CallTargetRetriever)

getCurrentContinuable

public ContinuableObject getCurrentContinuable()
Retrieves the continuable that is active for the executing thread.

Returns:
this thread's continuable; or

null if there's no current continuable

Since:
1.6

getManager

public ContinuationManager getManager()
Retrieves the manager that is used by the continuation runner.

Returns:
this runner's continuation manager
Since:
1.6


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