I want to enable AWS X-Ray for all my Repositories without annotating every controller with @XRayEnabled
. Therefore I am locking for a pointcut expression.
What I got so far from the cheat sheet is that I can get all classes with the @Repository
annotation with
@within(org.springframework.stereotype.Repository)
and all classes with a specialization of @Repository
with within(@(@org.springframework.stereotype.Controller *) *)
.
The problem I have is that my code structure looks as follows:
@NoRepositoryBean
public interface JpaRepository<T, ID> extends PagingAndSortingRepository<T, ID>, QueryByExampleExecutor<T> {
// default repository from org.springframework.data.jpa.repository package
}
@NoRepositoryBean
public interface BaseRepository<T, ID> extends JpaRepository<T, ID> {
void baseMethod() {
...
}
}
@Repository
public interface Repository1 extends BaseRepository<Entity1> {
public void method1() {
...
}
}
@MyRepository // specialization of the @Repository annotation
public interface Repository2 extends BaseRepository<Entity2> {
public void method2() {
...
}
}
As you can see I am having a multilevel inheritance here. If I combine the two pointcuts mentioned above with ||
, it works for method1()
and method2()
, but baseMethod()
or all methods of the JpaRepository
are ignored. Of course I could do the same with the @NoRepositoryBean
annotation, but that is not good practice, as I want to do something similar with @Service
annotations which have base classes without annotations.
If I add the @XRayEnabled
annotation to Repository1
or Repository2
, it also works and the calls are visible in X-Ray, but again bad practice.
So I would really appreciate if someone could help me to find a good solution for my problem.