Aspect的写法

@Aspect
public class MyAspect {
 
//对应的方法为 public void haha(String name){...}
 @Before("execution(* com.wjh.business.MyBusiness.haha(..)) &&"+"args(name)")
 public void beforeServicePointcut5(String name) {
         .........
 }
 
// 对应的调法
// @MyAnnotation
//public void haha(String name) {...}
@Before("@annotation(com.wjh.annotation.MyAnnotation)")
 public void beforeServicePointcut2() {
  System.out.println("#####666666666666###########");
 }
 
//其他的合法调法
@Before("com.wjh.business.MyBusiness.haha(String)")
 public void beforeServicePointcut33() {
  System.out.println("###00000000002#########");
 }
 
 @Before("execution(* com.wjh.business.MyBusiness.haha())")
 public void beforeServicePointcut4() {
  System.out.println("########3333333333####");
 }
@Pointcut("execution(* com.wjh.business.MyBusiness.haha())")
 public void servicePointcut() {
 }
 @Before(value = "servicePointcut()")
 public void beforeServicePointcut6() {
  System.out.println("###11111111111#########");
 }
 
}



你可能感兴趣的:(Aspect的写法)