spring2.0 AOP (二)

java 代码
  1. <aop:config>  </aop:config>   
  2.            
  3.             ref="workflowHistoryImpl">   
  4.             
  5.                 expression="execution(* cn.grgbanking.view..*Impl.saveData(..)) and args(request)" />   
  6.             
  7.                 method="saveHistory" />   
  8.         
  9.     
  10.   
  11.     "workflowHistoryImpl"  
  12.         class="cn.grgbanking.wfms.impl.WorkflowHistoryImpl">   
  13.       

说明:

 这是个添加工作流历史记录的拦截类.当执行cn.grgbanking.view下面的所有节点业务类提交保存数据方法的时都会拦截到执行添加工作流历史记录的方法.

执行这个添加的类bean是 workflowHistoryImpl,方法是saveHistory

java 代码
  1. public class WorkflowHistoryImpl extends HibernateGenericDao implements  
  2.         IWorkflowHistory {   
  3.   
  4.     /**  
  5.      * @description 保存历史记录  
  6.      * @param  
  7.      * @return  
  8.      * @exception  
  9.      * @athor  
  10.      */  
  11.   
  12.     public boolean saveHistory(HttpServletRequest request) {   
  13.         String taskId = request.getParameter("TASKINSTANCEID");   
  14.         String businessid = request.getParameter("businessKey"); // TODO   
  15.                                                                     // Auto-generated   
  16.         // method   
  17.         WfmsHistory wfmsHistory = new WfmsHistory();   
  18.         if (taskId != null) {   
  19.             long tid = Long.parseLong(taskId);   
  20.             wfmsHistory.setTaskinstanceid(tid);   
  21.         }   
  22.         if (businessid != null) {   
  23.             wfmsHistory.setBusinessid(businessid);   
  24.         }   
  25.         this.save(wfmsHistory);   
  26.         return true;   
  27.     }   
  28. }   

 

第二种写在bean里面

java 代码
  1. @Aspect  
  2. public class WorkflowHistoryImpl extends HibernateGenericDao {   
  3.   
  4.     @After("execution(* cn.grgbanking.view..*Impl.saveData(..)) && args(request,..)")   
  5.     public void saveHistory( HttpServletRequest request) {   
  6.         System.out.println("aspect-------------------------successfull");                  
  7.     }   
  8. }  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值