Aspect Declarations

Aspect declarations are supported by the org.aspectj.lang.annotation.Aspect annotation. The declaration:

     @Aspect
     public class Foo {}
      

Is equivalent to:

     public aspect Foo {}
      

Privileged aspects are declared as:

     @Aspect(isPrivileged=true)
     public class Foo {}
     
     is equivalent to...
     
     public privileged aspect Foo {}
      

To specify an aspect an aspect instantiation model (the default is singleton), use the instantionModel and perClausePattern attributes. For example:

     @Aspect(instantiationModel=AspectInstantiationModel.PERTHIS,
             perClausePattern="execution(* abc..*(..))")
     public class Foo {}
     
     is equivalent to...
     
     public aspect Foo perthis(execution(* abc..*(..))) {}
      

The full definitions of the Aspect annotation type and the AspectInstantiationModel enumerated type are:

     /**
      * Use to indicate that a class should be treated as an aspect by
      * AspectJ's weaver.
      */
     @Target({ElementType.TYPE})
     public @interface Aspect {
     	AspectInstantiationModel instantiationModel() default AspectInstantiationModel.SINGLETON;
     	String perClausePattern() default "";
       	boolean isPrivileged() default false;
     }
     
     /**
      * The different aspect instantiation models supported by AspectJ
      */
     public enum AspectInstantiationModel {
      SINGLETON,
      PERTHIS,
      PERTARGET,
      PERCFLOW,
      PERCFLOWBELOW,
      PERTYPEWITHIN
     }