[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[List Home]
|
Re: [aspectj-users] Match all method calls with a specific parameter type at any position
|
- From: Andy Clement <andrew.clement@xxxxxxxxx>
- Date: Wed, 10 Jun 2009 09:30:34 -0700
- Delivered-to: aspectj-users@eclipse.org
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=dzlJw+rCOl8/5BwAKesiI9DK/8gWJoAuNJmCCcvfMCE=; b=cLtbUpsX16RNx8HtLVQCQd7GPjVzB5woyzav4dmuNM5ZIlFIcSNnZDSmxFnjM/Yv+h zYx992YV4ZRgHi/MSGC0E3ASeoMLwcXG3vqUtJR+LHH8rvo9tpcX80CEyIhrYl5YLMLG 8efiWxBkzbfqbpp/n+JZ+aNVzqM7gP90GKCH0=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=HhQjwZzReGAjrdE2/DBIzshF+ezDlEuOisdcnosaYfmAvvMh7axaXyuUdGfF5WJGmr OI50OqcXPnOijSG5aAiAQw1jR74X0vHGktOGhy1j1oztFRhdbyfDepx9aHWUYGOzETHK 8jYVW/w10ElTYYl1KqFGjQ+HjiH6pr0XehhhQ=
If you want to use args directly for binding, the normal (not all that
pretty) solution right now is:
pointcut havingAConnectionParameter1(Connection conn): call(* *(..))
&& args(conn,..);
pointcut havingAConnectionParameter2(Connection conn): call(* *(..))
&& args(*,conn,.. );
pointcut havingAConnectionParameter3(Connection conn): call(* *(..))
&& args(*,*,conn,.. );
pointcut havingAConnectionParameter4(Connection conn): call(* *(..))
&& args(*,*,*,conn,.. );
pointcut havingAConnectionParameter5(Connection conn): call(* *(..))
&& args(*,*,*,conn,.. );
pointcut havingAConnectionParameter6(Connection conn): call(* *(..))
&& args(*,*,*,*,conn,.. );
obviously you need as many variants as the max number of arguments,
but more than 6/7 arguments then I think the code you are advising has
other problems ;)
there are open enhancement requests relating to this.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=160509
https://bugs.eclipse.org/bugs/show_bug.cgi?id=233718
The second one is interesting as it discusses a lot of possible syntaxes.
cheers,
Andy.
2009/6/10 Tahir Akhtar <tahir@xxxxxxxxxxxxxxxxxxx>:
> 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@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>