I made an aspect to my application but I'm thinking that this isn't the best way to do that.
--> The target is the IMPLEMENTATION class.
expression="execution(public * service.impl.*.update(..)) or execution(public void service.impl.*.save(..))" />
<!-- "uniqueConstraintLogicalCheckInterceptor" is a bean that implements MethodInterceptor ->
In few lines, the Aspect is working well and I tested it with the 2 methods, without them and with one or another, but I think that something is going wrong.
I put a "System.out.println("Specialized method not found, proceeding to the super() method.")" (debug only), because sometimes the methodInvocation.getMethod() throwed NoSuchMethodException and I think that it was because the child class hasn't an implementation (but the super class always has a generic implementation).
What happen is that the message of the SYSOUT just appears when there's no SAVE method, not for the UPDATE method... And I repeat, even this way, the aspect is being executed.
What's going wrong? Why the SYSOUT appears just in the SAVE and not in the UPDATE??
Help, please! I want to understand why.
==> Additional information:
- I figured out that the child class implements a super abstract class B that implements an abstract class A (in other words, Target extends B that extends A);
- For some reason, the method that is not intercepted if has no child implementation (the UPDATE method, in this case) just has implementation in the super "A" class (the "most" super). Otherwise, the SAVE method is implemented 2 times: in the classes A and B (I don't know why because they aren't mine).
The problem is solved. For education reasons, I'll put an image here that describes the problem.