Class BasicContinuableRunner
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.0
-
Constructor Summary
ConstructorDescriptionBasicContinuableRunner
(ContinuationConfigInstrument configInstrument, Class[] entryMethodArgumentTypes) Create a new runner instance.BasicContinuableRunner
(ContinuationConfigInstrument configInstrument, Class[] entryMethodArgumentTypes, ClassLoader classloader) Create a new runner instance with a custom classloader. -
Method Summary
Modifier and TypeMethodDescriptionResumes the execution of a call continuation.void
beforeExecuteEntryMethodHook
(Object object) Hook method that will be executed right before executing the entry method of a continuable object, when the default implementation ofexecuteContinuable(java.lang.Object)
is used.callTargetRetriever
(CallTargetRetriever callTargetRetriever) Sets the call target retriever that will be used when a call continuation is triggered.cloneContinuations
(boolean cloneContinuations) Configures the runner to clone continuations or not.void
executeContinuable
(Object object) Executes the continuable object by looking up the entrance method and invoking it.Retrieves the call target retriever that will be used when a call continuation is triggered.Retrieves the classloader that is used by this runner.boolean
Indicates whether continuations should be cloned when they are resumed.Retrieves the instrumentation configuration that is used by this runner.Retrieves the continuable that is active for the executing thread.Class[]
Retrieves the entry method argument types.Retrieves the manager that is used by the continuation runner.Resumes the execution of a paused continuation.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.Starts the execution of a new instance of the provided class.Starts the execution of a new instance of a continuable.Starts the execution of a new instance of the provided class.
-
Constructor Details
-
BasicContinuableRunner
public BasicContinuableRunner(ContinuationConfigInstrument configInstrument, Class[] entryMethodArgumentTypes) Create a new runner instance.- Parameters:
configInstrument
- the instance of the instrumentation configuration that will be used for the transformationentryMethodArgumentTypes
- the array argument types that the entry method takes, for instancenull
if it takes none.- Since:
- 1.0
-
BasicContinuableRunner
public BasicContinuableRunner(ContinuationConfigInstrument configInstrument, Class[] entryMethodArgumentTypes, 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 transformationentryMethodArgumentTypes
- the array argument types that the entry method takes, for instancenull
if it takes none.classloader
- the classloader that will be used to load the continuable classes, this is for example an instance ofBasicContinuableClassLoader
- Since:
- 1.0
-
-
Method Details
-
start
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.0
-
start
Starts the execution of a new instance of the provided class.- Parameters:
klass
- 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.0
-
start
Starts the execution of a new instance of a continuable.- Parameters:
continuable
- the instance 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.0
-
resume
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.0
-
answer
Resumes the execution of a call continuation.- Parameters:
continuationId
- the ID of the continuation that will be resumedcallAnswer
- 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.0
-
run
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.0
-
executeContinuable
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 appropriate.
- Parameters:
object
- the continuable that will be executed- Throws:
Throwable
- when an unexpected error occurs- Since:
- 1.0
-
beforeExecuteEntryMethodHook
Hook method that will be executed right before executing the entry method of a continuable object, when the default implementation ofexecuteContinuable(java.lang.Object)
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.0
- See Also:
-
getConfigInstrumentation
Retrieves the instrumentation configuration that is used by this runner.- Returns:
- this runner's instrumentation configuration
- Since:
- 1.0
-
getEntryMethodArgumentTypes
Retrieves the entry method argument types.- Returns:
- the argument types that are used by the continuations entry method
- Since:
- 1.2
-
getClassLoader
Retrieves the classloader that is used by this runner.- Returns:
- this runner's classloader
- Since:
- 1.0
-
cloneContinuations
Configures the runner to clone continuations or not.- Parameters:
cloneContinuations
-true
if continuations should be cloned when they are resumed; orfalse
if they should not be cloned- Returns:
- this runner instance
- Since:
- 1.0
- See Also:
-
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; orfalse
if they should not be cloned- Since:
- 1.0
- See Also:
-
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; orfalse
if they should not be cloned- Since:
- 1.0
- See Also:
-
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.0
- See Also:
-
setCallTargetRetriever
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.0
- See Also:
-
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.0
- See Also:
-
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.0
-
getManager
Retrieves the manager that is used by the continuation runner.- Returns:
- this runner's continuation manager
- Since:
- 1.0
-