[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] Execution and Call pointcuts
|
Ramnivas is right. And for information on the referent of
this, target, and args in each join point, see the AspectJ
Programming Guide Semantics appendix section on Join
Points:
http://www.eclipse.org/aspectj/doc/released/progguide/semantics-joinPoints.html
Wes
On Tue, 14 Mar 2006 07:52:35 -0800
Ramnivas Laddad <ramnivas@xxxxxxxxxxxxxxx> wrote:
> The problem is the target() pointcut. Since you are
> matching a call join point, the target will be the object
> on which the method is invoked -- accMgr in your case.
> However, the type of "s" in advice declaration is
> MoneyTransfer. So the target() is restricting the
> selected join points to where the target object is of
> MoneyTransfer.
>
> The following pointcut fixes that:
>
> pointcut withdrawBefore(MoneyTransfer s, String acc):
> withincode(public void MoneyTransfer.transfer(String))
> &&
> call(public void AccountManager.withdraw(String))
> &&
> this(s) && args(acc);
>
> -Ramnivas
>
> simmonds wrote:
> > Hi Everyone,
> >
> > I want to pick out a join point that includes a call to
> an operation from
> > within another operation. The "withincode" join point
> works fine by itself,
> > but once I add the "call" statement it no longer works.
> What am I doing wrong?
> >
> > public privileged aspect MoneyTransferAspect {
> >
> > pointcut withdrawBefore(MoneyTransfer s, String acc):
> > withincode(public void
> MoneyTransfer.transfer(String)) &&
> > call(public void AccountManager.withdraw(String))
> &&
> > target(s) && args(acc);
> >
> > before (MoneyTransfer s, String acc):
> withdrawBefore(s,acc) {
> >
> > try {
> >
> > System.out.println("before" + acc);
> > } catch( Exception e ) { e.printStackTrace(); }
> > }
> > }
> >
> > public class MoneyTransfer {
> >
> > AccountManager accMngr=new AccountManager();
> >
> > public void transfer (String acc)
> > {
> > accMngr.withdraw(acc);
> > System.out.println( "MTS: " + acc );
> > }
> > }
> >
> > _______________________________________________
> > aspectj-users mailing list
> > aspectj-users@xxxxxxxxxxx
> > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> >
> >
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users