沉睡森林@漂在北京

本处文章除注明“转载”外均为原创,转载请注明出处。

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  152 随笔 :: 4 文章 :: 114 评论 :: 0 Trackbacks
 

       在到处查资料,下载demo后,我终于让自己的osworkflow工作流跑了起来。环境采用了MySQL5Tomcat6JDBC做持久层。具体的步骤如下:

 

       1、创建数据库,脚本如下。

       osworkflow_app

 

    2、创建数据源,在tomcat根目录下找到conf目录里的context.xml文件,在Context节点中加入如下代码:

<Resource name="jdbc/osworkflow_app" auth="Container" type="javax.sql.DataSource"

               maxActive="100" maxIdle="30" maxWait="10000"

               username="root" password="sa" driverClassName="com.mysql.jdbc.Driver"

               url="jdbc:mysql://localhost:3306/osworkflow_app"/>

    其中,本人的数据库用户名和密码分别是rootsa,库表名称为osworkflow_app,需要修改的是数据库用户名和密码。特别注意,需要把mysql的驱动包随手丢到tomcatlib目录下。

 

       3、分别加入osworkflow的配置文件到src下面。

log4j.properties

log4j.rootLogger=debug, A1 , R

 

log4j.logger.org.apache=INFO

 

log4j.appender.A1=org.apache.log4j.ConsoleAppender

log4j.appender.A1.layout=org.apache.log4j.PatternLayout

log4j.appender.A1.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss} [%c]-[%p] %m%n

 

log4j.appender.R=org.apache.log4j.RollingFileAppender

log4j.appender.R.File=C:/OSWorkflowDemo.log

log4j.appender.R.MaxFileSize=1000KB

log4j.appender.R.MaxBackupIndex=1

log4j.appender.R.layout=org.apache.log4j.PatternLayout

log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n

 

osuser.xml

<?xml version="1.0" encoding="utf-8"?>

<opensymphony-user>

    <provider class="com.opensymphony.user.provider.jdbc.JDBCAccessProvider">

       <property name="user.table">os_user</property>

       <property name="group.table">os_group</property>

       <property name="membership.table">os_membership</property>

       <property name="user.name">username</property>

       <property name="user.password">passwordhash</property>

       <property name="group.name">groupname</property>

       <property name="membership.userName">username</property>

       <property name="membership.groupName">groupname</property>

       <property name="datasource">jdbc/osworkflow_app</property>

    </provider>

    <provider class="com.opensymphony.user.provider.jdbc.JDBCCredentialsProvider">

       <property name="user.table">os_user</property>

       <property name="group.table">os_group</property>

       <property name="membership.table">os_membership</property>

       <property name="user.name">username</property>

       <property name="user.password">passwordhash</property>

       <property name="group.name">groupname</property>

       <property name="membership.userName">username</property>

       <property name="membership.groupName">groupname</property>

       <property name="datasource">jdbc/osworkflow_app</property>

    </provider>

    <provider class="com.opensymphony.user.provider.jdbc.JDBCProfileProvider">

       <property name="user.table">os_user</property>

       <property name="group.table">os_group</property>

       <property name="membership.table">os_membership</property>

       <property name="user.name">username</property>

       <property name="user.password">passwordhash</property>

       <property name="group.name">groupname</property>

       <property name="membership.userName">username</property>

       <property name="membership.groupName">groupname</property>

       <property name="datasource">jdbc/osworkflow_app</property>

    </provider>

    <authenticator class="com.opensymphony.user.authenticator.SmartAuthenticator" />

</opensymphony-user>

 

osworkflow.xml

<?xml version="1.0" encoding="utf-8"?>

<osworkflow>

    <persistence class="com.opensymphony.workflow.spi.jdbc.MySQLWorkflowStore">

       <property key="datasource" value="java:comp/env/jdbc/osworkflow_app" />

       <property key="entry.sequence" value="SELECT max(ID)+1 FROM OS_WFENTRY" />

       <property key="step.sequence" value="SELECT max(ID)+1 FROM OS_STEPIDS" />

       <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="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" />

       <!--just for mysql-->

       <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="entry.sequence.increment" value="INSERT INTO OS_ENTRYIDS (ID) values (null)" />

       <property key="entry.sequence.retrieve" value="SELECT max(ID) FROM OS_ENTRYIDS" />

    </persistence>

   

    <factory class="com.opensymphony.workflow.loader.XMLWorkflowFactory">

       <property key="resource" value="workflows.xml" />

    </factory>

</osworkflow>

 

propertyset.xml

<?xml version="1.0" encoding="utf-8"?>

<propertysets>

    <propertyset name="jdbc"

      class="com.opensymphony.module.propertyset.database.JDBCPropertySet">

        <arg name="datasource" value="java:comp/env/jdbc/osworkflow_app"/>

        <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>

 

workflows.xml

<?xml version="1.0" encoding="utf-8"?>

<workflows>

    <workflow name="leave_apply" type="resource" location="bus_zhijian1.xml"/>

</workflows>

 

 

4、创建自己的流程描述文件bus_zhijian1.xml。该文件我没有经过测试,只能自己学习,不能贴出来了。建议初学者可以使用仅仅两个step的描述文件进行入门的学习。

 

5、编写java类和一些FunctionProvider,完成具体的业务。

posted on 2008-10-07 20:51 王总兵 阅读(312) 评论(0)  编辑  收藏 所属分类: Workflow

只有注册用户登录后才能发表评论。


网站导航: