next up previous
Next: POINTCUTIFEXPR mode Up: Nested Lexical Scopes Previous: ASPECT mode


Whereas the JAVA and ASPECT modes are very similar, basically differing only on the keywords recognized, the POINTCUT mode has a completely different lexical structure. In Figure 1, the lexical scopes for pointcuts are shown by the boxes nested inside the Aspect. There are four contexts in which pointcut scopes occur, as follows:

Pointcut Context #1 - a Per clause in an aspect declaration:
The header of an aspect declaration ends with an an optional per clause. A per clause consists of either the keyword issingleton or a parenthesized pointcut expression preceded by one of the keywords percflow, percflowbelow, pertarget or perthis. A POINTCUT scope starts after one of the per keywords and ends at the matching closing parenthesis that surrounds the pointcut. Figure 1 shows a nested scope for a pointcut expression following the percflow keyword.

Pointcut Context #2 - body of a declare declaration:
Inside the body of an aspect one can define a declare declaration. A lexical POINTCUT scope begins just after the keyword declare and ends at the ; terminating the declaration.

The example program shows a declaration of a warning which matches all calls to constructors of classes found in packages ending in the digit 1, with classname Foo or a subclass of Foo.

Pointcut Context #3 - body of a pointcut declaration:

Pointcut declarations are provided in AspectJ as a way of defining a named pointcut. In the example program in Figure 1 two such declarations are given, one for notKeywords and another for hasSpecialIf. Inside pointcut declarations a pointcut lexical scope begins immediately following the pointcut keyword and ends after the ; terminating the pointcut declaration. Pointcut declarations can appear both inside aspects and inside ordinary Java classes.

Pointcut Context #4 - header of an advice declaration:

Advice declarations have a pointcut expression in their header. All such pointcuts will be preceded by one of the keywords before, after or around. For example, in Figure 1, a pointcut follows an after keyword. The pointcut ends before the body of the pointcut begins, signalled by a {.

Thus, a pointcut context starts immediately after a before, after or around token, and ends at the first opening brace encountered.

next up previous
Next: POINTCUTIFEXPR mode Up: Nested Lexical Scopes Previous: ASPECT mode
hendren 2004-09-02