Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Advising all calls to all methods within a certain package

Hi,

See the section on declaring types and joinpoint signatures in the
documentation:

http://www.eclipse.org/aspectj/doc/released/adk15notebook/join-point-signatures.html#method-call-join-point-signatures

You are advising calls through subtypes of java.io as well.  Are you
sure you do not want to do this?

This will work, although introduces a dynamic test:

  pointcut p(): call(* java.io..*.*(..)) &&
               if(thisJoinPointStaticPart.getSignature().getDeclaringType().getName().startsWith("java.io."));

Or

 execution(* *(..)) && within(java.io..*)

But this latter example will get executed for calls to java.io methods
that happen via subtypes of java.io classes, which you would have also
been catching with call(* java.io..*(..)) anyway.

Andy.

2008/6/23 Raffi Takvor Khatchadourian <khatchad@xxxxxxxxxxxxxxxxxx>:
> Hi Eric,
>
> On 23 Jun 2008, at 16:14, Eric Bodden wrote:
>>
>> 2008/6/23 Raffi Takvor Khatchadourian <khatchad@xxxxxxxxxxxxxxxxxx>:
>>>
>>> Hello. I would like to advise all calls to all methods within the
>>> java.io package and subpackages. I have the following pointcut:
>>>
>>> call(* java.io..*.*(..))
>>>
>>> It works, however, it also advised calls to methods within java.lang as
>>> well. Anyway to fix this? Thanks!
>>
>> If I am not mistaken, this should only be the case if the callee
>> extends a type in java.io..., which is probably what you want.
>
> Hm, actually I am looking to advise methods declared in classes
> contained in the java.io package and subpackages. Thus, I solely want to
> consider the declared package names and not any inheritance hierarchies.
> Am I using the correct pointcut to do so?
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>


Back to the top