« Return to Thread: Match all method calls with a specific parameter type at any position

Re: Match all method calls with a specific parameter type at any position

by Tahir Akhtar :: Rate this Message:

Reply to Author | View in Thread

One somewhat limited solution I see is to use an annotation on the
methods with thisJoinPoint.getArgs().

Tahir Akhtar wrote:

> Hi,
> Is there a way to declare a pointcut that matches all method calls
> whose any parameter is of specific type (say java.sql.Connection).
>
> I see that following will match methods whose last (or only) parameter
> is of type Connection.
>
> pointcut havingAConnectionParameter(Connection conn): call(* *(..)) &&
> args(..,conn );
>
> And following will match methods whose first (or only) parameter is of
> type Connection.
>
> pointcut havingAConnectionParameter(Connection conn): call(* *(..)) &&
> args(conn, .. );
>
> But how can I match when I don't know the exact position or even
> number of parameters in advance?
>
>
> Regards
> Tahir Akhtar
>
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@...
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>

_______________________________________________
aspectj-users mailing list
aspectj-users@...
https://dev.eclipse.org/mailman/listinfo/aspectj-users

 « Return to Thread: Match all method calls with a specific parameter type at any position