AspectMetadata<A extends Object> class final

Everything the container needs to know about an @Aspect class: its advice methods, its named pointcuts and its instantiation model.

The generator reads the aspect's annotations at build time and writes this object into the aspect's bean definition (its aspect field). At startup the AspectAutoProxyCreator finds the bean definitions that have one and turns each AspectAdvice into an advisor. Applications never write it, except for bean definitions written by hand and for AspectJProxyFactory.addAspect, which takes one.

// What the generator writes for an aspect with one named pointcut
// `calculator()` and one @After advice method `after`.
BeanDefinition<AuditAspect>(
  name: 'auditAspect',
  create: (_) => AuditAspect(),
  aspect: AspectMetadata<AuditAspect>(
    typeName: 'AuditAspect',
    pointcuts: {'calculator': 'execution(* Calculator.*(..))'},
    advice: [
      AspectAdvice<AuditAspect>(
        kind: AdviceKind.after,
        pointcut: 'calculator()',
        methodName: 'after',
        invoke: (aspect, _, _, _) => aspect.after(),
      ),
    ],
  ),
);

Spring (Java):

// Spring reads the same information reflectively:
AspectMetadata metadata =
    new AspectMetadata(AuditAspect.class, "auditAspect");

Constructors

AspectMetadata({List<AspectAdvice<A>> advice = const [], Map<String, String> pointcuts = const {}, String? typeName, Map<String, bool Function(Object? value)> typeTests = const {}, Map<String, Object? Function(Object? value)> argumentAnnotations = const {}, String? perClause})
Describes an aspect with its advice methods and named pointcuts.

Properties

advice → List<AspectAdvice<A>>
The advice methods, in declaration order.
final
argumentAnnotations → Map<String, Object? Function(Object? value)>
For @args(Annotation): by annotation name, a function returning that annotation when a value's runtime class carries it, else null.
final
hashCode → int
The hash code for this object.
no setterinherited
perClause → String?
perthis(pointcut) for one aspect instance per proxy, pertarget(pointcut) for one per target bean (the aspect bean must then be a prototype); null for one shared instance.
final
pointcuts → Map<String, String>
The aspect's named @Pointcuts, method name to expression. It also holds the pointcuts of other classes the aspect refers to, under a qualified key ('CommonPointcuts.inWeb').
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
typeName → String
The aspect's class name, as written by the generator so that it survives minified release builds.
final
typeTests → Map<String, bool Function(Object? value)>
Type tests by simple type name ('String': (v) => v is String), so args(String) can test the runtime type of an argument, as AspectJ's instanceof does.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited