Commit 1ae0a4d4 by pengbin

aop

parent 1ccd91e8
...@@ -2,6 +2,7 @@ package com.saraad.common.aop; ...@@ -2,6 +2,7 @@ package com.saraad.common.aop;
import org.aspectj.lang.JoinPoint; import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.Signature; import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before; import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut; import org.aspectj.lang.annotation.Pointcut;
...@@ -41,4 +42,16 @@ public class ServiceLog { ...@@ -41,4 +42,16 @@ public class ServiceLog {
System.out.println("正在执行:"+target.getClass().getName()+"_"+method.getName()); System.out.println("正在执行:"+target.getClass().getName()+"_"+method.getName());
} }
@After("log()")
public void doAfter(JoinPoint joinPoint){
Object target = joinPoint.getTarget();
Signature signature = joinPoint.getSignature();
if(!(signature instanceof MethodSignature))
throw new IllegalArgumentException("非实现类方法");
MethodSignature ms = (MethodSignature) signature;
Method method = ms.getMethod();
System.out.println(target.getClass().getName()+"_"+method.getName()+"执行完毕");
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment