AspectJ: parameter binding with 'args()' for methods with multiple parameters
I am having some trouble creating a before
aspect for a method that has multiple parameters.
public class Sample {
public boolean myCall(String s, String s1, String s3, ByteBuffer bytes, int i, int g) {
System.out.println("Calling real sample");
}
}
This aspect does not match. I only need to use the ByteBuffer parameter in the override code.
pointcut sampleCall(ByteBuffer bytes) :
execution(b开发者_如何学Pythonoolean com.example.Sample.myCall (..)) && args(bytes);
before(ByteBuffer bytes) : sampleCall(bytes) {
System.out.println("Before sample");
}
Actually finally got it to work with
pointcut sampleCall(ByteBuffer bytes) :
execution(boolean com.example.Sample.myCall(String, String, String, ByteBuffer, ..))
&& args(String, String, String, bytes, ..);
before(ByteBuffer bytes) : sampleCall(bytes) {
System.out.println("Before sample");
}
精彩评论