01.08.2012 Views

Using Osworkflow in your Application

Using Osworkflow in your Application

Using Osworkflow in your Application

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Us<strong>in</strong>g</strong> OSWorkfl ow <strong>in</strong> <strong>your</strong> <strong>Application</strong><br />

Firstly, the framework confi gures itself by pars<strong>in</strong>g and read<strong>in</strong>g the osworkflow.xml<br />

fi le <strong>in</strong> the classpath. This fi le conta<strong>in</strong>s several sett<strong>in</strong>gs, such as the WorkflowStore<br />

implementation class name, the WorkflowFactory handler class name, and so on.<br />

The default osworkflow.xml fi le is as follows:<br />

<br />

<br />

<br />

<br />

<br />

<br />

OSWorkfl ow delegates the persistence features—such as load<strong>in</strong>g and sav<strong>in</strong>g<br />

<strong>in</strong>dividual <strong>in</strong>stances—of the eng<strong>in</strong>e to an <strong>in</strong>terface named WorkflowStore.<br />

There are several built-<strong>in</strong> implementations such as EJB, JDBC, etc. The default<br />

osworkflow.xml fi le uses the MemoryWorkflowStore implementation for persist<strong>in</strong>g<br />

<strong>in</strong>stances <strong>in</strong> memory.<br />

The WorkflowFactory is the <strong>in</strong>terface responsible for read<strong>in</strong>g workfl ow<br />

defi nitions <strong>in</strong> any format and giv<strong>in</strong>g them to the eng<strong>in</strong>e <strong>in</strong> a proper format. The<br />

default implementation is XMLWorkflowFactory; obviously this reads XML<br />

workfl ow defi nitions.<br />

As you can see, the default osworkflow.xml fi le is confi gured to use an<br />

XMLWorkflowFactory and po<strong>in</strong>ts to a resource fi le called workflows.xml. The<br />

workflows.xml fi le looks like this:<br />

<br />

<br />

<br />

<br />

The workflows.xml fi le describes which workfl ow defi nitions are available and<br />

<strong>in</strong> which fi le the eng<strong>in</strong>e can fi nd the XML data. You can see we have two different<br />

processes to <strong>in</strong>itiate—holiday and loan.<br />

[ 70 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!