原文:
http://www.blogjava.net/pdw2009/archive/2006/04/11/40475.html
1 新建一个名为oswf的Web Projcet 项目,并添加项目的 struts capabilities,并把osworkflow所需要jar文件拷贝到lib目录下.
2 在tomcat的servers.xml文件中配置一个项目连接到我们所在的myeclipse工作区中所建立的oswf项目下的WebRoot目录下.在servers.xml中添加如下代码:
<Context path="/oswf" docBase="D:/peidw/workplace/osworkflow/WebRoot" debug="5" reloadable="true" crossContext="true">
<Resource name="jdbc/oswf" auth="Container" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/oswf">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/osworkflow</value>
</parameter>
<parameter>
<name>username</name>
<value>root</value>
</parameter>
<parameter>
<name>password</name>
<value></value>
</parameter>
<parameter>
<name>maxActive</name>
<value>20</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>2</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>-1</value>
</parameter>
<parameter>
<name>removeAbandoned</name>
<value>true</value>
</parameter>
<parameter>
<name>removeAbandonedTimeout</name>
<value>300</value>
</parameter>
</ResourceParams>
</Context>
3 在src目录需要建立三个文件来配置OSWorkflow的相关配置.首先是osworkflow.xml文件,至于文件的作用一看就明白,内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<osworkflow>
<persistence class="com.opensymphony.workflow.spi.jdbc.JDBCWorkflowStore">
<property key="datasource" value="jdbc/oswf"/>
<property key="entry.sequence" value="select max(id)+1 from os_wfentry"/>
<property key="entry.id" value="id"/>
<property key="entry.name" value="name" />
<property key="entry.state" value="state"/>
<property key="step.sequence" value="select max(id)+1 from os_stepids"/>
<property key="step.sequence.increment" value="insert into os_stepids(id) values(null) "/>
<property key="step.sequence.retrieve" value="select max(id) from os_stepids"/>
<property key="history.table" value="os_historystep"/>
<property key="current.table" value="os_currentstep"/>
<property key="histroyPrev.table" value="os_historystep_prev"/>
<property key="currentPrev.table" value="os_currentstep_prev"/>
<property key="step.id" value="ID"/>
<property key="step.entryId" value="ENTRY_ID"/>
<property key="step.stepId" value="STEP_ID"/>
<property key="step.actionId" value="ACTION_ID"/>
<property key="step.owner" value="OWNER"/>
<property key="step.caller" value="CALLER"/>
<property key="step.startDate" value="START_DATE"/>
<property key="step.finishDate" value="FINISH_DATE"/>
<property key="step.dueDate" value="DUE_DATE"/>
<property key="step.status" value="STATUS"/>
<property key="step.previousId" value="PREVIOUS_ID"/>
</persistence>
<factory class="com.opensymphony.workflow.loader.JDBCWorkflowFactory">
<property key="resource" value="workflows.xml"/>
</factory>
</osworkflow>
在src目录下新建一个propertyset.xml来存储相应的字段配置信息:
<?xml version="1.0" encoding="UTF-8"?>
<propertysets>
<propertyset name="jdbc"
class="com.opensymphony.module.propertyset.database.JDBCPropertySet">
<arg name="datasource" value="jdbc/oswf"/>
<arg name="table.name" value="OS_PROPERTYENTRY"/>
<arg name="col.globalKey" value="GLOBAL_KEY"/>
<arg name="col.itemKey" value="ITEM_KEY"/>
<arg name="col.itemType" value="ITEM_TYPE"/>
<arg name="col.string" value="STRING_VALUE"/>
<arg name="col.date" value="DATE_VALUE"/>
<arg name="col.data" value="DATA_VALUE"/>
<arg name="col.float" value="FLOAT_VALUE"/>
<arg name="col.number" value="NUMBER_VALUE"/>
</propertyset>
</propertysets>
还要新建一个流程的配置文件,该文件的命名与osworkflow.xml的factory节点里的值有关,如:
<?xml version="1.0" encoding="UTF-8"?>
<workflows>
<workflow name="leave" type="resource" location="leave.xml"/>
</workflows>
那么leave.xml就是一个工作流的真正配置文件。其内容如下:
这样就可以配置OSworkflow持久化进mysql中.
1 新建一个名为oswf的Web Projcet 项目,并添加项目的 struts capabilities,并把osworkflow所需要jar文件拷贝到lib目录下.
2 在tomcat的servers.xml文件中配置一个项目连接到我们所在的myeclipse工作区中所建立的oswf项目下的WebRoot目录下.在servers.xml中添加如下代码:
<Context path="/oswf" docBase="D:/peidw/workplace/osworkflow/WebRoot" debug="5" reloadable="true" crossContext="true">
<Resource name="jdbc/oswf" auth="Container" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/oswf">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/osworkflow</value>
</parameter>
<parameter>
<name>username</name>
<value>root</value>
</parameter>
<parameter>
<name>password</name>
<value></value>
</parameter>
<parameter>
<name>maxActive</name>
<value>20</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>2</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>-1</value>
</parameter>
<parameter>
<name>removeAbandoned</name>
<value>true</value>
</parameter>
<parameter>
<name>removeAbandonedTimeout</name>
<value>300</value>
</parameter>
</ResourceParams>
</Context>
3 在src目录需要建立三个文件来配置OSWorkflow的相关配置.首先是osworkflow.xml文件,至于文件的作用一看就明白,内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<osworkflow>
<persistence class="com.opensymphony.workflow.spi.jdbc.JDBCWorkflowStore">
<property key="datasource" value="jdbc/oswf"/>
<property key="entry.sequence" value="select max(id)+1 from os_wfentry"/>
<property key="entry.id" value="id"/>
<property key="entry.name" value="name" />
<property key="entry.state" value="state"/>
<property key="step.sequence" value="select max(id)+1 from os_stepids"/>
<property key="step.sequence.increment" value="insert into os_stepids(id) values(null) "/>
<property key="step.sequence.retrieve" value="select max(id) from os_stepids"/>
<property key="history.table" value="os_historystep"/>
<property key="current.table" value="os_currentstep"/>
<property key="histroyPrev.table" value="os_historystep_prev"/>
<property key="currentPrev.table" value="os_currentstep_prev"/>
<property key="step.id" value="ID"/>
<property key="step.entryId" value="ENTRY_ID"/>
<property key="step.stepId" value="STEP_ID"/>
<property key="step.actionId" value="ACTION_ID"/>
<property key="step.owner" value="OWNER"/>
<property key="step.caller" value="CALLER"/>
<property key="step.startDate" value="START_DATE"/>
<property key="step.finishDate" value="FINISH_DATE"/>
<property key="step.dueDate" value="DUE_DATE"/>
<property key="step.status" value="STATUS"/>
<property key="step.previousId" value="PREVIOUS_ID"/>
</persistence>
<factory class="com.opensymphony.workflow.loader.JDBCWorkflowFactory">
<property key="resource" value="workflows.xml"/>
</factory>
</osworkflow>
在src目录下新建一个propertyset.xml来存储相应的字段配置信息:
<?xml version="1.0" encoding="UTF-8"?>
<propertysets>
<propertyset name="jdbc"
class="com.opensymphony.module.propertyset.database.JDBCPropertySet">
<arg name="datasource" value="jdbc/oswf"/>
<arg name="table.name" value="OS_PROPERTYENTRY"/>
<arg name="col.globalKey" value="GLOBAL_KEY"/>
<arg name="col.itemKey" value="ITEM_KEY"/>
<arg name="col.itemType" value="ITEM_TYPE"/>
<arg name="col.string" value="STRING_VALUE"/>
<arg name="col.date" value="DATE_VALUE"/>
<arg name="col.data" value="DATA_VALUE"/>
<arg name="col.float" value="FLOAT_VALUE"/>
<arg name="col.number" value="NUMBER_VALUE"/>
</propertyset>
</propertysets>
还要新建一个流程的配置文件,该文件的命名与osworkflow.xml的factory节点里的值有关,如:
<?xml version="1.0" encoding="UTF-8"?>
<workflows>
<workflow name="leave" type="resource" location="leave.xml"/>
</workflows>
那么leave.xml就是一个工作流的真正配置文件。其内容如下:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE workflow PUBLIC "-//OpenSymphony Group//DTD OSWorkflow 2.7//EN"
"http://www.opensymphony.com/osworkflow/workflow_2_7.dtd">
<workflow>
<initial-actions>
<action id="0" name="開始">
<results>
<unconditional-result old-status="Finished" status="Queued" step="1" />
</results>
</action>
</initial-actions>
<steps>
<step id="1" name="填假單">
<actions>
<action id="1" name="送出">
<pre-functions>
<function type="class">
<arg name="class.name">com.opensymphony.workflow.util.Caller</arg>
</function>
</pre-functions>
<results>
<unconditional-result old-status="Finished" status="Queued"
step="2" owner="User100" />
</results>
</action>
</actions>
</step>
<step id="2" name="批假單">
<actions>
<action id="2" name="准許">
<pre-functions>
<function type="class">
<arg name="class.name">com.opensymphony.workflow.util.Caller</arg>
</function>
</pre-functions>
<results>
<unconditional-result old-status="Finished" status="Queued"
step="3" owner="${caller}"/>
</results>
</action>
<action id="3" name="駁回">
<pre-functions>
<function type="class">
<arg name="class.name">com.opensymphony.workflow.util.Caller</arg>
</function>
</pre-functions>
<results>
<unconditional-result old-status="Finished" status="Queued"
step="1" owner="${caller}"/>
</results>
</action>
</actions>
</step>
<step id="3" name="停止" />
</steps>
</workflow>
这样就可以配置OSworkflow持久化进mysql中.