AguiAgentAutoRegistration
public class AguiAgentAutoRegistration implements BeanFactoryAware, InitializingBean
io/agentscope/spring/boot/agui/common/AguiAgentAutoRegistration.java:75–213AGUI 智能体 Auto 注册,承载智能体的部署、调度与服务化运行。位于 io.agentscope.spring.boot.agui.common 包,实现 BeanFactoryAware、InitializingBean。核心成员包括 setBeanFactory、aguiAgentAutoRegistrar、afterPropertiesSet、AguiAgentAutoRegistration。
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
| 构造器Constructor | 说明Description |
|---|---|
public AguiAgentAutoRegistration(AguiAgentRegistry registry) | 创建新的AguiAgentAutoRegistration。 Creates a new AguiAgentAutoRegistration. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public void setBeanFactory(BeanFactory beanFactory) throws BeansException | 设置 `setBeanFactory`。 Sets the bean factory. |
protected void aguiAgentAutoRegistrar() | 执行 `aguiAgentAutoRegistrar` 方法。 Registers all Agent beans with the AguiAgentRegistry. |
public void afterPropertiesSet() throws Exception | 在属性设置后调用。 Invoke `#aguiAgentAutoRegistrar()` after all properties are set. |
构造器详情Constructor Detail
AguiAgentAutoRegistration
public AguiAgentAutoRegistration(AguiAgentRegistry registry)
创建新的AguiAgentAutoRegistration。
Creates a new AguiAgentAutoRegistration.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
registry | AguiAgentRegistry | 智能体注册表。The agent registry |
io/agentscope/spring/boot/agui/common/AguiAgentAutoRegistration.java:88–90方法详情Method Detail
setBeanFactory
public void setBeanFactory(BeanFactory beanFactory) throws BeansException
设置 setBeanFactory。
Sets the bean factory.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
beanFactory | BeanFactory | bean 工厂(类型 `BeanFactory`)。The bean factory. |
BeansException可能抛出 `BeansException`。Thrown when the operation cannot be completed.
io/agentscope/spring/boot/agui/common/AguiAgentAutoRegistration.java:92–97aguiAgentAutoRegistrar
protected void aguiAgentAutoRegistrar()
执行 aguiAgentAutoRegistrar 方法。
Registers all Agent beans with the AguiAgentRegistry.
io/agentscope/spring/boot/agui/common/AguiAgentAutoRegistration.java:104–141afterPropertiesSet
public void afterPropertiesSet() throws Exception
在属性设置后调用。
Invoke #aguiAgentAutoRegistrar() after all properties are set.
Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/spring/boot/agui/common/AguiAgentAutoRegistration.java:209–212