Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Is it possible to dynamically exclude joinpoints at runtime?

Hello,

I would like to be able to dynamically define an "exclude" joinpoit on my advice at runtime. For example, say I have:

pointcut myPointcut(): execution(* *.*(..));

Object around() : myPointcut() ...



At runtime, I would like to be able to dynamically define another joinpoint which will be added as an "excluded" joinpoint on the advice, in order to exclude some package from the advice. The definition would be equivalent to this:

pointcut myPointcut(): execution(* *.*(..)) &&
                      !execution(* some.package..*(..));

Object around() : myPointcut() ...


Is this at all possible with AspectJ?  My only idea would be to have some sort
of independent pre-processing step which would read the exclusions (perhaps from a property file), and then build and write the aspect source out to disk, recompile and reweave the app. Then the app could be re-started with the new dynamically defined aspect and the correct exclusions on the pointcut. This definitely wouldn't be at runtime, but it's the only solution I can think of. Can anyone think of a more elegant solution?

By the way, you may be wondering why I don't just write the aspect with the correct joinpoint definition in the first place. The reason is that this is part of a framework, and I want a simple API (a method call or property file) for users to define classes to exclude from weaving. I don't want the users to have to know AspectJ.

Thanks,
Chad









Back to the top