Class AguiAgentAutoRegistration
java.lang.Object
io.agentscope.spring.boot.agui.common.AguiAgentAutoRegistration
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanFactoryAware,org.springframework.beans.factory.InitializingBean
public class AguiAgentAutoRegistration
extends Object
implements org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.InitializingBean
A Scanner class for automatically registering Agent beans with the AguiAgentRegistry.
This configuration scans all Agent beans in the application context and registers them with the registry. It supports both singleton and prototype scoped beans:
- Singleton beans: The bean instance is registered directly
- Prototype beans: A factory is registered that creates new instances per request (thread-safe)
Agent ID Resolution:
AguiAgentIdannotation on the bean method or class- Bean name (default)
Usage:
// Singleton bean (shared instance)
@Bean
public Agent chatAgent() {
return ReActAgent.builder().name("Chat").model(model).build();
}
// Prototype bean (new instance per request - thread-safe)
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public Agent isolatedAgent() {
return ReActAgent.builder().name("Isolated").model(model).build();
}
// Custom agent ID
@Bean
@AguiAgentId("custom-id")
public Agent myAgent() {
return ReActAgent.builder().name("Custom").model(model).build();
}
-
Constructor Summary
ConstructorsConstructorDescriptionAguiAgentAutoRegistration(io.agentscope.core.agui.registry.AguiAgentRegistry registry) Creates a new AguiAgentAutoRegistration. -
Method Summary
Modifier and TypeMethodDescriptionvoidInvokeaguiAgentAutoRegistrar()after all properties are set.protected voidRegisters all Agent beans with the AguiAgentRegistry.voidsetBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
-
Constructor Details
-
AguiAgentAutoRegistration
public AguiAgentAutoRegistration(io.agentscope.core.agui.registry.AguiAgentRegistry registry) Creates a new AguiAgentAutoRegistration.- Parameters:
registry- The agent registry
-
-
Method Details
-
setBeanFactory
public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) throws org.springframework.beans.BeansException - Specified by:
setBeanFactoryin interfaceorg.springframework.beans.factory.BeanFactoryAware- Throws:
org.springframework.beans.BeansException
-
aguiAgentAutoRegistrar
protected void aguiAgentAutoRegistrar()Registers all Agent beans with the AguiAgentRegistry.This method is called after the registry is created and scans for all Agent beans.
-
afterPropertiesSet
InvokeaguiAgentAutoRegistrar()after all properties are set.- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception
-