I have the following issue with AspectJ. My java web application includes multiple dependencies which uses aspects (contain their own META-INF/aop.xml inside jars). Here is an example of aop.xml:
<aspectj>
<weaver>
<include within="package..*"/>
</weaver>
<aspects>
<aspect name="package.LoggingAspect" />
</aspects>
</aspectj>
And here is the code of the aspect:
@Aspect
public class LoggingAspect {
@Around("executeMethod() && @annotation(someAnnotation)")
public Object execute(ProceedingJoinPoint joinPoint, SomeAnnotation a) throws Throwable {
//some logic here
}
@Pointcut("execution(* *..*.*(..))")
public void executeMethod() {
}
}
In my application I need to override the logic under the given advice. How can I achive this? I tried to provide my own aspect with the same advice (same conditions), but in this case both aspects are applied. Is there any way to exclude unnecessary aspect/advice or override it?
UPD. As temporary solution I copied the code of LoggingAspect to my own, changed the logic of the advide and provided aop.xml with the following:
<aspects>
<aspect name="package.MyLoggingAspect"/>
<exclude within="package.LoggingAspect"/>
</aspects>