com.opensymphony.workflow.loader
Class JDBCWorkflowFactory
java.lang.Object
com.opensymphony.workflow.loader.AbstractWorkflowFactory
com.opensymphony.workflow.loader.XMLWorkflowFactory
com.opensymphony.workflow.loader.JDBCWorkflowFactory
- All Implemented Interfaces:
- FunctionProvider, WorkflowFactory, Serializable
public class JDBCWorkflowFactory - extends XMLWorkflowFactory
- implements FunctionProvider
Workflow Factory that stores workflows in a database.
The database requires a property called 'datasource' which is the JNDI
name of the datasource for this factory.
Also required is a database table called OS_WORKFLOWDEFS with two columns,
WF_NAME which contains the workflow name, and WF_DEFINITION which will contain the xml
workflow descriptor, the latter can be either a TEXT or BINARY type.
Note that this class is provided as an example, and users are encouraged to use
their own implementations that are more suited to their particular needs.
- Author:
- Hubert Felber, Philipp Hug
Date: May 01, 2003
Time: 11:17:06 AM
- See Also:
- Serialized Form
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ds
protected DataSource ds
workflows
protected Map workflows
reload
protected boolean reload
JDBCWorkflowFactory
public JDBCWorkflowFactory()
getWorkflow
public WorkflowDescriptor getWorkflow(String name,
boolean validate)
throws FactoryException
- Description copied from interface:
WorkflowFactory
- Get a workflow descriptor given a workflow name.
- Specified by:
getWorkflow in interface WorkflowFactory- Overrides:
getWorkflow in class XMLWorkflowFactory
- Parameters:
name - The name of the workflow to get.
- Returns:
- The descriptor for the specified workflow.
- Throws:
FactoryException - if the specified workflow name does not exist or cannot be located.
getWorkflowNames
public String[] getWorkflowNames()
- Description copied from interface:
WorkflowFactory
- Get all workflow names in the current factory
- Specified by:
getWorkflowNames in interface WorkflowFactory- Overrides:
getWorkflowNames in class XMLWorkflowFactory
- Returns:
- An array of all workflow names
execute
public void execute(Map transientVars,
Map args,
com.opensymphony.module.propertyset.PropertySet ps)
- Description copied from interface:
FunctionProvider
- Execute this function
- Specified by:
execute in interface FunctionProvider
- Parameters:
transientVars - Variables that will not be persisted. These include inputs
given in the Workflow.initialize(java.lang.String, int, java.util.Map) and Workflow.doAction(long, int, java.util.Map) method calls.
There are a number of special variable names:
entry: (object type: WorkflowEntry)
The workflow instance
context:
(object type: WorkflowContext). The workflow context.
actionId: The Integer ID of the current action that was take (if applicable).
currentSteps: A Collection of the current steps in the workflow instance.
store: The WorkflowStore.
descriptor: The WorkflowDescriptor.
Also, any variable set as a Register), will also be
available in the transient map, no matter what. These transient variables only last through
the method call that they were invoked in, such as Workflow.initialize(java.lang.String, int, java.util.Map)
and Workflow.doAction(long, int, java.util.Map).args - The properties for this function invocation. Properties are created
from arg nested elements within the xml, an arg element takes in a name attribute
which is the properties key, and the CDATA text contents of the element map to
the property value.ps - The persistent variables that are associated with the current
instance of the workflow. Any change made to the propertyset are persisted to
the propertyset implementation's persistent store.
initDone
public void initDone()
throws FactoryException
- Description copied from class:
AbstractWorkflowFactory
- Invoked after the properties of the factory have been set.
Subclasses should override this method and add any specific
setup code required. For example, connecting to an external resource
or database.
- Specified by:
initDone in interface WorkflowFactory- Overrides:
initDone in class XMLWorkflowFactory
- Throws:
FactoryException - if there was an error during initialization.
read
public byte[] read(String workflowname)
throws SQLException
- Throws:
SQLException
removeWorkflow
public boolean removeWorkflow(String name)
throws FactoryException
- Specified by:
removeWorkflow in interface WorkflowFactory- Overrides:
removeWorkflow in class XMLWorkflowFactory
- Throws:
FactoryException
saveWorkflow
public boolean saveWorkflow(String name,
WorkflowDescriptor descriptor,
boolean replace)
throws FactoryException
- Description copied from interface:
WorkflowFactory
- Save the workflow.
Is it the responsibility of the caller to ensure that the workflow is valid,
through the
WorkflowDescriptor.validate() method. Invalid workflows will
be saved without being checked.
- Specified by:
saveWorkflow in interface WorkflowFactory- Overrides:
saveWorkflow in class XMLWorkflowFactory
- Parameters:
name - The name of the workflow to same.descriptor - The descriptor for the workflow.replace - true if an existing workflow with this name should be replaced.
- Returns:
- true if the workflow was saved.
- Throws:
FactoryException - if there was an error saving the workflow
InvalidWorkflowDescriptorException - if the descriptor specified is invalid
write
public boolean write(String workflowname,
byte[] wf)
throws SQLException
- Throws:
SQLException
|