public interface AcpInterceptor
Interceptors allow cross-cutting concerns to be applied to handler invocations. Common uses include logging, metrics, authentication, and error handling.
The lifecycle methods are called in this order:
preInvoke(com.agentclientprotocol.sdk.agent.support.AcpInvocationContext) - before handler invocation (all interceptors)postInvoke(com.agentclientprotocol.sdk.agent.support.AcpInvocationContext, java.lang.Object) - after successful invocation (reverse order)onError(com.agentclientprotocol.sdk.agent.support.AcpInvocationContext, java.lang.Throwable) - if an exception occurred (reverse order)afterCompletion(com.agentclientprotocol.sdk.agent.support.AcpInvocationContext) - always called for cleanup (reverse order)InterceptorChain| 限定符和类型 | 字段和说明 |
|---|---|
static int |
DEFAULT_ORDER
Default order value for interceptors (middle priority).
|
| 限定符和类型 | 方法和说明 |
|---|---|
default void |
afterCompletion(AcpInvocationContext context)
Called after invocation completes (success or failure).
|
default int |
getOrder()
Get the order of this interceptor.
|
default java.lang.Object |
onError(AcpInvocationContext context,
java.lang.Throwable ex)
Called when handler throws an exception.
|
default java.lang.Object |
postInvoke(AcpInvocationContext context,
java.lang.Object result)
Called after successful handler invocation.
|
default boolean |
preInvoke(AcpInvocationContext context)
Called before handler invocation.
|
static final int DEFAULT_ORDER
default int getOrder()
default boolean preInvoke(AcpInvocationContext context)
context - the invocation contextdefault java.lang.Object postInvoke(AcpInvocationContext context, java.lang.Object result)
context - the invocation contextresult - the handler resultdefault java.lang.Object onError(AcpInvocationContext context, java.lang.Throwable ex)
context - the invocation contextex - the exceptiondefault void afterCompletion(AcpInvocationContext context)
context - the invocation context