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 Andy,

On 23 Jun 2008, at 18:15, Andy Clement wrote:
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

Thanks for the link!

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

Yes, I am sure. The intent is to advise all calls to methods pertaining
to standard I/O; thus why I chose the java.io package. For instance, the
advice applies to calls to System.out.println(..) which is what I
desire, however, it also advises calls to StringBuilder.toString() which
does not pertain directly to I/O. I see now that the reason this call is
being advised is because StringBuilder implements the
java.io.Serializable interface.
This will work, although introduces a dynamic test:

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

Thanks for the help but this seems odd that something that can be
resolved statically would require a dynamic check.

Raffi


Back to the top