public interface Interceptor<T extends org.mule.runtime.api.meta.model.ComponentModel>
ConfigurationInstance. Those instances can have lifecycle, can
be stateful and can use JSR-330 annotations for dependency injection. However, they MUST be thread-safe and
reusable.| Modifier and Type | Method and Description |
|---|---|
default void |
after(ExecutionContext<T> executionContext,
Object result)
Executes after the execution of an operation is finished, regardless of it being successful or not.
|
default void |
before(ExecutionContext<T> executionContext)
Executes before the operation is executed.
|
default Throwable |
onError(ExecutionContext<T> executionContext,
Throwable exception)
Executes when the execution of an operation threw exception.
|
default void |
onSuccess(ExecutionContext<T> executionContext,
Object result)
Executes when an operation was successfully executed.
|
default void before(ExecutionContext<T> executionContext) throws Exception
after(ExecutionContext, Object), nor any other of the interceptors in line will be executed either. Because
of this, no implementation should rely on the execution of any other method in this or other interceptorexecutionContext - the ExecutionContext for the operation to be executedException - in case of errordefault void onSuccess(ExecutionContext<T> executionContext, Object result)
after(ExecutionContext, Object) method is guaranteed to be executed regardless of this method's outcome in
this or other involved instancesexecutionContext - the ExecutionContext that was used to execute the operationresult - the result of the operation. Can be null if the operation itself returned that.default Throwable onError(ExecutionContext<T> executionContext, Throwable exception)
Exception to allow implementations to decorate, enrich or even replace the exception that will be
bubbled up. Implementations however are not obligated to do such thing in which case they should return the same
exception supplied. Notice however that:
after(ExecutionContext, Object) method is guaranteed to be executed regardless of this method's outcome in
this or other involved instancesexecutionContext - the ExecutionContext that was used to execute the operationexception - the Exception that was thrown by the failing operationException that should be propagated forwarddefault void after(ExecutionContext<T> executionContext, Object result)
onSuccess(ExecutionContext, Object) or
onError(ExecutionContext, Throwable) but it doesn't execute if before(ExecutionContext) threw exception.
The result argument holds the return value of the operation. Because this method is invoked even if the operation
failed, then the result will be a null in such a case. However, notice that testing result for being
null is not an indicator of the operation having failed or not, since the operation might have successfully returned
null. This method should be used for actions that should take place "no matter what". Actions that should
depend on the operation's outcome are to be implemented using onSuccess(ExecutionContext, Object) or
onError(ExecutionContext, Throwable)executionContext - the ExecutionContext that was used to execute the operationresult - the result of the operation. Can be null if the operation itself returned that or failed.Copyright © 2024 MuleSoft, Inc.. All rights reserved.