Skip to content

Commit 3373307

Browse files
authored
Merge pull request #3989 from jooby-project/3987
camel: dump application.properties + event notifier
2 parents f96aaf2 + 959c5ac commit 3373307

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

modules/jooby-camel/src/main/java/io/jooby/camel/CamelModule.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
import org.apache.camel.builder.RouteBuilder;
1818
import org.apache.camel.impl.DefaultCamelContext;
1919
import org.apache.camel.main.SimpleMain;
20+
import org.apache.camel.spi.EventNotifier;
2021

2122
import io.jooby.Extension;
2223
import io.jooby.Jooby;
24+
import io.jooby.Reified;
2325
import io.jooby.ServiceRegistry;
2426
import io.jooby.internal.camel.JoobyCamelContext;
2527
import io.jooby.internal.camel.SingletonProvider;
@@ -157,6 +159,14 @@ public void install(Jooby application) throws Exception {
157159

158160
application.onStarting(
159161
() -> {
162+
// dump configuration as initial properties, enabled camel auto-configuration
163+
var config = application.getConfig();
164+
if (config.hasPath("camel")) {
165+
for (var prop : config.getConfig("camel").entrySet()) {
166+
main.addInitialProperty(
167+
"camel." + prop.getKey(), prop.getValue().unwrapped().toString());
168+
}
169+
}
160170
// build camel
161171
main.init();
162172

@@ -167,6 +177,14 @@ public void install(Jooby application) throws Exception {
167177
camel.addRoutes(route);
168178
}
169179
}
180+
// Do events
181+
Reified<List<EventNotifier>> eventType = Reified.list(EventNotifier.class);
182+
var events = application.getServices().getOrNull(eventType);
183+
if (events != null) {
184+
for (var event : events) {
185+
camel.getManagementStrategy().addEventNotifier(event);
186+
}
187+
}
170188
// Start camel:
171189
main.start();
172190
});

0 commit comments

Comments
 (0)