Idioms
About this Chapter
This chapter consists of very short snippets of AspectJ code,
typically pointcuts, that are particularly evocative or useful.
This section is a work in progress.
Here's an example of how to enfore a rule that code in the java.sql
package can only be used from one particular package in your system. This
doesn't require any access to code in the java.sql package.
Any call to an instance of a subtype of AbstractFacade whose class is
not exactly equal to AbstractFacade:
If AbstractFacade is an abstract class or an interface, then every
instance must be of a subtype and you can replace this with:
Any call to a method which is defined by a subtype of
AbstractFacade, but which isn't defined by the type AbstractFacade itself:
The execution of a method that is defined in the source code for a
type that is a subtype of AbstractFacade but not in AbstractFacade itself:
To use a per-class variable declared on many classes,
you can defer initialization until you are in a non-static instance context
so you can refer to the particular class member. If you want to use
it from advice (without knowing the particular class at compile-time),
you can declare a method on the type.