A central part of AspectJ's programming model is that aspects
written using the code style and compiled using ajc support
aspectOf
and
hasAspect
static
methods. When developing an aspect using the annotation style and compiling
using a regular Java 5 compiler, these methods will not be visible to the
compiler and will result in a compilation error if another part of the
program tries to call them.
To provide equivalent support for AspectJ applications compiled with
a standard Java 5 compiler, AspectJ 5 defines the
Aspects
utility class:
public class Aspects { /* variation used for singleton, percflow, percflowbelow */ static<T> public static T aspectOf(T aspectType) {...} /* variation used for perthis, pertarget */ static<T> public static T aspectOf(T aspectType, Object forObject) {...} /* variation used for pertypewithin */ static<T> public static T aspectOf(T aspectType, Class forType) {...} /* variation used for singleton, percflow, percflowbelow */ public static boolean hasAspect(Object anAspect) {...} /* variation used for perthis, pertarget */ public static boolean hasAspect(Object anAspect, Object forObject) {...} /* variation used for pertypewithin */ public static boolean hasAspect(Object anAspect, Class forType) {...} }