Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] toString Aspect aspect browser

Thanks Ron

I now see that i should have used execution() rather than call()


The problem is that if

public String toString()  if is implemented only in java.lang,Object;

The aspect cant find it as a joinpoint.

if i implement toString() in my class

public String toString() { return "You wont see this because the aspect 
will get there first";}

It is found by the asect and i get my nice string out.


Is there a way around this??

Thanks again 
Jon











"DiFrango, Ron" <ron.difrango@xxxxxxxxxxxxxx>
2003-07-24 03:38 PM

 
        To:     "'aspectj-users@xxxxxxxxxxx'" <aspectj-users@xxxxxxxxxxx>
        cc:     Jon Pallas/EHV/CE/PHILIPS@EMEA3
        Subject:        RE: [aspectj-users] toString Aspect aspect browser
        Classification: 



Jon,

I got it to work with the following:

       public pointcut myClass(Object obj) : within(com.philips.sct..*)
                                 && this(obj);

                 public pointcut myToString(Object obj) : 
                                 myClass(obj)
                                 && execution(public String toString());

                 String around(Object obj) : myToString(obj) {
                                 return StringUtil.toString(obj); 
                 }

Thanks,

Ron DiFrango


-----Original Message-----
From: jon.pallas@xxxxxxxxxxx [mailto:jon.pallas@xxxxxxxxxxx] 
Sent: Thursday, July 24, 2003 7:58 AM
To: aspectj-users@xxxxxxxxxxx
Subject: [aspectj-users] toString Aspect aspect browser


Hi All 


I am new to aspectj so I may be doing something simple wrong any help 
would be apperciated.

I have writen an Aspect that i want to intersept any call to toString(). 
The code is below
using the aspect browser in eclipse i can see that it only affects classes 

that are not in 
com.philips.sct? but his is what i want tbe be affected? 

Is it just the browser or is it my code?

Thanks
Jon




1)

package com.philips.sct.aspects;

import com.philips.common.util.StringUtil;

public aspect ToStringEnhancerAspect {
 
        public pointcut myClass(Object obj) : within(com.philips.sct..*) 
&& this(obj);

 
        public pointcut myAspects() : within(com.philips.sct.aspects.*);
 
 
        public pointcut myToString(Object obj) : !myAspects()
                        &&  myClass(obj)
                        &&  call(public String toString())
                        ;

        String around (Object obj): myToString(obj){
                return StringUtil.toString(obj); 
        }
}


_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users
 
**************************************************************************
The information transmitted herewith is sensitive information intended 
only
for use by the individual or entity to which it is addressed. If the 
reader
of this message is not the intended recipient, you are hereby notified 
that
any review, retransmission, dissemination, distribution, copying or other
use of, or taking of any action in reliance upon this information is
strictly prohibited. If you have received this communication in error,
please contact the sender and delete the material from your computer.





Back to the top