Package 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
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:
-
Field Summary
FieldsFields inherited from class com.opensymphony.workflow.loader.AbstractWorkflowFactory
properties -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidExecute this functiongetWorkflow(String name, boolean validate) Get a workflow descriptor given a workflow name.String[]Get all workflow names in the current factoryvoidinitDone()Invoked after the properties of the factory have been set.byte[]booleanremoveWorkflow(String name) booleansaveWorkflow(String name, WorkflowDescriptor descriptor, boolean replace) Save the workflow.booleanMethods inherited from class com.opensymphony.workflow.loader.XMLWorkflowFactory
createWorkflow, getBaseDir, getInputStream, getLayout, getName, isModifiable, renameWorkflow, save, setLayout, writeXMLMethods inherited from class com.opensymphony.workflow.loader.AbstractWorkflowFactory
getProperties, getWorkflow, init
-
Field Details
-
ds
-
workflows
-
reload
protected boolean reload
-
-
Constructor Details
-
JDBCWorkflowFactory
public JDBCWorkflowFactory()
-
-
Method Details
-
getWorkflow
Description copied from interface:WorkflowFactoryGet a workflow descriptor given a workflow name.- Specified by:
getWorkflowin interfaceWorkflowFactory- Overrides:
getWorkflowin classXMLWorkflowFactory- 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
Description copied from interface:WorkflowFactoryGet all workflow names in the current factory- Specified by:
getWorkflowNamesin interfaceWorkflowFactory- Overrides:
getWorkflowNamesin classXMLWorkflowFactory- 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:FunctionProviderExecute this function- Specified by:
executein interfaceFunctionProvider- Parameters:
transientVars- Variables that will not be persisted. These include inputs given in theWorkflow.initialize(java.lang.String, int, java.util.Map)andWorkflow.doAction(long, int, java.util.Map)method calls. There are a number of special variable names:entry: (object type:WorkflowEntry) The workflow instancecontext: (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: TheWorkflowStore.descriptor: TheWorkflowDescriptor.
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 asWorkflow.initialize(java.lang.String, int, java.util.Map)andWorkflow.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
Description copied from class:AbstractWorkflowFactoryInvoked 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:
initDonein interfaceWorkflowFactory- Overrides:
initDonein classXMLWorkflowFactory- Throws:
FactoryException- if there was an error during initialization.
-
read
- Throws:
SQLException
-
removeWorkflow
- Specified by:
removeWorkflowin interfaceWorkflowFactory- Overrides:
removeWorkflowin classXMLWorkflowFactory- Throws:
FactoryException
-
saveWorkflow
public boolean saveWorkflow(String name, WorkflowDescriptor descriptor, boolean replace) throws FactoryException Description copied from interface:WorkflowFactorySave the workflow. Is it the responsibility of the caller to ensure that the workflow is valid, through theWorkflowDescriptor.validate()method. Invalid workflows will be saved without being checked.- Specified by:
saveWorkflowin interfaceWorkflowFactory- Overrides:
saveWorkflowin classXMLWorkflowFactory- 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
-
write
- Throws:
SQLException
-