I am currently working on a REST API that will be using the Spring framework. My team is looking into using some AOP for the purpose of maintaining cross-cutting concerns.
I have had success with Spring AOP, but later realized that it may not be powerful enough to handle things that I would like to do.
I have been trying to get AspectJ integrated into our Spring application, but have had little success. The spring documentation does not seem to be fully fleshed out and Google searches have been tough because articles often mix-up Spring AOP and AspectJ integrated in Spring.
I was wondering if there are some tips, pointers or walk-throughs that use AspectJ in the Spring Framework.
The problem that I am trying to solve is that I would like to set a variable on an class when another setter is called. Spring AOP fails to be able to do this because it is proxy based and can only proxy beans it controls. The setters that I am calling are model class and will not be beans handled by Spring.
I have decided to switch to the aspectj-maven compile plugin, but I am getting the following error when I turned on verbose:
"can not build thisJoinPoint lazily for this advice since it has no suitable guard [Xlint:noGuardForLazyTjp]"
This is my current aspect
public aspect SkynetServiceAspect1 {
@Before("execution(* com.company.application.service.ServiceImpl..*(..))")
public void loggingLoggerGuy(JoinPoint jp) {
Object[] oArray = jp.getArgs();
System.out.println("***************************************************************************************************************");
System.out.println("I am this method: "+ jp.getSignature().getName() + "with the following arguments" + oArray.toString()+"!");
}
}
This is the error I receive upon running a maven clean install
[INFO] Showing AJC message detail for messages of types: [error, warning, fail]
[WARNING] can not build thisJoinPoint lazily for this advice since it has no suitable guard [Xlint:noGuardForLazyTjp]
C:\workspaces\Newport-1\OAuthPOCAOP\target\classes!com\company\application\aspect\SkynetServiceAspect1.class:18
[WARNING] advice defined in com.company.application.aspect.SkynetServiceAspect1 has not been applied [Xlint:adviceDidNotMatch]
C:\workspaces\Newport-1\OAuthPOCAOP\target\classes!com\company\application\aspect\SkynetServiceAspect1.class:18
Any help would be greatly appreciated, thanks.