Package dev.agenor.core.spi
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 TypeMethodDescription<T> voidaddService(Class<T> serviceClass, T instance) Registers an additional service instance available for constructor injection.<T extends Agent>
TcreateAgent(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.voidinitialize(AgentContext context) Initializes this engine with the runtime's core services.scanForAgents(String... packageNames) Scans the given packages for classes annotated with@Agent.
-
Method Details
-
initialize
Initializes this engine with the runtime's core services.- Parameters:
context- the runtime's core services; nevernull
-
scanForAgents
Scans the given packages for classes annotated with@Agent.- Parameters:
packageNames- packages to scan- Returns:
- discovered agent classes
-
createAgents
Instantiates one agent per discovered class.- Parameters:
agentClasses- classes to instantiate- Returns:
- agent instances keyed by agent ID
-
createAgent
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
Registers an additional service instance available for constructor injection.- Type Parameters:
T- the service type- Parameters:
serviceClass- the service typeinstance- the service instance
-