I'm trying to get AOP to work on a JAX-RS service. It is working on Spring-injected objects, but not my JAX-RS services. My assumption is that it's not working because Jersey creates my JAX-RS objects, rather than Spring. How can I get AOP to work on my JAX-RS services?
Here's how I declare my aspects:
@Pointcut("execution (* com.ancestry.academy.api.user.UserService.*(..))")
public void apiMethods() {}
@Around("com.ancestry.academy.api.ApiAdvisor.apiMethods()")
public Object aroundApi(ProceedingJoinPoint pjp) throws Throwable
{
System.out.println("User Service API called");
return pjp.proceed();
}
@Pointcut("execution (* com.ancestry.academy.services.user.UserManagerImpl.*(..))")
public void serviceMethods() {}
@Around("com.ancestry.academy.api.ApiAdvisor.serviceMethods()")
public Object aroundService(ProceedingJoinPoint pjp) throws Throwable
{
System.out.println("User Maanageer API called");
return pjp.proceed();
}
The first aspect is on my JAX-RS service, and is the one that doesn't work. The second aspect is on a spring-injected bean that provides business logic, and it does work.
There's nothing particularly special about UserService, except that it extends SpringBeanAutowiringSupport.
I have <aop:aspectj-autoproxy/>
in my spring XML file.