I am trying to do the following:
I have a server with the following structure.
bin
apis
services
etc ...
I want to define an API that contains an aspect that will be used by services. Say:
@Aspect public class AuthorizationAspect { @Pointcut("call(* *()) && @annotation(Authorization)") public void cutAuthorize() { } @Before("cutAuthorize()") public void callFromAuthorizeBefore() { System.out.println("Test"); } }
Then I define the service and comment on the methods I want with @Authorization, and it gets a pointcut on this aspect.
Things you should know:
- Services use the API only to compile code, so the scope is "provided" since the API will already be on the server.
- JAR services load dynamically, so they will be in another class loader.
My question is: how can I do this? How to identify my maven artifacts for this?
I noticed that the aspectj plugin has a weaveDependencies section, but it will also include all classes in this API in the service JAR (something I want to avoid). Is it correct?
Thanks in advance,
Rui
source share