Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Use of wildcards in pointcut designators....

hmm,

I would try something perhaps like (as a first stab):

pointcut outputLog() : call(public * MyClass.f*(..)) || call(protected * MyClass.f*(..));

But something even neater would perhaps be:

pointcut outputLog() : call(* MyClass.f*(..)) && !within(MyClass)

By including the !within then I am basically stating that I am not interested in calls that MyClass makes to itself. Now, if MyClass is making any calls to private methods (as MyClass is the only type that can make these calls in the first place .. apart from privileged aspects :) then they will not be caught but this does have the disadvantage of not capturing any calls that MyClass makes to it's own public and protected methods so it might not be what you are looking for? Really a question for your specific situation.

Oh and Jim, Have a great time in the new Job!

Cheers,

Russ



On 29 Jul 2004, at 15:12, Swati Pradhan wrote:

Hi,

I am still not very clear...
Lets suppose that my class name is MyClass and I want
to match all the private and protected (not public
ones) methods of MyClass. So, how I will define a
pointcut then....

Well, I am using book "Mastering AspectJ" by Joseph
D.Gradecki and Nicholas Lesiecki for reference... and
it says (on page 62-63) that we can define pcd like:

call(* * DVD.*(*)) or
call(* void DVD.*(*)) or
call(* * *.*(*)).

But all of the above give compilation error...

Russell, you say that access types are enumeration so
is there any other way to match them, other than
specifying them in pcd...

Thanks in advance...
Swati


--- Russell Miles <russellmiles@xxxxxxx> wrote:

Hi Swati,

First of all, what's the name of the class that the
methods are on?
Also, you seem to be confusing wildcard behavior on
the components of a
Signature (as the single parameter to a call pcd)
with wildcards on a
String.

If, for example, the class that contained the
methods was MyClass then
the following pcd should work to capture all three
calls:

pointcut outputLog() : call(* MyClass.f*(..));

This doesn't treat the modifier as a string, rather
an enumeration that
we simply are not interested in. Hope this helps :)

AspectJ is at 1.2 and is available for download from

www.eclipse.org/aspectj. This is the usual
distribution with a compile
time weaver as well as some work done on load time
weaving (see older
postings to this list for info on that).

Cheers,

Russ



On 29 Jul 2004, at 12:30, Swati Pradhan wrote:

Hi everybody,

I am new to AOSD... and there are few questions...

I am trying some simple examples... and need some
clarification on the use of wildcard in the
following
context:

I have a java program with 3 functions:
    1) public int f1(int i);

    2) private void f2();

    3) protected int f3(int);

If I declare a pointcut:

    pointcut outputLog() : call(pr* * f*(..));

for all the private and protected functions...

both ajc 1.1.1 and 1.0.6 gives  compiler error:

 expected "(", found f
 pointcut outputLog() : call(pr* * f*(..));


I am not clear: what's wrong with the pointcut
format.
Can't we use wildcards for access type?... Can
anyone
explain this to me ....


Please also let me know where I can find details
of
how AspectJ is implemented.... (like how proceed()
is
implemeted and why the particular implementation
is
preffered to other alternatives)...

One last question.... does AspectJ has a recent
version of Compile time weaver after Aspectj1.0.6.

Thanks,
Swati



		
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx


http://dev.eclipse.org/mailman/listinfo/aspectj-users

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx

http://dev.eclipse.org/mailman/listinfo/aspectj-users




		
__________________________________
Do you Yahoo!?
Yahoo! Mail is new and improved - Check it out!
http://promotions.yahoo.com/new_mail
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users



Back to the top