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

Now the orig<strong>in</strong>al bean is substituted by a proxy, which wraps each Workflow<br />

<strong>in</strong>terface method with transaction handl<strong>in</strong>g code (the TransactionInterceptor<br />

bean). The orig<strong>in</strong>al workflow bean is now called the target bean of the <strong>in</strong>terceptor.<br />

With this addition, the <strong>in</strong>itialize() method of the example code block <strong>in</strong> the<br />

previous section would run on its own transaction, due to the PROPAGATION_REQUIRED<br />

transaction attribute for all the Workflow <strong>in</strong>terface methods.<br />

The Spr<strong>in</strong>gTypeResolver<br />

By us<strong>in</strong>g a Spr<strong>in</strong>gTypeResolver you can describe the beans that implement the<br />

Function or other resolver-supported <strong>in</strong>terfaces and reference them by name<br />

<strong>in</strong>side the WorkflowDescriptor. To defi ne a resolver, add this bean element to the<br />

BeanFactory XML:<br />

<br />

Then, modify the workflow bean defi nition by add<strong>in</strong>g a new property element:<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

After that, add a Function bean that looks like this <strong>in</strong> the BeanFactory XML:<br />

<br />

It can be declared and used <strong>in</strong> the WorkflowDescriptor <strong>in</strong> the follow<strong>in</strong>g way:<br />

<br />

SampleBus<strong>in</strong>essLogicFunction<br />

<br />

The new "spr<strong>in</strong>g" function type signals the WorkflowDescriptor to resolve the bean<br />

name with the Spr<strong>in</strong>g BeanFactory via a call to the BeanFactory.getBean() method<br />

with the bean name as the method parameter. The SampleBus<strong>in</strong>essLogicFunction<br />

would obviously have to implement the classic FunctionProvider <strong>in</strong>terface.<br />

[ 92 ]

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

Saved successfully!

Ooh no, something went wrong!