RunAfter class final

A reflective annotation that declares that the annotated interceptor, filter, or handler should execute after one or more specified targets within the Jetleaf request processing pipeline.

Overview

The RunAfter annotation complements RunBefore, allowing developers to define relative ordering constraints between interceptors in Jetleaf’s request execution chain.

This annotation is crucial when interceptors depend on preconditions or states established by others—for example, ensuring that security validation runs before logging, or that metrics aggregation runs after response finalization.

Usage Example

@RunAfter([LoggingInterceptor, 'security_interceptor'])
class AuthInterceptor implements HandlerInterceptor {
  @override
  Future<bool> preHandle(req, res, handler) async {
    if (!req.headers.containsKey('Authorization')) {
      throw UnauthorizedException('Missing Authorization header');
    }
    return true;
  }
}

In this example:

  • AuthInterceptor will execute after both LoggingInterceptor and the interceptor registered as 'security_interceptor'.

Supported Target Types

  • Type references (e.g. LoggingInterceptor)
  • String pod names (e.g. 'metrics_interceptor')

Framework Integration

When Jetleaf constructs the interceptor execution chain, it merges RunBefore and RunAfter declarations into a unified precedence graph, then performs topological sorting to determine the correct invocation sequence.

Combined Example

@RunBefore([AuthInterceptor])
class MetricsInterceptor {}

@RunAfter([MetricsInterceptor])
class AuthInterceptor {}

→ Jetleaf will ensure that: MetricsInterceptor runs before AuthInterceptor.

Design Notes

  • Used exclusively at class-level, enforced via @Target({TargetKind.classType}).
  • Relies on ReflectableAnnotation for runtime introspection.
  • Safely ignored if a referenced interceptor does not exist in the current context.
  • RunBefore — declares inverse ordering (run before targets).

Summary

The RunAfter annotation provides declarative, fine-grained control over interceptor sequencing, ensuring consistent, predictable, and maintainable request processing order.

Inheritance
Annotations
  • @Target.new({TargetKind.classType})

Constructors

RunAfter(List<Object> targets)
A reflective annotation that declares that the annotated interceptor, filter, or handler should execute after one or more specified targets within the Jetleaf request processing pipeline.
const

Properties

annotationType → Type
Returns the annotation _type of this annotation.
no setteroverride
hashCode → int
Returns a hash code consistent with equality definition.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
targets → List<Object>
The list of targets (either Types or String pod names) that this interceptor should execute after.
final

Methods

equals(Object other) → bool
Checks whether the given object is logically equivalent to this annotation.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
Returns a string representation of this annotation.
inherited

Operators

operator ==(Object other) → bool
Checks if this annotation is equal to another object.
inherited