transactionadvice.java
来自「cwbbs 云网论坛源码」· Java 代码 · 共 41 行
JAVA
41 行
package com.cloudwebsoft.framework.aop.advice;import java.lang.reflect.Method;import java.lang.reflect.Proxy;import com.cloudwebsoft.framework.aop.base.Advice;import com.cloudwebsoft.framework.db.JdbcTemplate;import cn.js.fan.util.ErrMsgException;public class TransactionAdvice implements Advice { public TransactionAdvice() { } public void Before(Object proxy, Method method, Object[] args) throws Throwable { int len = args.length; for (int i=0; i<len; i++) { if (args[i] instanceof JdbcTemplate) { JdbcTemplate jt = (JdbcTemplate)args[i]; jt.getConnection().beginTrans(); } } } public void After(Object proxy, Method method, Object[] args) throws Throwable { int len = args.length; for (int i=0; i<len; i++) { if (args[i] instanceof JdbcTemplate) { JdbcTemplate jt = (JdbcTemplate)args[i]; jt.getConnection().commit(); } } } public void Throw(Object proxy, Method method, Object[] args, Exception e) throws Throwable { throw new ErrMsgException(e.getMessage()); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?