OSWORKFLOW-将Osworkflow+MYSQL持久化之二:JDBCStore
/*
*Author: Meanson Wang
*Date: 2005-01-15
*Email: meansonw@hotmail.com
*/
Osworkflow支持以下的持久化:MemoryStore (default), SerializableStore, JDBCStore, OfbizStore, and EJBStore.
【环境】
WIN2000
Osworkflow 2.7.0
Tomat 5.0.25
Mysql 4.1.7-nt + mysql-connector-java-3.0.15-ga-bin.jar
以下是使用MYSQL来进行持久化,支持文档是OSWF的手册的1.4 Persistence Options.html。里面建议用的是HypersonicSQL.
【步骤一:】建库
在MYSQL里建立一个DB命名为osworkflow
执行压缩文件src/etc/deployment/jdbc里面的mysql.sql建表。
【步骤二:】在TOMCAT里建立一个Datasource,命名为jdbc/oswf
1)Tomcat的admin中的DataSource中配置一个DataSource jdbc/oswf
2)$CATALINA_HOME/conf/catalina/localhost/$appname.xml中配置一个resource link
【步骤三:】修改osworkflow.xml
<osworkflow>
<!--
<persistence class="com.opensymphony.workflow.spi.memory.MemoryWorkflowStore"/>
-->
<persistence class="com.opensymphony.workflow.spi.jdbc.MySQLWorkflowStore">
<property key="datasource" value="jdbc/oswf"/>
<property key="entry.sequence"
value="SELECT max(id)+1 FROM OS_WFENTRY"/>
<property key="entry.table" value="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="historyPrev.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.XMLWorkflowFactory">
<property key="resource" value="workflows.xml" />
</factory>
</osworkflow>
【步骤四:】添加propertyset.xml文件到WEB-INF\classes下。
<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"/>