aop library

Aspect-oriented programming: code that runs before, after or around the methods of other beans without editing them.

Import it to write aspects (@Aspect, @Before, @Around, ...), pointcut expressions that pick the advised methods, and advisor beans with your own MethodInterceptor. It is also exported by package:spring_core_dart/spring_core_dart.dart. Use AOP for concerns that cut across many classes: logging, timing, auditing, permission checks, retries. The proxies that run the advice are written at build time by spring_core_dart_generator, so the package must run it.

// Logs every call to OrderService.
@Aspect()
@Component()
@Log()
class Auditing {
  @Before('execution(* OrderService.*(..))')
  void audit(JoinPoint joinPoint) => log.info(joinPoint.toShortString());
}

Spring (Java):

@Aspect
@Component
class Auditing {
  @Before("execution(* com.example.OrderService.*(..))")
  void audit(JoinPoint joinPoint) { ... }
}

Classes

AdviceBinding
The type of an advice parameter that the pointcut fills in, such as timed in @annotation(timed) or id in args(id, ..).
Advised
The interface every generated AOP proxy implements: it exposes the bean behind the proxy and the advice applied to it.
Advisor
A piece of advice packaged as an object: the MethodInterceptor to run around calls of other beans.
After
Marks an aspect method to run after each matched call, whether it returned or threw, like a finally block.
AfterReturning
Marks an aspect method to run after each matched call that returned normally, with the returned value.
AfterThrowing
Marks an aspect method to run after each matched call that threw, with the error.
AnnotationMatchingPointcut<A>
A pointcut that matches members carrying an annotation of type A, or every member of beans whose class carries it.
AnnotationPointcut
A marker for pointcuts that match only members or classes carrying annotations from outside package:spring_core_dart, such as @Cacheable or @Validated.
AopContext
Gives an advised bean access to its own proxy, so it can call itself with the advice applied.
AopPointcut
A rule that decides which members of which beans an advisor's advice applies to.
AopProxyFactory
Knows how to wrap one bean class in its generated proxy class, and which of its members can be advised.
AopUtils
Helpers that tell whether an object is an AOP proxy and find the bean behind it.
Around
Marks an aspect method to run instead of each matched call, deciding whether and how the real method runs.
Aspect
Marks a bean class as an aspect: a bean whose advice methods run around the calls of other beans.
AspectAdvice<A extends Object>
One advice method of an @Aspect class, described so it can be called without reflection.
AspectAdviceInterceptor
The MethodInterceptor that runs one aspect advice method: it turns the advice kind (before, after, around, ...) into the right place in the call.
AspectAutoProxyCreator
The bean post-processor that puts advice into effect: it replaces each bean that some advice matches with the bean's generated proxy.
AspectJProxyFactory
A ProxyFactory that also takes the advice of an @Aspect object.
AspectMetadata<A extends Object>
Everything the container needs to know about an @Aspect class: its advice methods, its named pointcuts and its instantiation model.
AsyncMethodInvocation
The MethodInvocation of a method that returns a Future (or FutureOr), with a way to run code when that future completes.
Before
Marks an aspect method to run before each matched call.
ComposablePointcut
A pointcut built from other pointcuts with "or" (union) and "and" (intersection).
DeclareParents
Makes the proxies of matching beans implement an extra interface, with an implementation the aspect supplies (an AspectJ "introduction").
DefaultPointcutAdvisor
The standard PointcutAdvisor: a pointcut, an interceptor and an order.
ExpressionPointcut
A pointcut written as an AspectJ-style expression, the syntax of the @Before / @Around / ... annotations.
Introduction
An extra interface that a @DeclareParents field adds to the proxies of matching beans, with the way to create its implementation.
JoinPoint
One intercepted call, as advice sees it: which member is called, on which bean, with which arguments.
MethodInterceptor
Code that runs around calls of other beans, written as a class instead of an @Aspect method.
MethodInvocation
One intercepted call as a MethodInterceptor sees it: the call's details plus a way to continue it.
MethodSignature
What is known about an advised member without calling it: its name, its types, its annotations and those of its class.
NameMatchMethodPointcut
A pointcut that matches members by name, with * wildcards.
Pointcut
Gives a pointcut expression a name, so several advice methods can share it.
PointcutAdvisor
An Advisor that applies only to the members its pointcut selects.
ProceedingJoinPoint
The JoinPoint of @Around advice, which can also run the call.
ProxyFactory
Builds extra proxies of a bean in code, with advice chosen by the caller rather than by the context's aspects.
ProxyInvoker
The runtime engine behind one proxy: it runs each call of a proxied member through the advice that matches that member.
TruePointcut
A pointcut that matches every member of every bean.

Enums

AdviceKind
The five kinds of aspect advice, one per annotation, listed in the order they nest inside one aspect.
MemberKind
Whether an advised member is a method, a getter or a setter.

Functions

pointcutMatchesBean(AopPointcut pointcut, MethodSignature signature, String beanName, List<String> beanAliases, {List<String> introducedTypes = const []}) → bool
Whether pointcut matches the member signature of the bean beanName, with everything the bean is known by.
retypeFuture<T>(Object? value) → Future<T>
Turns the result of an advised call into a Future<T>.
wildcardMatch(String pattern, String text) → bool
Whether text matches pattern, where * stands for any characters.

Exceptions / Errors

AopConfigException
Thrown when AOP is set up in a way that cannot work, usually at startup: advice matches a bean that cannot be proxied, an aspect has an unsupported instantiation model, or a proxy's advisors are changed although it has none.
AopInvocationException
Thrown by an advised call when the advice cannot run as written, like Spring's AopInvocationException.