2

I using aspectj LTW in my guice application and I m trying to make the pointcut definition for the aspects controlled from a configuration file. for example:

pointcut publicOperation() : execution(*** READ THIS FROM CONFIG/PROPERTY FILE ****);
Object around() : publicOperation() {
        .....
    }

what all possible options that I have ?

Thanks

Sammy
  • 4,538
  • 8
  • 33
  • 52
  • Doesn't this have to be compiled? Are you talking about doing some filter replace right before compilation? – Sotirios Delimanolis Aug 08 '13 at 15:46
  • Yes, it would be compiled the first time the project is build, but after that, I just want to be able to modify the pointcut expression from an external file, without having to rebuild. just need to restart the server for the LTW to pick up the new pointcut. – Sammy Aug 08 '13 at 15:48
  • I don't know much about aspectj, but aren't those declarations static, as in not changeable at runtime? – Sotirios Delimanolis Aug 08 '13 at 15:51

1 Answers1

1

Put your pointcut definitions into aop.xml as suggested by the The AspectJ Development Environment Guide.

kriegaex
  • 63,017
  • 15
  • 111
  • 202
  • Thanks for the suggestion. this way, I have to make an abstract aspect and make all my aspects extends it. as only concret-aspects that extends abstract aspects can define pointcuts in the aop.xml. also, I will have to externalize the aop.xml to allow for modifying it without building the aspectj projects. – Sammy Aug 09 '13 at 22:58
  • So what? Is it a problem? At least it is a viable solution. You said in another remark: "I just want to be able to modify the pointcut expression from an external file, without having to rebuild." Bingo! I just gave you what you asked for and it is even a canonical way without dirty tricks. What more do yoh want? – kriegaex Aug 10 '13 at 07:08
  • Yes, yes! this definitely will work. I was hoping there is a way where I can I can allow system admins ( that don't need to know about aspectj) to modify a propery file like (MONITORED_METHOD=execution(........), but if this is not possible. yours will be definitively the accepted answer ;) – Sammy Aug 10 '13 at 08:44
  • You can either teach them to change code in all appropriate places of *aop.xml* or build an intermediate layer, allowing them to just enter the method names and then merge them into the appropriate places using a little generator tool. It depends on how far you want to go in order to make it easier for them. – kriegaex Aug 10 '13 at 09:15