Is there any way for using an annotation for running a function before currently called function, something like this:
public void doSomethingEarlier() {
}
@DoSomethingEarlier
public void doSomething() {
}
So I want to call doSomethin() function, and before executing this function I want to automatically run doSomethingEarlier() function.
You have a number of ways, which are a bit difficult to implement:
Proxywhere you can parse the annotation on the target method and invoke a method with the same nameThe first approach is more straightforward. It would probably be better to have the annotation look something like:
In general, this is how AOP works on the low level.