I have a generic method that accepts any type as its parameter.
For example, I would like a pointcut that matches the calls made to the method only with 'String' type as its parameter. Ultimately the requirement is to limit the scope which the advices get executed for to 'String' parameters.
Here is my generic class and method:
public class Param<T> {
public T execute(T s){
return s;
}
}
Main class: My app makes calls to the method with both Boolean and String as parameters.
public static void main(String[] args) {
Param<String> sp = new Param<String>();
String rs = sp.execute("myString"); //want a joint point
Param<Boolean> bp = new Param<Boolean>();
Boolean rb = bp.execute(true); //dont want a joint point
}
Below pointcuts are valid for both String and Boolean parameters (work for any type actually). But I would like a pointcut to intercept method calls only when parameter is of type String.
@Pointcut("call(* com.amazon.auiqa.aspectj.generics.Param.execute(**))")
void param(){}
@Pointcut("execution(Object com.amazon.auiqa.aspectj.generics.Param.execute(Object))")
void param(){}
Below ones did not work for me:
@Pointcut("execution(String com.amazon.auiqa.aspectj.generics.Param.execute(String))")
@Pointcut("call(String com.amazon.auiqa.aspectj.generics.Param.execute(String))")
I was wondering if it is possible to achieve what I want to achieve here. I would like to do the same thing with method return types.