Class InMemoryAgentRepository

java.lang.Object
com.agentforge4j.config.loader.repository.InMemoryAgentRepository
All Implemented Interfaces:
AgentRepository

public final class InMemoryAgentRepository extends Object implements AgentRepository
Thread-safe in-memory AgentRepository whose global snapshot can be replaced atomically.
  • Constructor Details

    • InMemoryAgentRepository

      public InMemoryAgentRepository(Map<String,AgentDefinition> globalAgents)
      Creates a repository from an initial global agent snapshot.
      Parameters:
      globalAgents - initial agents keyed by id
  • Method Details

    • get

      public AgentDefinition get(String id)
      Returns an agent by id from the current global snapshot.
      Specified by:
      get in interface AgentRepository
      Parameters:
      id - agent id
      Returns:
      matching agent definition
      Throws:
      AgentNotFoundException - when no agent exists for the id
    • findAll

      public Map<String,AgentDefinition> findAll()
      Returns all agents from the current global snapshot.
      Specified by:
      findAll in interface AgentRepository
      Returns:
      immutable map of all agents keyed by id
    • replaceGlobalAgents

      public void replaceGlobalAgents(Map<String,AgentDefinition> globalAgents)
      Replaces the global agent snapshot used by this repository.
      Parameters:
      globalAgents - replacement agents keyed by id