You could do this via reflection, your test method needs to iterate through the fields on the object under test and if they are of a relevant type set it's name (and possibly go through it's members if it's a container?)
-----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Elad Sofer Sent: 27 April 2009 08:19 To: [email protected] Subject: Re: [aspectj-users] Help with defining a point cut Thanks again, What i mean by my pattern (refering to your code example), is that i need to set the name of myPrivateLabel to "JLabel_myPrivateLabel". I was not able to do that since our code sometimes looks like this: class A { private JLabel myPrivateLabel = new JLabel(); private JLabel anotherPrivateLabel; A() { anotherPrivateLabel = new JLabel(); } //methods } I need to be able to handle both cases and dont really understand how. BTW - i am using annotations to define my aspects. Thanks for you patience. Elad. On Mon, Apr 27, 2009 at 9:57 AM, Jochen Wuttke <[email protected]> wrote: On Apr 27, 2009, at 7:08 AM, Elad Sofer wrote: Thanks for the reply, The thing is that a join point after the Ctor is not suffiecient since i need to have the following name pattern <Type>_<MemberName>, this means that if i have a JLabel within class A and it is initialized in the declerative part i do not have access to the instance of A that holds the JLabel, and this is needed to be able to match the member name using reflection (or is it not ?). I'm still not sure what you mean when you say <Type>_<MemberName>. Is it something like this; class A { private JLabel myPrivateLabel; A() { myPrivateLabel = new JLabel(); } //methods } If it is, then I assume you want to set the name in the JLabel to "A_myPrivateLabel"? If that's the case you can change the "execution" join-point to "call", that at least gives you access to the current instance of "A". Catching the member name requires an additional bit of advice at every field assignment where you can check the type and remember the name if necessary. If all this is not what you meant, I think you should give a code example. Jochen _______________________________________________ aspectj-users mailing list [email protected] https://dev.eclipse.org/mailman/listinfo/aspectj-users ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ This e-mail and any attachments are for the intended addressee(s) only and may contain confidential and/or privileged material. If you are not a named addressee, do not use, retain or disclose such information. This email is not guaranteed to be free from viruses and does not bind Serco in any contract or obligation. Serco Limited. Registered in England and Wales. No: 242246 Registered Office: Serco House,16 Bartley Wood Business Park, Hook, Hampshire RG27 9UY United Kingdom. Help cut carbon...please don’t print this e-mail unless you really need to. _______________________________________________ aspectj-users mailing list [email protected] https://dev.eclipse.org/mailman/listinfo/aspectj-users
