Thursday, May 2, 2013

AOP Method Signiture Pattern

AOP Method Signiture Patterns
I studied a lot of time to study AOP.
as i studied i feel like master of AOP but as time gone by i forget how to use
and re searching online guide of AOP
so I want summarize about use of AOP
Hope that it would be helpful me and you guys

The first wild card means method type : public, private, protected, *(all)

If AopTest.class exist in different package
execution(* com.sang.hwa.AopTest.*(..)) if AopTest.class exist in same package
all method mapping in AopTest.class
execution(* AopTest.*(..)) //If class name has xxxxController.class it will be mapped execution(public * com.sns.controller..*Controller.*(..)) package com.sns.common.aspect; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * {@link SnsPointDay} 의 point-cut 지정 및 결과 코드 처리를 위한 어노테이션 * */ @Target({ ElementType.METHOD, ElementType.TYPE }) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface SnsPointDay { public String div() default "00"; public String category(); public String item(); public int point() default 1; public String status() default ""; } @Before(@annotation(com.sns.common.aspect.SnsPointDay)) @AfterReturning("@annotation(point)") public void afterControllerWithPoint(JoinPoint jp, SnsPoint point) throws Throwable { } //Annotation Expression //$$(And), ||(or), !(not) @Pointcut("operation() || execution() || @annotation(pointDay)") @Before("execution(* *.*(..)) && target(target) && args(a,b)") public void logParameter(Object target, dobule a, double b){"class : " + taget.getClass().getName());" values : " + a + " , " + b); }

No comments:

Post a Comment