锁定老帖子 主题:深入osworkflow的function
精华帖 (0) :: 良好帖 (6) :: 新手帖 (6) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2008-05-06
最后修改:2011-02-06
1.基本概念 osworkflow里使用自定义的function来执行业务代码,如步骤“拟稿”,当你执行提交操作的时候,可以自定义一个funciton用来保存稿件到业务数据库。 function分为pre-function(前置方法)和post-function(后置方法),前置函数在step和action之前执行, 后置方法在step和action之后执行。 2.如何使用 2.1 定义前置function 前置方法,放在action里results之前。 <action id="100" name="启动工作流"> <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="Underway" step="1" owner="${caller}"/> </results> </action> 2.2 定义后置function 后置方法,放在action里results之后。 <action id="100" name="启动工作流"> <results> <unconditional-result old-status="Finished" status="Underway" step="1" owner="${caller}"/> </results> <post-functions> <function type="class"> <arg name="class.name">com.opensymphony.workflow.util.Caller</arg> </function> </post-functions> </action> 2.3 执行benshell osworkflow支持在function里执行beanshell脚本。 <post-functions> <function type="beanshell"> <arg name="script"> System.out.println("step is success!!!"); </arg> </function> </post-functions> 2.4 自定义function 实现FunctionProvider接口来自定义自己的function.如下: public class MyFunction implements FunctionProvider { @SuppressWarnings("unchecked") public void execute(Map transientVars, Map args, PropertySet ps) throws WorkflowException { } } 在function里你能够得到caller(调用者的名字),workflowID(工作流ID),actionId(操作ID)。 WorkflowEntry workflowEntry = (WorkflowEntry) transientVars.get("entry"); long workflowId = workflowEntry.getId(); BasicWorkflowContext context = (BasicWorkflowContext) transientVars.get("context"); String caller = context.getCaller(); int actionId = (Integer) transientVars.get("actionId"); 3.使用spring来管理function osworkflow支持使用spring来管理function和condition的生命周期。 3.1 让spring来管理function 在bean.xml做如下配置 <!-- 将工作流的function和condition交给spring管理 --> <bean id="resolver" class="com.opensymphony.workflow.util.SpringTypeResolver"> </bean> 这样通过byName的注入方式,注入到你的AbstractWorkflow的bean里。 或者 AbstractWorkflow workflow = new BasicWorkflow(userName); workflow.setResolver(workflowTypeResolver); workflow.setConfiguration(osworkflowConfiguration); 3.2定义myFunction的bean <bean id="myFunction" class="MyFunction" /> 3.2配置bean的function <post-functions> <function type="spring"> <arg name="bean.name">myFunction</arg> </function> </post-functions> arg的name为bean.name 注意:<arg name="bean.name">myFunction</arg>必须放在同一行,因为myFunction旁边有空格的话,会找不到myFunction bean。 更多osworkflow讨论,请进入osworkflow组:[url]http://osworkflow.group.iteye.com/ [/url] 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2008-05-07
恩,不错,osworkflow与其他业务模块交互就靠funciton了
|
|
返回顶楼 | |
发表时间:2008-05-07
可以找这本书来看看
OSWorkflow: A guide for Java developers and architects to integrating open-source Business Process Management (Paperback) http://www.amazon.com/OSWorkflow-developers-architects-integrating-open-source/dp/1847191525 |
|
返回顶楼 | |
发表时间:2008-05-08
最近一直在研究osworkflow,
很想看看lllyq说的这本书。 |
|
返回顶楼 | |
发表时间:2008-06-27
怎么实现会签阿,谢谢啦
|
|
返回顶楼 | |
发表时间:2008-06-27
工作流初学者:
参考:http://hi.baidu.com/vjame/blog/item/43a537d1719caf3d9b50279d.html |
|
返回顶楼 | |
发表时间:2008-06-28
kathytingzi 写道 怎么实现会签阿,谢谢啦
增加两个conditon, 第一个:如果会签的人都签字了,进入下一个步骤。 第二个:如果还未有人未会签,则循环当前步骤。 |
|
返回顶楼 | |
发表时间:2009-01-01
最后修改:2009-01-01
你好,我是这样配置的
<bean id="workflowTypeResolver" class="com.opensymphony.workflow.util.SpringTypeResolver"> <property name="functions"> <map> <entry key="stockCheckPassFunction"> <value>com.atsig.market.workflow.function.StockCheckPassFunction</value> </entry> </map> </property> </bean> <bean id="stockCheckPassFunction" class="com.atsig.market.workflow.function.StockCheckPassFunction"> </bean> <post-functions> <function type="spring"> <arg name="bean.name">stockCheckPassFunction</arg> </function> </post-functions> 但却报此错误,我不知道是什么原因,你是否可以告诉我,谢谢了. com.opensymphony.workflow.WorkflowException: No type or class.name argument specified to TypeResolver at com.opensymphony.workflow.TypeResolver.getFunction(TypeResolver.java:84) at com.opensymphony.workflow.AbstractWorkflow.executeFunction(AbstractWorkflow.java:860) at com.opensymphony.workflow.AbstractWorkflow.transitionWorkflow(AbstractWorkflow.java:1273) at com.opensymphony.workflow.AbstractWorkflow.doAction(AbstractWorkflow.java:567) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198) at $Proxy0.doAction(Unknown Source) at com.atsig.market.stock.service.StockWorkflowSerImpl.doAction(StockWorkflowSerImpl.java:77) at com.atsig.market.stock.controller.StockApplyCheckupController.dealWithAction(StockApplyCheckupController.java:74) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.web.servlet.mvc.multiaction.MultiActionController.invokeNamedMethod(MultiActionController.java:473) at org.springframework.web.servlet.mvc.multiaction.MultiActionController.handleRequestInternal(MultiActionController.java:410) at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153) at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:212) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445) at java.lang.Thread.run(Thread.java:619) |
|
返回顶楼 | |
发表时间:2009-01-01
我想在Function中通过Spring注入属性,但确获得的值为Null,我该如何给Function注入属性?。我一个初学值,不太懂,有说的不对的地方,还请见谅,谢谢。
|
|
返回顶楼 | |
发表时间:2009-01-02
用osworkflow 做过几个小东西,感觉到osworkflow的确太麻烦,准备最近抽时间封装一下
|
|
返回顶楼 | |