Class AgentInterceptor

java.lang.Object
com.aispect.core.engine.runtime.interceptor.AgentInterceptor
All Implemented Interfaces:
InvocationHandler

public class AgentInterceptor extends Object implements InvocationHandler
JDK The core interceptor of dynamic proxy, which belongs torunning phase (Runtime)Responsibilities.

delegate at instantiation AiComponentScanner Complete annotation scanning and resource registration during startup; When the method is called, from AgentInvocationCacheImpl Read the registered Agent, pass instanceof distinguish AiUnitAgentHandler and AbstractGraphAgent, and routes the call to the appropriate execution engine (Unit / Graph)。

  • Constructor Details

    • AgentInterceptor

      public AgentInterceptor(Object target, Class<?> interfaceClass, AiOperations aiOperations) throws AiScanException
      Interceptor constructor.

      Trigger component scanning in the startup phase immediately upon instantiation: entrust AiComponentScanner Scan the annotations of the target interface and verify the legality of the resources. and will instantiate Handler Deposit invocationCache。

      Parameters:
      target - The proxy's target object instance
      interfaceClass - The interface class corresponding to the agent
      aiOperations - AI Service operation interface instance
      Throws:
      AiScanException - If the component scan during the startup phase finds configuration errors
  • Method Details

    • invoke

      public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
      Interception entry during running phase: According to the cached Agent Resources to route calls to the appropriate engine.

      Priority:Unit Agent > Graph Agent > Native method call (informal)

      Specified by:
      invoke in interface InvocationHandler
      Throws:
      Throwable