java 代码
- <aop:config> </aop:config>
- ref="workflowHistoryImpl">
- expression="execution(* cn.grgbanking.view..*Impl.saveData(..)) and args(request)" />
- method="saveHistory" />
- "workflowHistoryImpl"
- class="cn.grgbanking.wfms.impl.WorkflowHistoryImpl">
说明:
这是个添加工作流历史记录的拦截类.当执行cn.grgbanking.view下面的所有节点业务类提交保存数据方法的时都会拦截到执行添加工作流历史记录的方法.
执行这个添加的类bean是 workflowHistoryImpl,方法是saveHistory
java 代码
- public class WorkflowHistoryImpl extends HibernateGenericDao implements
- IWorkflowHistory {
- /**
- * @description 保存历史记录
- * @param
- * @return
- * @exception
- * @athor
- */
- public boolean saveHistory(HttpServletRequest request) {
- String taskId = request.getParameter("TASKINSTANCEID");
- String businessid = request.getParameter("businessKey"); // TODO
- // Auto-generated
- // method
- WfmsHistory wfmsHistory = new WfmsHistory();
- if (taskId != null) {
- long tid = Long.parseLong(taskId);
- wfmsHistory.setTaskinstanceid(tid);
- }
- if (businessid != null) {
- wfmsHistory.setBusinessid(businessid);
- }
- this.save(wfmsHistory);
- return true;
- }
- }
第二种写在bean里面
java 代码
- @Aspect
- public class WorkflowHistoryImpl extends HibernateGenericDao {
- @After("execution(* cn.grgbanking.view..*Impl.saveData(..)) && args(request,..)")
- public void saveHistory( HttpServletRequest request) {
- System.out.println("aspect-------------------------successfull");
- }
- }
本文介绍了一种使用AOP技术实现的工作流历史记录添加方法。该方法通过配置拦截器,在执行特定模块的保存操作时自动记录历史信息。此外,还提供了一个基于注解的实现方案。
2211

被折叠的 条评论
为什么被折叠?



