2017-10-23 7 views
0

MVC를 사용하여 AOP에서 인터셉트 된 메소드 호출자를 좀 더 구체적으로 표시 할 수있는 방법이 있습니까? 나는 "method()"라는 도청 된 메서드를 호출하는 "callerM1()"과 "callerM2()"라는 두 가지 메서드가 있습니다.AOP에서 인터셉트 된 메소드의 호출자 얻기

@Before("execution(* *.method(..)) && args(arg1)") 
public Object doSomething(...){ 
    //find out which one and do something 
} 

은 어떻게 배울 수있다 "callerM1()"또는 어떤에만 스프링 AOP 기능을 사용하여 "메소드() '라고했다"callerM2() ": 그럼이 같은 측면을 가지고? 여기에서는 Around advice도 사용할 수 있지만 다른 문제라고 생각합니다. 나는 EnclosingStaticPart를 포함하여 다양한 가능성을 점검하고 성공없이 pointcut 정의를 변경했다.

빠른 해결책은 StackTraceElement를 사용하고 있었지만 좋지 않다고 생각합니다.

답변

0

솔루션은 here으로 제공되며, 스프링 - 솝뿐만 아니라 전체 aspectj를 필요로합니다.

@Aspect 
public class TestAspect { 

    @Around("call(void com.spring.ioc.Aggregated.*(..))") 
    public Object advice(ProceedingJoinPoint joinPoint) throws Throwable { 
     System.out.println("xxxxxxxxxxxx: TestAspect.advice(): aspect is called on " + joinPoint 
      + ". This object: " + joinPoint.getThis()); 
     return joinPoint.proceed(); 
    } 
}