Class IntentInterceptorAbstract

Allows intercepting intents before their publication.

An interceptor can reject or modify intents. Multiple interceptors can be registered, forming a chain in which each interceptor is called one by one in registration order.

For each intent, the platform invokes the intercept method of the first registered interceptor, passing the intent and the next handler as arguments. By calling the next handler in the intercept method, intent dispatching is continued. If there is no more interceptor in the chain, the intent is transported to the receivers, if any. But, if throwing an error in the intercept method, intent dispatching is aborted, and the error transported back to the sender.

Registering Interceptors

You register interceptors with the bean manager when the host application starts. Interceptors can be registered only in the host application. They are invoked in registration order.

Beans.register(IntentInterceptor, {useClass: IntentLoggerInterceptor, multi: true});

Filtering intents for Interception

The platform passes all intents to the interceptors. The interceptor must filter intents of interest.

Hierarchy

  • IntentInterceptor

Implements

Constructors

Methods

Constructors

Methods

  • Intercepts an intent before being published.

    Decide if to continue publishing by passing the intent to the next handler, or to reject publishing by throwing an error, or to swallow the intent by not calling the next handler at all. If rejecting publishing, the error is transported to the intent issuer.

    Important: When passing the message to the next handler, either return its Promise or await it. Otherwise, errors of subsequent interceptors would not be reported to the sender.

    Parameters

    Returns Promise<void>

    Throws

    throw an error to reject publishing; the error is transported to the intent issuer.

Generated using TypeDoc