Package rife.workflow
Class Workflow
java.lang.Object
rife.workflow.Workflow
Runs work and dispatches events to work that is paused.
Note that this workflow executes the work, but doesn't create a new thread for itself. When a workflow is used, you should take the necessary steps to keep the application running for as long as you need the work to be available.
- Since:
- 1.0
- API Note:
- The workflow engine is still in an ALPHA EXPERIMENTAL STAGE and might change.
-
Constructor Summary
ConstructorDescriptionWorkflow()
Creates a new workflow instance with a cached thread pool.Workflow
(ExecutorService executor) Creates a new workflow instance with a provided executor.Workflow
(ExecutorService executor, HierarchicalProperties properties) Creates a new workflow instance.Workflow
(HierarchicalProperties properties) Creates a new workflow instance with a provided parent properties. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(EventListener listener) Adds a new event listener.void
Convenience method that informs about an event in a workflow.void
Convenience method that informs about an event in a workflow with associated data.void
Informs about an event that wakes up work if it is paused for the event type.Retrieves the hierarchical properties for this workflow instance.void
removeListener
(EventListener listener) Removes an event listener.Starts the execution of a new work instance.Starts the execution of a new work instance.void
Convenience method that triggers an event in a workflow.void
Convenience method that triggers an event in a workflow with associated data.void
Triggers an event that wakes up work that is paused for the event type.void
Causes the calling thread to wait until no more work is running.void
Causes the calling thread to wait until work is paused for events.
-
Constructor Details
-
Workflow
public Workflow()Creates a new workflow instance with a cached thread pool.- Since:
- 1.0
-
Workflow
Creates a new workflow instance with a provided executor.- Parameters:
executor
- the executor to use for running the work- Since:
- 1.0
-
Workflow
Creates a new workflow instance with a provided parent properties.- Parameters:
properties
- the parent hierarchical properties- Since:
- 1.0
-
Workflow
Creates a new workflow instance.- Parameters:
executor
- the executor to use for running the workproperties
- the parent hierarchical properties- Since:
- 1.0
-
-
Method Details
-
properties
Retrieves the hierarchical properties for this workflow instance.- Returns:
- this workflow's collection of hierarchical properties
- Since:
- 1.0
-
start
Starts the execution of a new work instance.- Parameters:
klass
- the work class whose instance that should be executed, the class should extendWork
- Since:
- 1.0
-
start
Starts the execution of a new work instance.- Parameters:
work
- the work that should be executed- Returns:
- this workflow instance
- Since:
- 1.0
-
inform
Convenience method that informs about an event in a workflow.- Parameters:
type
- the type of the event- Since:
- 1.0
- See Also:
-
inform
Convenience method that informs about an event in a workflow with associated data.- Parameters:
type
- the type of the eventdata
- the data that will be sent with the event- Since:
- 1.0
- See Also:
-
inform
Informs about an event that wakes up work if it is paused for the event type.If events are informed about and no work is ready to consume them, they will be lost. This is different from events being triggered.
- Parameters:
event
- the event- Since:
- 1.0
- See Also:
-
trigger
Convenience method that triggers an event in a workflow.- Parameters:
type
- the type of the event- Since:
- 1.0
- See Also:
-
trigger
Convenience method that triggers an event in a workflow with associated data.- Parameters:
type
- the type of the eventdata
- the data that will be sent with the event- Since:
- 1.0
- See Also:
-
trigger
Triggers an event that wakes up work that is paused for the event type.If events are triggered, and no work is ready to consume them, they will be queued up until the first available work arrives.
- Parameters:
event
- the event- Since:
- 1.0
- See Also:
-
waitForPausedWork
Causes the calling thread to wait until work is paused for events.- Throws:
InterruptedException
- when the current thread is interrupted- Since:
- 1.0
-
waitForNoWork
Causes the calling thread to wait until no more work is running.- Throws:
InterruptedException
- when the current thread is interrupted- Since:
- 1.0
-
addListener
Adds a new event listener.- Parameters:
listener
- the event listener that will be added- Since:
- 1.0
- See Also:
-
removeListener
Removes an event listener.- Parameters:
listener
- the event listener that will be removed- Since:
- 1.0
- See Also:
-