Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] around a constructor

Hello.
I was wondering if it is possible to have a pointcut "around" a constructor?

   private String name;
   private static MyObject ojb;
   private MyObject()
   {
       this.name = NameHolder.getInstance().getNameBySystem();
   }


I would like this to instead be

   private MyObject()
   {
       this.name = NameHolder.getInstance().useThisName( "superman" );
   }

But I can't figure out the pointcut syntax for the life of me.  I think I
should be trying to cut into call( NameHolder.getNameBySystem() ) but that
call is made in a lot of files and I only want to match on one particular instance.
So, should I use "call( NameHolder )" and "withincode( MyObject )"?

Any help with this is very appreciated.

Thanks a lot.


Charlie



Back to the top