FuncitonProvider是osworkflow的一个事务处理入口。我们可以通过这个接口来实现具体的操作,具有极为方便的java实现机制。
首先是抽象方法:
public void execute(Map transientVars, Map args, PropertySet ps) throws WorkflowException;
这个方法包括的这三个参数:
1) transientVars
流程操作过程中产生的不必持久化的参数
e.g:
public class Caller implements FunctionProvider {
//~ Methods
public void execute(Map transientVars, Map args, PropertySet ps) {
WorkflowContext context = (WorkflowContext) transientVars.get("context");
transientVars.put("caller", context.getCaller());
}
}
上面的代码是Caller类,一个FunctionProvider 的默认实现,过程中临时的变量caller存储到了transientVars,然后在我们的流程文件中,可以通过${caller}方式调用。具体的例子可以查看osworkflow里面的example中的example.xml里面是如何使用caller参数的。
不过在我们实践中,估计有时也需要对这一部分的数据持久化,因为我们需要保留流程的具体操作人等实时和历史信息。
2)args
这个参数是在我们的流程配置文件中,针对我们特殊的FunctionProvider里面配置的参数map
e.g:
<function type="class">
<arg name="class.name">com.future.workflow.functions.Approve</arg>
<arg name="message">This is a test!</arg>
</function>
对于上面的配置,我们可以在execute(Map transientVars, Map args, PropertySet ps)方法中,通过args.get("message")来获取具体的变量值,一目了然,无须赘言!
3)ps(PropertySet )
PropertySet是一个类map式的类,它主要用于存储跟流程相关的属性。