I am trying to define a pointcut whose advice will run when method from a Spring Data JPA repository is invoked.
Here is my anonymous pointcut together with the inline advice (from PliEventManagerAspect):
after(Pli pli) returning: (execution(* org.springframework.data.repository.CrudRepository+.save(Pli)) && args(pli)){
System.out.println("Caught!!!!");
}
Here the definition for my PliRepository:
public interface PliRepository extends GlobalRepository<Pli, Long>, PliRepositoryCustom {
and PliRepositoryImpl:
public class PliRepositoryImpl extends QueryDslRepositorySupport implements PliRepositoryCustom {
and PliRepositoryCustom:
public interface PliRepositoryCustom {
and lastly GlobalRepository:
@NoRepositoryBean
public interface GlobalRepository<T, ID extends Serializable> extends JpaRepository<T, ID> {
I have also set the javaagent command line arg. And I have the following aop.xml:
<!DOCTYPE aspectj PUBLIC
"-//AspectJ//DTD//EN"
"http://www.eclipse.org/aspectj/dtd/aspectj.dtd">
<aspectj>
<weaver options="-verbose">
<include within="org.springframework.data.repository..*"/>
</weaver>
<aspects>
<aspect name="trc.suivi.aspects.PliEventManagerAspect" />
</aspects>
</aspectj>
The above advice, which is supposed to run in LTW since it is advising a class in a jar, is not run at all… I am sure I must make some mistake in the pointcut definition. Can anyone please help?
I changed to the following configuration:
aop.xml:
Thus the weaver scans all classes.
And PliEventManagerAspect.aj:
It now works (thanks to Marten from Spring Forums).