Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Help with defining a point cut


On Apr 27, 2009, at 9:19 AM, Elad Sofer wrote:

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.

OK, I think I see the problem now. Try what I suggested before:

- use the set() join-point to capture all assignments to type javax.swing.Component (or whatever it is you are interested in) - grab the name of the assigned field from the locally available info (dunno how, but should be straightforward with something like target() or thisJoinPoint()) - use reflection to read out the rest of the info you need to build the name
- call setName() (by reflection)

Jochen



Back to the top