Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AspectJ » multiple formal parameters?
multiple formal parameters? [message #34081] Fri, 16 April 2004 10:16 Go to next message
Michael Moser is currently offline Michael MoserFriend
Messages: 914
Registered: July 2009
Senior Member
I am frustrated - I don't get it!

I want to specify an advice that has TWO parameters and I need access
to BOTH parameters in the advice.

I was able to phrase that as an "anonymous" pointcut (I think that's
the name for something like this):
....
before(IEvent evt, boolean flag): target(evt) && call(*
IEvent.setHandled(boolean)) && args(flag) {
...
}
....

But now I would like to specify this as a NAMED pointcut (1st to make
this more readable and 2nd to reuse the pointcut in more than one
advice):

I defined the pointcut:
....
pointcut eventSetHandled(IEvent evt, boolean flag): target(evt) &&
call(* IEvent.setHandled(boolean)) && args(flag);

And now I want to specify the advice. But how do I phrase this? I
tried:

before(IEvent evt, boolean flag): eventSetHandled(IEvent, boolean)
{ ... }
before(IEvent evt, boolean flag): eventSetHandled(IEvent evt,
boolean flag) { ... }
before(IEvent evt, boolean flag): eventSetHandled(evt, flag) {
.... }
???

None of the above work, i.e. all variants just yield compile errors!
How do I phrase this? What do I need to specify to get hold of more
than a single parameter of a named pointcut??? Or is this not possible
at all?

Alas, all the examples given in the AspectJ manual only show a single
parameter...

Michael
Re: multiple formal parameters? [message #34150 is a reply to message #34081] Fri, 16 April 2004 12:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: clemas.uk.ibm.com

Hi,

What you want to do is possible. The third variant you quote below works.

i.e. this works for me:

pointcut eventSetHandled(IEvent evt,boolean flag):
target(evt) &&
call(* IEvent.setHandled(boolean)) &&
args(flag);

before(IEvent evt, boolean flag): eventSetHandled(evt,flag) {
System.err.println("In advice! evt="+evt+" flag="+flag);
}


And I'd probably drop the type reference in the call() PCD since you are
using target(). If you want other examples of multiple parameters, take a
look at the Enterprise AOP tutorial presentation downloadable from

http://www.newaspects.com/presentations

Andy.

Michael Moser wrote:

> I am frustrated - I don't get it!

> I want to specify an advice that has TWO parameters and I need access
> to BOTH parameters in the advice.

> I was able to phrase that as an "anonymous" pointcut (I think that's
> the name for something like this):
> ....
> before(IEvent evt, boolean flag): target(evt) && call(*
> IEvent.setHandled(boolean)) && args(flag) {
> ...
> }
> ....

> But now I would like to specify this as a NAMED pointcut (1st to make
> this more readable and 2nd to reuse the pointcut in more than one
> advice):

> I defined the pointcut:
> ....
> pointcut eventSetHandled(IEvent evt, boolean flag): target(evt) &&
> call(* IEvent.setHandled(boolean)) && args(flag);

> And now I want to specify the advice. But how do I phrase this? I
> tried:

> before(IEvent evt, boolean flag): eventSetHandled(IEvent, boolean)
> { ... }
> before(IEvent evt, boolean flag): eventSetHandled(IEvent evt,
> boolean flag) { ... }
> before(IEvent evt, boolean flag): eventSetHandled(evt, flag) {
> .... }
> ???

> None of the above work, i.e. all variants just yield compile errors!
> How do I phrase this? What do I need to specify to get hold of more
> than a single parameter of a named pointcut??? Or is this not possible
> at all?

> Alas, all the examples given in the AspectJ manual only show a single
> parameter...

> Michael
Re: multiple formal parameters? [message #34183 is a reply to message #34150] Fri, 16 April 2004 13:09 Go to previous message
Michael Moser is currently offline Michael MoserFriend
Messages: 914
Registered: July 2009
Senior Member
Indeed - the third variant works.In fact I got this compiled just
before I saw your append, so I seem to get a first "feeling" for this
somewhat strange syntax. But why it didn't compile before remains
beyond me.

Anyway - thanks a lot! I highly appreciate your help!
And thanks for the link, too! Already on the way to the printer...

Michael

PS.: I'm still puzzled about this exception example - see my other
thread...

"Andy Clement" <clemas@uk.ibm.com> wrote in message
news:c5oili$1ja$1@eclipse.org...
> Hi,
>
> What you want to do is possible. The third variant you quote below
works.
>
> i.e. this works for me:
>
> pointcut eventSetHandled(IEvent evt,boolean flag):
> target(evt) &&
> call(* IEvent.setHandled(boolean)) &&
> args(flag);
>
> before(IEvent evt, boolean flag): eventSetHandled(evt,flag) {
> System.err.println("In advice! evt="+evt+" flag="+flag);
> }
>
>
> And I'd probably drop the type reference in the call() PCD since you
are
> using target(). If you want other examples of multiple parameters,
take a
> look at the Enterprise AOP tutorial presentation downloadable from
>
> http://www.newaspects.com/presentations
>
> Andy.
>
> Michael Moser wrote:
>
> > I am frustrated - I don't get it!
>
> > I want to specify an advice that has TWO parameters and I need
access
> > to BOTH parameters in the advice.
>
> > I was able to phrase that as an "anonymous" pointcut (I think
that's
> > the name for something like this):
> > ....
> > before(IEvent evt, boolean flag): target(evt) && call(*
> > IEvent.setHandled(boolean)) && args(flag) {
> > ...
> > }
> > ....
>
> > But now I would like to specify this as a NAMED pointcut (1st to
make
> > this more readable and 2nd to reuse the pointcut in more than one
> > advice):
>
> > I defined the pointcut:
> > ....
> > pointcut eventSetHandled(IEvent evt, boolean flag): target(evt) &&
> > call(* IEvent.setHandled(boolean)) && args(flag);
>
> > And now I want to specify the advice. But how do I phrase this? I
> > tried:
>
> > before(IEvent evt, boolean flag): eventSetHandled(IEvent,
boolean)
> > { ... }
> > before(IEvent evt, boolean flag): eventSetHandled(IEvent evt,
> > boolean flag) { ... }
> > before(IEvent evt, boolean flag): eventSetHandled(evt, flag) {
> > .... }
> > ???
>
> > None of the above work, i.e. all variants just yield compile
errors!
> > How do I phrase this? What do I need to specify to get hold of
more
> > than a single parameter of a named pointcut??? Or is this not
possible
> > at all?
>
> > Alas, all the examples given in the AspectJ manual only show a
single
> > parameter...
>
> > Michael
>
>
Re: multiple formal parameters? [message #578484 is a reply to message #34081] Fri, 16 April 2004 12:13 Go to previous message
Andrew Clement is currently offline Andrew ClementFriend
Messages: 162
Registered: July 2009
Senior Member
Hi,

What you want to do is possible. The third variant you quote below works.

i.e. this works for me:

pointcut eventSetHandled(IEvent evt,boolean flag):
target(evt) &&
call(* IEvent.setHandled(boolean)) &&
args(flag);

before(IEvent evt, boolean flag): eventSetHandled(evt,flag) {
System.err.println("In advice! evt="+evt+" flag="+flag);
}


And I'd probably drop the type reference in the call() PCD since you are
using target(). If you want other examples of multiple parameters, take a
look at the Enterprise AOP tutorial presentation downloadable from

http://www.newaspects.com/presentations

Andy.

Michael Moser wrote:

> I am frustrated - I don't get it!

> I want to specify an advice that has TWO parameters and I need access
> to BOTH parameters in the advice.

> I was able to phrase that as an "anonymous" pointcut (I think that's
> the name for something like this):
> ....
> before(IEvent evt, boolean flag): target(evt) && call(*
> IEvent.setHandled(boolean)) && args(flag) {
> ...
> }
> ....

> But now I would like to specify this as a NAMED pointcut (1st to make
> this more readable and 2nd to reuse the pointcut in more than one
> advice):

> I defined the pointcut:
> ....
> pointcut eventSetHandled(IEvent evt, boolean flag): target(evt) &&
> call(* IEvent.setHandled(boolean)) && args(flag);

> And now I want to specify the advice. But how do I phrase this? I
> tried:

> before(IEvent evt, boolean flag): eventSetHandled(IEvent, boolean)
> { ... }
> before(IEvent evt, boolean flag): eventSetHandled(IEvent evt,
> boolean flag) { ... }
> before(IEvent evt, boolean flag): eventSetHandled(evt, flag) {
> .... }
> ???

> None of the above work, i.e. all variants just yield compile errors!
> How do I phrase this? What do I need to specify to get hold of more
> than a single parameter of a named pointcut??? Or is this not possible
> at all?

> Alas, all the examples given in the AspectJ manual only show a single
> parameter...

> Michael
Re: multiple formal parameters? [message #578506 is a reply to message #34150] Fri, 16 April 2004 13:09 Go to previous message
Michael Moser is currently offline Michael MoserFriend
Messages: 914
Registered: July 2009
Senior Member
Indeed - the third variant works.In fact I got this compiled just
before I saw your append, so I seem to get a first "feeling" for this
somewhat strange syntax. But why it didn't compile before remains
beyond me.

Anyway - thanks a lot! I highly appreciate your help!
And thanks for the link, too! Already on the way to the printer...

Michael

PS.: I'm still puzzled about this exception example - see my other
thread...

"Andy Clement" <clemas@uk.ibm.com> wrote in message
news:c5oili$1ja$1@eclipse.org...
> Hi,
>
> What you want to do is possible. The third variant you quote below
works.
>
> i.e. this works for me:
>
> pointcut eventSetHandled(IEvent evt,boolean flag):
> target(evt) &&
> call(* IEvent.setHandled(boolean)) &&
> args(flag);
>
> before(IEvent evt, boolean flag): eventSetHandled(evt,flag) {
> System.err.println("In advice! evt="+evt+" flag="+flag);
> }
>
>
> And I'd probably drop the type reference in the call() PCD since you
are
> using target(). If you want other examples of multiple parameters,
take a
> look at the Enterprise AOP tutorial presentation downloadable from
>
> http://www.newaspects.com/presentations
>
> Andy.
>
> Michael Moser wrote:
>
> > I am frustrated - I don't get it!
>
> > I want to specify an advice that has TWO parameters and I need
access
> > to BOTH parameters in the advice.
>
> > I was able to phrase that as an "anonymous" pointcut (I think
that's
> > the name for something like this):
> > ....
> > before(IEvent evt, boolean flag): target(evt) && call(*
> > IEvent.setHandled(boolean)) && args(flag) {
> > ...
> > }
> > ....
>
> > But now I would like to specify this as a NAMED pointcut (1st to
make
> > this more readable and 2nd to reuse the pointcut in more than one
> > advice):
>
> > I defined the pointcut:
> > ....
> > pointcut eventSetHandled(IEvent evt, boolean flag): target(evt) &&
> > call(* IEvent.setHandled(boolean)) && args(flag);
>
> > And now I want to specify the advice. But how do I phrase this? I
> > tried:
>
> > before(IEvent evt, boolean flag): eventSetHandled(IEvent,
boolean)
> > { ... }
> > before(IEvent evt, boolean flag): eventSetHandled(IEvent evt,
> > boolean flag) { ... }
> > before(IEvent evt, boolean flag): eventSetHandled(evt, flag) {
> > .... }
> > ???
>
> > None of the above work, i.e. all variants just yield compile
errors!
> > How do I phrase this? What do I need to specify to get hold of
more
> > than a single parameter of a named pointcut??? Or is this not
possible
> > at all?
>
> > Alas, all the examples given in the AspectJ manual only show a
single
> > parameter...
>
> > Michael
>
>
Previous Topic:multiple formal parameters?
Next Topic:Framework for supporting java based languages in eclipse?
Goto Forum:
  


Current Time: Tue Mar 19 08:06:35 GMT 2024

Powered by FUDForum. Page generated in 0.02138 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top