Aspect with Annotation
목적
참고
설정 방법
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface MyAnnotation{
String name() default "";
}Last updated
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface MyAnnotation{
String name() default "";
}Last updated
@Configuration
@EnableAspectJAutoProxy
public class AspectConfiguration {
}@Sl4j
@Aspect
@Component
public class MyAnnotationAdvisor {
@PointCut("@annotation(annotation)")
public void pointCutMyAnnoration(MyAnnotation annotation){};
@Around(value="pointCutMyAnnoration(annotation)")
public Object proceedingJoinPointMyAnnotation(ProceedingJoinPoint joinPoint, MyAnnotation annotation){
log.debug(annotation.toString());
try{
Object object = joinPoint.proceed(args);
} catch (Throwable e) {
log.error("Exception occurred [" + e.getLocalizedMessage() + "]", e);
}
}
}