I have a JAX-RS resource that uses Jersey's own @Inject annotation to inject a transactional Spring service bean. Injection works, and the service works.
I want to create an aspect for logging. I wrote one, and was able to get it to work if I make the pointcut refer to the transactional Spring service bean, but I can't get it to execute when the pointcut points to the JAX-RS resource.
My XML config looks like this:
On the JAX-RS resource class I added a couple annotations to make sure the class is managed by the Spring container:
<bean id="restLogAspect" class="com.company.product.service.rest.resource.RESTServiceLogAspect"/>
<aop:pointcut id="loggingPointcut" expression="within(com.company.product.service.rest.MyResource)" />
<aop:aspect id="loggingAspect" ref="restLogAspect">
<aop:around pointcut-ref="loggingPointcut" method="aroundInvoke"/>
My XML config also includes:
I suspect the problem is one of two things:
1) JAX-RS/Jersey is not getting the resource instance from Spring container
2) My pointcut needs to change