I'd like to define a pointcut where the only important point is that the amount of parameters of the target method. For example, I have the following pointcut definition;
@Pointcut("@annotation(org.springframework.web.bind.annotation.RequestMapping)
&& execution(* pkg..*.*(pkg.Obj1, pkg.Obj2, pkg.Obj3))")
I do not wish to hardcode the expected parameter types, but I only wish to get the methods with only three parameters for this pointcut. How do I achieve this with only the information that there should be three parameters for the above pointcut, without specifying the details of parameters?
For example I want it to match;
// in package pkg.*
@RequestMapping
public test(ObjX objX, ObjY objY, ObjZ objZ) {
//etc
}
but not match the following;
// also in package pkg.*
@RequestMapping
public test(ObjX obj) {
//etc
}
or
// also in package pkg.*
@RequestMapping
public test(ObjX objX, ObjY objY) {
//etc
}
or
// also in package pkg.*
@RequestMapping
public test(ObjX objX, ObjY objY, ObjZ objZ, ObjQ objQ) {
//etc
}
I've found it, the way to achieve this is to give *
as the parameters;
@Pointcut("@annotation(org.springframework.web.bind.annotation.RequestMapping)
&& execution(* xxx.yyy.zzz..*.*(*, *, *))")
With the similar usage of *
for return type, other class & method names.