mirror of
https://github.com/wahyd4/Martian.git
synced 2026-08-09 05:16:21 +10:00
update version
This commit is contained in:
@@ -22,8 +22,6 @@ public class MarsBeanProxy implements MethodInterceptor {
|
||||
|
||||
private Enhancer enhancer;
|
||||
|
||||
private Class<?> cls;
|
||||
|
||||
/**
|
||||
* 获取代理对象
|
||||
*
|
||||
@@ -31,7 +29,6 @@ public class MarsBeanProxy implements MethodInterceptor {
|
||||
* @return 对象
|
||||
*/
|
||||
public Object getProxy(Class<?> clazz) {
|
||||
this.cls = clazz;
|
||||
enhancer = new Enhancer();
|
||||
// 设置需要创建子类的类
|
||||
enhancer.setSuperclass(clazz);
|
||||
@@ -67,7 +64,7 @@ public class MarsBeanProxy implements MethodInterceptor {
|
||||
}
|
||||
|
||||
/* 开启事务 */
|
||||
ExecTraction.beginTraction(args, tractionModel);
|
||||
ExecTraction.beginTraction(tractionModel);
|
||||
|
||||
/* 执行aop的开始方法 */
|
||||
ExecAop.startMethod(args, aopModel);
|
||||
@@ -79,7 +76,7 @@ public class MarsBeanProxy implements MethodInterceptor {
|
||||
ExecAop.endMethod(args,o1,aopModel);
|
||||
|
||||
/* 提交事务 */
|
||||
ExecTraction.commit(args, tractionModel);
|
||||
ExecTraction.commit(tractionModel);
|
||||
return o1;
|
||||
} catch (Throwable e) {
|
||||
/* 回滚事务 */
|
||||
|
||||
@@ -59,7 +59,7 @@ public class ExecAop {
|
||||
* @param marsAop aop注解
|
||||
* @return aop实体
|
||||
*/
|
||||
public static AopModel getAopModel(MarsAop marsAop) throws Exception {
|
||||
public static AopModel getAopModel(MarsAop marsAop) throws Exception {
|
||||
if(marsAop == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -11,30 +11,28 @@ public class ExecTraction {
|
||||
|
||||
/**
|
||||
* 开启事务
|
||||
* @param args 参数
|
||||
* @param aopModel Aop实体
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
public static void beginTraction(Object[] args, AopModel aopModel) throws Exception {
|
||||
public static void beginTraction(AopModel aopModel) throws Exception {
|
||||
if (aopModel == null) {
|
||||
return;
|
||||
}
|
||||
Method m2 = aopModel.getCls().getDeclaredMethod(AopConstant.START_METHOD, new Class[]{Object[].class, AopModel.class});
|
||||
m2.invoke(aopModel.getObj(), new Object[]{args, aopModel});
|
||||
Method m2 = aopModel.getCls().getDeclaredMethod(AopConstant.START_METHOD, new Class[]{AopModel.class});
|
||||
m2.invoke(aopModel.getObj(), new Object[]{aopModel});
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交事务
|
||||
* @param aopModel 对象
|
||||
* @param args 参数
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
public static void commit(Object[] args, AopModel aopModel) throws Exception {
|
||||
public static void commit(AopModel aopModel) throws Exception {
|
||||
if (aopModel == null) {
|
||||
return;
|
||||
}
|
||||
Method m2 = aopModel.getCls().getDeclaredMethod(AopConstant.END_METHOD, new Class[]{Object[].class});
|
||||
m2.invoke(aopModel.getObj(), new Object[]{args});
|
||||
Method m2 = aopModel.getCls().getDeclaredMethod(AopConstant.END_METHOD);
|
||||
m2.invoke(aopModel.getObj());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,7 +54,7 @@ public class ExecTraction {
|
||||
* @param traction 事务监听注解
|
||||
* @return aop实体
|
||||
*/
|
||||
public static AopModel getAopModel(Traction traction) throws Exception {
|
||||
public static AopModel getAopModel(Traction traction) throws Exception {
|
||||
if(traction == null){
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -28,9 +28,9 @@ public class TractionAop {
|
||||
*
|
||||
* 将获取到的连接 放到缓存中
|
||||
*
|
||||
* @param args canshu
|
||||
* @param aopModel aop对象
|
||||
*/
|
||||
public void startMethod(Object[] args, AopModel aopModel) {
|
||||
public void startMethod(AopModel aopModel) {
|
||||
try {
|
||||
|
||||
Map<String, DruidDataSource> maps = (Map<String,DruidDataSource>) marsSpace.getAttr(MarsConstant.DATA_SOURCE_MAP);
|
||||
@@ -52,10 +52,9 @@ public class TractionAop {
|
||||
|
||||
/**
|
||||
* 从缓存中获取当前线程的数据库连接,并提交事务
|
||||
*
|
||||
* @param args canshu
|
||||
*
|
||||
*/
|
||||
public void endMethod(Object[] args) {
|
||||
public void endMethod() {
|
||||
try {
|
||||
Map<String,Connection> connections = (Map<String,Connection>) ThreadUtil.getThreadLocal().get();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user