I have several implementations of SomeInterface. The question is what is the pointcut for the method executeSomething in all implementation of SomeInterface.
public class SomeImplementation implements SomeInterface {
public String executeSomething(String parameter) {
// Do something
}
}
public class AnotherImplementation implements SomeInterface {
public String executeSomething(String parameter) {
// Do something different way
}
}
Pointcuts for that method can be either method-execution or method-call pointcuts. The most specific pointcuts for your requirement would look like this:
execution(public String SomeInterface+.executeSomething(String))
call(public String SomeInterface+.executeSomething(String))
Some explanation on these pointcut types:
String
that are defined in SomeInterface
or any subtype of it, being named executeSomething
and accepting a single String
argument. This is the most specific type pattern that can be defined for your case and it will match only implementations of the String SomeInterface.executeSomething(String)
method.Execution type pointcuts are used more often, but call type pointcuts are very useful too in some cases.
See The AspectJ Language/Join Points and Pointcuts chapter in the AspectJ Programming Guide for further reference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With