Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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) {
}
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));

Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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) {
Comment on lines 280 to 287
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();
}
Expand Down
Loading