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

java.lang.Object
  extended by com.uwyn.rife.continuations.ContinuationConfigRuntime<T>
Direct Known Subclasses:
EngineContinuationConfigRuntime

public abstract class ContinuationConfigRuntime<T extends ContinuableObject>
extends Object

Configures the runtime behavior of the continuations engine.

The active runtime configuration always has to be available through getActiveConfigRuntime() when a ContinuableObject is executed. Therefore, it's best to always call setActiveConfigRuntime(com.uwyn.rife.continuations.ContinuationConfigRuntime) before the executing. The BasicContinuableRunner does this by default. If you create your own runner, you have to ensure that this is respected.

By default the lifetime duration and purging of ContinuableObject instances is set to a sensible default, so this only needs tuning in specific case.

This class has to be extended though to provide information that suits your continuations usage and to indicate whether continuations should be cloned when they are resumed.

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

Field Summary
static long DEFAULT_CONTINUATION_DURATION
          The default duration is 20 minutes.
static int DEFAULT_CONTINUATION_PURGE_FREQUENCY
          The default frequency is every 20 times out of the scale, with the default scale of 1000 this means, 1/50th of the time.
static int DEFAULT_CONTINUATION_PURGE_SCALE
          The default purge scale is 1000.
 
Constructor Summary
ContinuationConfigRuntime()
           
 
Method Summary
abstract  boolean cloneContinuations(T executingContinuable)
          Indicates whether a continuable should be cloned before resuming the execution.
static ContinuationConfigRuntime getActiveConfigRuntime()
          Retrieves the active runtime configuration for the executing thread.
abstract  T getAssociatedContinuableObject(Object executingInstance)
          Retrieves the ContinuableObject that corresponds to the currently executing object instance.
 long getContinuationDuration()
          The duration, in milliseconds, by which a continuation stays valid.
abstract  ContinuationManager getContinuationManager(T executingContinuable)
          Retrieves the manager that is responsible for the ContinuableObject that is currently executing.
 int getContinuationPurgeFrequency()
          The frequency by which the continuations purging will run in the ContinuationManager.
 int getContinuationPurgeScale()
          The scale that will be used to determine how often continuations purging will run in the ContinuationManager.
static void setActiveConfigRuntime(ContinuationConfigRuntime config)
          Sets the active runtime configuration for the executing thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CONTINUATION_DURATION

public static final long DEFAULT_CONTINUATION_DURATION
The default duration is 20 minutes.

Since:
1.6
See Also:
Constant Field Values

DEFAULT_CONTINUATION_PURGE_FREQUENCY

public static final int DEFAULT_CONTINUATION_PURGE_FREQUENCY
The default frequency is every 20 times out of the scale, with the default scale of 1000 this means, 1/50th of the time.

Since:
1.6
See Also:
Constant Field Values

DEFAULT_CONTINUATION_PURGE_SCALE

public static final int DEFAULT_CONTINUATION_PURGE_SCALE
The default purge scale is 1000.

Since:
1.6
See Also:
Constant Field Values
Constructor Detail

ContinuationConfigRuntime

public ContinuationConfigRuntime()
Method Detail

setActiveConfigRuntime

public static void setActiveConfigRuntime(ContinuationConfigRuntime config)
Sets the active runtime configuration for the executing thread.

Parameters:
config - the active runtime configuration for the executing thread
Since:
1.6

getActiveConfigRuntime

public static ContinuationConfigRuntime getActiveConfigRuntime()
                                                        throws MissingActiveContinuationConfigRuntimeException
Retrieves the active runtime configuration for the executing thread.

Returns:
the active runtime configuration
Throws:
MissingActiveContinuationConfigRuntimeException - when the active runtime configuration isn't set
Since:
1.6

getContinuationDuration

public long getContinuationDuration()
The duration, in milliseconds, by which a continuation stays valid.

When this period is exceeded, a continuation can not be retrieved anymore and it will be removed from the manager during the next purge.

Returns:
the validity duration of a continuation in milliseconds
Since:
1.6

getContinuationPurgeFrequency

public int getContinuationPurgeFrequency()
The frequency by which the continuations purging will run in the ContinuationManager.

This works together with the scale that is configured through getContinuationPurgeScale(). The frequency divided by the scale makes how often the purging will happen. For instance, a frequency of 20 and a scale of 1000 means that purging will happen 1/50th of the time.

Returns:
the continuation purge frequency
Since:
1.6
See Also:
getContinuationPurgeScale()

getContinuationPurgeScale

public int getContinuationPurgeScale()
The scale that will be used to determine how often continuations purging will run in the ContinuationManager.

See getContinuationPurgeScale() for more info.

Returns:
the continuation purge scale
Since:
1.6
See Also:
getContinuationPurgeFrequency()

getAssociatedContinuableObject

public abstract T getAssociatedContinuableObject(Object executingInstance)
Retrieves the ContinuableObject that corresponds to the currently executing object instance.

If you don't work with a seperate continuable support class (see here) and don't allow people to just implement a marker interface without having to extend a base class, the associated continuable object is the same as the executing instance.

However, if there is a separate continuable support class, you'll need to return the appropriate continuable object here.

Parameters:
executingInstance - the currently executing object instance
Returns:
the executing ContinuableObject
Since:
1.6
See Also:
ContinuationConfigInstrument.getContinuableSupportClassName()

getContinuationManager

public abstract ContinuationManager getContinuationManager(T executingContinuable)
Retrieves the manager that is responsible for the ContinuableObject that is currently executing.

Parameters:
executingContinuable - the currently executing continuable
Returns:
the corresponding manager
Since:
1.6

cloneContinuations

public abstract boolean cloneContinuations(T executingContinuable)
Indicates whether a continuable should be cloned before resuming the execution.

Parameters:
executingContinuable - the currently executing continuable
Returns:
true is the continuation should be cloned; or

false otherwise

Since:
1.6


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