Interface AgentDiscoveryEngine

All Known Implementing Classes:
DefaultAgentDiscoveryEngine

public interface AgentDiscoveryEngine
Optional package-scanning and DI-based agent construction engine, discovered via ServiceLoader.

agenor-runtime depends on this interface only; the implementation (reflection-based classpath scanning, factory instantiation) lives in agenor-runtime-scanning and is resolved once at AgenorRuntime construction time. When absent, package-scanning calls fail with a clear IllegalStateException pointing at the missing module.

@Behavior/@AgenorMessageHandler annotation processing is not part of this contract — it runs unconditionally in agenor-runtime regardless of whether this engine is present; see BehaviorAnnotationExtension for the seam covering ext-only behavior types.

Since:
0.25.0
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> void
    addService(Class<T> serviceClass, T instance)
    Registers an additional service instance available for constructor injection.
    <T extends Agent>
    T
    createAgent(Class<T> agentClass)
    Instantiates a single agent from its class via constructor injection.
    createAgents(Set<Class<? extends Agent>> agentClasses)
    Instantiates one agent per discovered class.
    void
    Initializes this engine with the runtime's core services.
    Set<Class<? extends Agent>>
    scanForAgents(String... packageNames)
    Scans the given packages for classes annotated with @Agent.
  • Method Details

    • initialize

      void initialize(AgentContext context)
      Initializes this engine with the runtime's core services.
      Parameters:
      context - the runtime's core services; never null
    • scanForAgents

      Set<Class<? extends Agent>> scanForAgents(String... packageNames)
      Scans the given packages for classes annotated with @Agent.
      Parameters:
      packageNames - packages to scan
      Returns:
      discovered agent classes
    • createAgents

      Map<String,Agent> createAgents(Set<Class<? extends Agent>> agentClasses)
      Instantiates one agent per discovered class.
      Parameters:
      agentClasses - classes to instantiate
      Returns:
      agent instances keyed by agent ID
    • createAgent

      <T extends Agent> T createAgent(Class<T> agentClass)
      Instantiates a single agent from its class via constructor injection.
      Type Parameters:
      T - the agent type
      Parameters:
      agentClass - the agent class to instantiate
      Returns:
      the created agent instance
    • addService

      <T> void addService(Class<T> serviceClass, T instance)
      Registers an additional service instance available for constructor injection.
      Type Parameters:
      T - the service type
      Parameters:
      serviceClass - the service type
      instance - the service instance