Configure the osworkflow environment in myeclipse (persistent to MySQL)

Source: Internet
Author: User
Original article: http://www.blogjava.net/pdw2009/archive/2006/04/11/40475.html
1. Create a web projcet project named oswf, add the struts capabilities of the project, and copy the jar files required by osworkflow to the lib directory.

2. configure a project in the Tomcat servers. xml file to connect to the webroot directory of the oswf project created in our myeclipse work zone. Add the following code to 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. basicperformancefactory </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. In the src directory, you need to create three files to configure the osworkflow configuration. The first is the osworkflow. xml file. As for the role of the file, you can see that the content is as follows:
<? 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 = "previus_id"/>

</Persistence>
 
<Factory class = "com. opensymphony. workflow. loader. jdbcworkflowfactory">
<Property key = "resource" value = "workflows. xml"/>
</Factory>
</Osworkflow>
Create a propertyset. xml file in the src directory to store the corresponding field configuration information:

<? 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>
Create a configuration file for the process. The file name is related to the values in the factory node of osworkflow. XML, for example:

<? XML version = "1.0" encoding = "UTF-8"?>
<Workflows>
<Workflow name = "leave" type = "resource" location = "leave. xml"/>
</Workflows>

Leave. XML is the real configuration file of a workflow. The content is as follows:

<? 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 = "start">
<Results>
<Unconditional-result old-status = "finished" status = "queued" step = "1"/>
</Results>
</Action>
</Initial-Actions>

<Steps>
<Step id = "1" name = "fill in a ticket">
<Actions>
<Action id = "1" name = "send">
<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 = "Approval Form">
<Actions>
<Action id = "2" name = "prospective">
<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 = "reply">
<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 = "stop"/>
</Steps>
</Workflow>

In this way, you can configure osworkflow to be persistent in MySQL.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.