diff --git a/camel-agent-core/src/main/java/io/dscope/camel/agent/a2a/AgentA2AProtocolSupport.java b/camel-agent-core/src/main/java/io/dscope/camel/agent/a2a/AgentA2AProtocolSupport.java index acc2d0b..05e8bd5 100644 --- a/camel-agent-core/src/main/java/io/dscope/camel/agent/a2a/AgentA2AProtocolSupport.java +++ b/camel-agent-core/src/main/java/io/dscope/camel/agent/a2a/AgentA2AProtocolSupport.java @@ -47,6 +47,7 @@ import io.dscope.camel.a2a.service.InMemoryTaskEventService; import io.dscope.camel.a2a.service.PersistentA2ATaskEventService; import io.dscope.camel.a2a.service.PersistentA2ATaskService; +import io.dscope.camel.a2a.service.TaskEventService; import io.dscope.camel.a2a.service.WebhookPushNotificationNotifier; import io.dscope.camel.persistence.core.FlowStateStore; import io.dscope.camel.persistence.core.FlowStateStoreFactory; @@ -219,8 +220,8 @@ private static void validatePlanMappings(AgentPlanSelectionResolver planSelectio } private static SharedA2AInfrastructure resolveSharedInfrastructure(Main main, Properties properties) { - InMemoryTaskEventService taskEventService = - main.lookup(A2AComponentApplicationSupport.BEAN_TASK_EVENT_SERVICE, InMemoryTaskEventService.class); + TaskEventService taskEventService = + main.lookup(A2AComponentApplicationSupport.BEAN_TASK_EVENT_SERVICE, TaskEventService.class); A2ATaskService taskService = main.lookup(A2AComponentApplicationSupport.BEAN_TASK_SERVICE, A2ATaskService.class); A2APushNotificationConfigService pushConfigService = @@ -262,7 +263,7 @@ private static void bind(Main main, String beanName, Object bean) { } } - private record SharedA2AInfrastructure(InMemoryTaskEventService taskEventService, + private record SharedA2AInfrastructure(TaskEventService taskEventService, A2ATaskService taskService, A2APushNotificationConfigService pushConfigService) { } @@ -613,13 +614,13 @@ private static final class SendStreamingMessageProcessor implements Processor { private final Processor sendMessageProcessor; private final AgentA2ATaskAdapter taskAdapter; - private final InMemoryTaskEventService taskEventService; + private final TaskEventService taskEventService; private final ObjectMapper objectMapper; private final A2ARuntimeProperties runtimeProperties; private SendStreamingMessageProcessor(Processor sendMessageProcessor, AgentA2ATaskAdapter taskAdapter, - InMemoryTaskEventService taskEventService, + TaskEventService taskEventService, ObjectMapper objectMapper, A2ARuntimeProperties runtimeProperties) { this.sendMessageProcessor = sendMessageProcessor; diff --git a/camel-agent-core/src/test/java/io/dscope/camel/agent/a2a/AgentA2AProtocolSupportTest.java b/camel-agent-core/src/test/java/io/dscope/camel/agent/a2a/AgentA2AProtocolSupportTest.java index bbfd379..c3e96c8 100644 --- a/camel-agent-core/src/test/java/io/dscope/camel/agent/a2a/AgentA2AProtocolSupportTest.java +++ b/camel-agent-core/src/test/java/io/dscope/camel/agent/a2a/AgentA2AProtocolSupportTest.java @@ -17,6 +17,7 @@ import io.dscope.camel.a2a.service.InMemoryA2ATaskService; import io.dscope.camel.a2a.service.InMemoryPushNotificationConfigService; import io.dscope.camel.a2a.service.InMemoryTaskEventService; +import io.dscope.camel.a2a.service.TaskEventService; import io.dscope.camel.a2a.service.WebhookPushNotificationNotifier; import java.nio.file.Files; import java.nio.file.Path; @@ -91,7 +92,7 @@ void reusesPreboundSharedTaskInfrastructure() throws Exception { objectMapper ); - assertSame(taskEventService, main.lookup(A2AComponentApplicationSupport.BEAN_TASK_EVENT_SERVICE, InMemoryTaskEventService.class)); + assertSame(taskEventService, main.lookup(A2AComponentApplicationSupport.BEAN_TASK_EVENT_SERVICE, TaskEventService.class)); assertSame(taskService, main.lookup(A2AComponentApplicationSupport.BEAN_TASK_SERVICE, A2ATaskService.class)); assertSame(pushConfigService, main.lookup(A2AComponentApplicationSupport.BEAN_PUSH_CONFIG_SERVICE, A2APushNotificationConfigService.class)); diff --git a/samples/agent-support-service/src/main/java/io/dscope/camel/agent/samples/SampleAdminMcpBindings.java b/samples/agent-support-service/src/main/java/io/dscope/camel/agent/samples/SampleAdminMcpBindings.java index 2fd03d2..d3adcb8 100644 --- a/samples/agent-support-service/src/main/java/io/dscope/camel/agent/samples/SampleAdminMcpBindings.java +++ b/samples/agent-support-service/src/main/java/io/dscope/camel/agent/samples/SampleAdminMcpBindings.java @@ -1,7 +1,6 @@ package io.dscope.camel.agent.samples; import com.fasterxml.jackson.databind.ObjectMapper; -import java.lang.reflect.Field; import java.util.Properties; import org.apache.camel.main.Main; @@ -279,38 +278,18 @@ private static String trimToNull(String value) { } private static Object lookup(Main main, String name) { - Object value = lookupFromRegistry(main, name); - if (value == null) { - value = main.lookup(name, Object.class); - } + Object value = main.lookup(name, Object.class); return value != null ? value : new ObjectMapper(); } private static Object required(Main main, String name) { - Object value = lookupFromRegistry(main, name); - if (value == null) { - value = main.lookup(name, Object.class); - } + Object value = main.lookup(name, Object.class); if (value == null) { throw new IllegalStateException("Required bean missing after runtime bootstrap: " + name); } return value; } - private static Object lookupFromRegistry(Main main, String name) { - try { - Field registryField = Main.class.getDeclaredField("registry"); - registryField.setAccessible(true); - Object registry = registryField.get(main); - if (registry == null) { - return null; - } - return registry.getClass().getMethod("lookupByName", String.class).invoke(registry, name); - } catch (Exception ignored) { - return null; - } - } - private static Object newInstance(String className) throws Exception { return Class.forName(className).getDeclaredConstructor().newInstance(); }