3

I am having some strange problems using spring and Load-Time-Weaving using AspectJ. In one of my Apsects, I wanted to react on invocations of the "doAuthentication" Method of the class org.springframework.flex.security3.SpringSecurityLoginCommand. Therefore I created a method:

@Around("execution(* org.springframework.flex.security3.SpringSecurityLoginCommand.doAuthentication(..))")
public Object aroundDoAuthentication(ProceedingJoinPoint pjp) throws Throwable {
...

This aspect is woven correctly if I use the aspectj-weaver agent, but is ignored if I use the spring-weaver. Unfortunately I have to use the spring-weaver, if I want correct aspect-spring integration. The only way I found out to get my aspect woven is to weave it around every method of the target class and to programatically filter the aspect calls:

@Around("execution(* org.springframework.flex.security3.SpringSecurityLoginCommand.*(..))")
public Object aroundDoAuthentication(ProceedingJoinPoint pjp) throws Throwable {
    final String methodName = pjp.getSignature().getName();
    if("doAuthentication".equals(methodName)) {
    ...

Using the above code, I managed to weave everythgin correctly, but I am not sattisfied with this as it seems to be a big hack to me.

Could anyone please explain why using the Spring-Weaver I am not able to weave the same as with the aspectj-weaver?

Chris

Christofer Dutz
  • 2,305
  • 1
  • 23
  • 34

1 Answers1

0

I don't know the code, but this seams to be the same old question.

Spring AOP is per default proxy based.

This means only invocations of methods that come from outside of the bean go though the proxy. Therefore only this invocation can trigger the AOP advice.

Ralph
  • 118,862
  • 56
  • 287
  • 383