工作流中ServiceTask的各种方法__.doc_第1页
工作流中ServiceTask的各种方法__.doc_第2页
工作流中ServiceTask的各种方法__.doc_第3页
工作流中ServiceTask的各种方法__.doc_第4页
工作流中ServiceTask的各种方法__.doc_第5页
已阅读5页,还剩3页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

工作流中ServiceTask的各种方法 在工作流中的activiti的serviceTask几种方法:模拟自动执行任务工作流的流程图:工作流配置:serviceTaskExpression.bpmn20.xmlXml代码 1. 2. 3. 7. 8. 9. 10. 11. 12. 13. 15. 16. 17. WelcometoBeijing 18. 19. 20. HelloMr.Bai 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 39. 40. 41. 42. 43. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. Welcome to Beijing Hello Mr. Bai 工作流的实现:Java代码 1. packagecom.easyway.activiti.servicetask; 2. 3. importorg.activiti.engine.delegate.DelegateExecution; 4. 5. /* 6. *从配置文件注入多个属性类型必须为Expression 7. *author 8. * 9. *2011-12-20下午10:08:01 10. */11. publicclassReverseStringsFieldInjectedimplementsJavaDelegate 12. 13. privateExpressiontext1; 14. privateExpressiontext2; 15. 16. publicvoidexecute(DelegateExecutionexecution) 17. Stringvalue1=(String)text1.getValue(execution); 18. execution.setVariable(var1,newStringBuffer(value1).reverse().toString(); 19. 20. Stringvalue2=(String)text2.getValue(execution); 21. execution.setVariable(var2,newStringBuffer(value2).reverse().toString(); 22. 23. package com.easyway.activiti.servicetask;import org.activiti.engine.delegate.DelegateExecution;/* * 从配置文件注入多个属性类型必须为Expression * author longgangbai * * 2011-12-20 下午10:08:01 */public class ReverseStringsFieldInjected implements JavaDelegate private Expression text1; private Expression text2; public void execute(DelegateExecution execution) String value1 = (String) text1.getValue(execution); execution.setVariable(var1, new StringBuffer(value1).reverse().toString(); String value2 = (String) text2.getValue(execution); execution.setVariable(var2, new StringBuffer(value2).reverse().toString(); Java代码 packagecom.easyway.activiti.servicetask; 1. 2. importorg.activiti.engine.delegate.DelegateExecution; 3. 4. /* 5. *从配置文件注入一个字符串用于变为写 6. *author7. * 8. *2011-12-20下午09:56:59 9. */10. publicclassToUppercaseimplementsJavaDelegate 11. privateExpressiontext; 12. publicvoidexecute(DelegateExecutionexecution)throwsException 13. Stringvalue1=(String)text.getValue(execution); 14. execution.setVariable(input,value1); 15. 16. 17. package com.easyway.activiti.servicetask;import org.activiti.engine.delegate.DelegateExecution;/* * 从配置文件注入一个字符串用于变为写 * author longgangbai * * 2011-12-20 下午09:56:59 */public class ToUppercase implements JavaDelegate private Expression text; public void execute(DelegateExecution execution) throws Exception String value1 = (String) text.getValue(execution); execution.setVariable(input, value1); servicetaskSpringTest-context.xmlXml代码 1. 2. 3. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 测试类:1. packagecom.easyway.activiti.servicetask; 2. 3. importorg.activiti.engine.runtime.ProcessInstance; 4. importorg.activiti.engine.test.Deployment; 5. importorg.activiti.spring.impl.test.SpringActivitiTestCase; 6. importorg.springframework.test.context.ContextConfiguration; 7. 8. /* 9. *工作流中ServiceTask的各种方法 10. *1.通过activiti:class使用相关的javaDelegate的子类。 11. * 13. 14. 15. WelcometoBeijing 16. 17. 18. HelloMr.Bai 19. 20. 21. 22. 2.通过spring的使用委派表达式实现 23. 24. 3.通过表达式将实现 25. 28. 29. 4.通过activiti:class注入相关的属性 30. 33. 34. 35. 36. 37. /*author38. * 39. *2011-12-20下午09:29:23 40. */41. ContextConfiguration(classpath:servicetaskSpringTest-context.xml) 42. publicclassServiceTaskExpressionTestextendsSpringActivitiTestCase 43. 44. Deployment(resources=diagrams/serviceTaskExpression.bpmn20.xml) 45. publicvoidtestDelegateExpression() 46. ProcessInstanceprocInst=runtimeService.startProcessInstanceByKey(serviceTaskProcess); 47. assertEquals(true,procInst.isEnded(); 48. 49. 50. package com.easyway.activiti.servicetask;import org.activiti.engine.runtime.ProcessInstance;import org.activiti.engine.test.Deployment;import org.activiti.spring.impl.test.SpringActivitiTestCase;import org.springframework.test.context.ContextConfiguration;/* * 工作流中ServiceTask的各种方法 * 1.通过activiti:class使用相关的javaDelegate的子类。 * Welcome to Beijing Hello Mr. Bai 2.通过spring的使用委派表达式实现 3.通过表达式将实现 4.通过activiti:class注入相关的属性 * author longgangbai * * 2011-12-20 下午09:29:23 */ContextConfiguration(classpath:servicetaskSpringTest-context.xml)public class ServiceTaskExpressionTest extends SpringActivitiTestCase Deplo

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论