Class AgentInvocationCacheImpl<H extends AiAgentFilter>

java.lang.Object
com.aispect.core.engine.bootstrap.registry.AgentInvocationCacheImpl<H>
Type Parameters:
H - Inherited from AiAgentFilter filter type
All Implemented Interfaces:
AgentInvocationCache<H>

public class AgentInvocationCacheImpl<H extends AiAgentFilter> extends Object implements AgentInvocationCache<H>
The default implementation class for proxy call caching.

belongstartup phase (Bootstrap)core registry. When the application starts, it is AiComponentScanner Scan for annotations on the target interface, Will be instantiated after verification AiAgentFilter Resources are stored in this table, and the creation method is the same as Handler mapping relationship.

use ConcurrentHashMap To ensure thread-safe cache access operations.
  • Constructor Details

    • AgentInvocationCacheImpl

      public AgentInvocationCacheImpl()
  • Method Details

    • computeHash

      public String computeHash(Method method, AiExecutePhase phase)
      Computes a cache's unique hash value (key) based on method and execution phase.
      Specified by:
      computeHash in interface AgentInvocationCache<H extends AiAgentFilter>
      Parameters:
      method - target method
      phase - AI Execution phase
      Returns:
      The format is "Stage name@method name" hash string
    • put

      public void put(Method method, AiExecutePhase phase, H resource) throws AiSpectException
      Put the filter resource into cache. If the same key already exists in the cache, an exception will be thrown to prevent overwriting.
      Specified by:
      put in interface AgentInvocationCache<H extends AiAgentFilter>
      Parameters:
      method - target method
      phase - AI Execution phase
      resource - Filter resource to cache
      Throws:
      AiSpectException - This exception is thrown if the cache for this method and stage already exists
    • get

      public H get(Method method, AiExecutePhase phase)
      Gets the filter resource for the specified method and stage from the cache.
      Specified by:
      get in interface AgentInvocationCache<H extends AiAgentFilter>
      Parameters:
      method - target method
      phase - AI Execution phase
      Returns:
      The cached filter resource, returned if it does not exist null
    • remove

      public boolean remove(Method method, AiExecutePhase phase)
      Removes the filter resource for the specified method and stage from the cache.
      Specified by:
      remove in interface AgentInvocationCache<H extends AiAgentFilter>
      Parameters:
      method - target method
      phase - AI Execution phase
      Returns:
      If removed successfully return true,If it does not exist in the cache, return false
    • clear

      public void clear()
      Clear all data in cache.
      Specified by:
      clear in interface AgentInvocationCache<H extends AiAgentFilter>