ppalaga commented on a change in pull request #3151:
URL: https://github.com/apache/camel-quarkus/pull/3151#discussion_r721959117
##########
File path:
extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelContextProcessor.java
##########
@@ -163,4 +168,54 @@ public CamelRuntimeBuildItem runtime(
recorder.createRuntime(beanContainer.getValue(),
context.getCamelContext()),
config.bootstrap.enabled);
}
+
+ /**
+ * Registers Camel CDI event bridges if
quarkus.camel.event-bridge.enabled=true and if
+ * the relevant events have CDI observers configured for them.
+ *
+ * @param beanDiscovery build item containing the results of bean discovery
+ * @param context build item containing the CamelContext instance
+ * @param recorder the CamelContext recorder instance
+ */
+ @Record(ExecutionTime.STATIC_INIT)
+ @BuildStep(onlyIf = EventBridgeEnabled.class)
+ public void registerCamelEventBridges(
+ BeanDiscoveryFinishedBuildItem beanDiscovery,
+ CamelContextBuildItem context,
+ CamelContextRecorder recorder) {
+
+ Set<String> observedLifecycleEvents = beanDiscovery.getObservers()
+ .stream()
+ .map(observerInfo ->
observerInfo.getObservedType().name().toString())
+ .filter(observedType ->
observedType.startsWith("org.apache.camel.quarkus.core.events"))
+
.collect(Collectors.collectingAndThen(Collectors.toUnmodifiableSet(),
HashSet::new));
+
+ // For management events the event class simple name is collected as
users can
+ // observe events on either the Camel event interface or the concrete
event class, and
+ // these are located in different packages
+ Set<String> observedManagementEvents = beanDiscovery.getObservers()
+ .stream()
+ .map(observerInfo ->
observerInfo.getObservedType().name().toString())
+ .filter(className ->
className.matches("org.apache.camel(?!.quarkus).*Event$"))
+ .map(className -> CamelSupport.loadClass(className,
Thread.currentThread().getContextClassLoader()))
+ .map(observedEventClass -> observedEventClass.getSimpleName())
Review comment:
👍
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]