I want to have a JAR with an aspect that intercepts all method calls, e.g.
@Aspect
public class CoolAspect {
@Pointcut("execution(public * *(..))")
public void anyPublicMethod() { }
@Before("anyPublicMethod()")
public void advice(JoinPoint point) {
System.out.println("sign:\t" + point.getSignature());
}
}
Suppose the above is the aspect I have and want clients to use. I compile it to a JAR and make available to Maven.
Now the clients would use this jar as a dependency, e.g.
<dependency>
<groupId>cool-group</groupId>
<artifactId>cool-artifact</artifactId>
<version>1.0.0</version>
</dependency>
This artifact (JAR) has the mentioned aspect.
Now is it possible for the aspect work by just declaring a Maven dependency?
Few things that might be important:
- I plan to use AspectJ (perhaps Spring AOP, if necessary),
- The clients will probably be web applications with normal
web.xml
etc. - Clients are built with Maven
- I want the Clients to be as easy to configure as possible - in my original idea a Maven dependency would be enough.
- The "Annotation JAR" will contain a web-fragment, so it's possible to declare some custom
ServletContextListener
there..
Any ideas?