Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Patterns of pointcuts

My understanding is that if I want to define a pointcut in terms of other pointcuts, I need to enumerate them:

   pointcut somepointcut() : p1() || p2() || p3();

I am thinking it would be nice to define a pointcut in terms of other pointcuts by using a pattern (I am pretty sure you cannot do this) Example:

   pointcut somepointcut() : p*();

Here is my rationale:

I am envisioning a large project with many teams of developers. Each team defines a pointcut to represent a given semantic event (e.g. a transaction) as implemented in their respective modules. p1() captures join points for semantic event E as implemented in package1 by team 1 p2() captures join points for semantic event E as implemented in package2 by team 2 p3() captures join points for semantic event E as implemented in package3 by team 3
   etc..

Each team does not know the implementation details of event E in the other packages. In a large project, the cognitive burden of the implementation details of event E across the entire project may prove too great for a single person.

In order to weave advice for event E across the entire project, such advice would have to reference some pointcut pg() (g for global) that included p1(), p2(), and p3():

   pointcut pg() : p1() || p2() || p3();

So far so good. But what if a 4th package were added to the project written by a 4th team? An additional pointcut, p4() would need to be created, plus pointcut pg() would need to be updated to include it.

Wouldn't it be nice if we could add additional such packages and not have to maintain the definition of pg()?

   pointcut pg() : p*();

Is there a way to define a pointcut in terms of other pointcuts without explicitly enumerating them? If not, then do you agree/disagree with the usefulness of having such a feature?


Thanks in advance for your thoughts,

-Nathan

--
In theory, there is no difference between theory and practice.  But, in practice, there is.

--Jan L.A. van de Snepscheut




Back to the top