Skip to content
Merged
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
18 changes: 18 additions & 0 deletions modules/jooby-camel/src/main/java/io/jooby/camel/CamelModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.main.SimpleMain;
import org.apache.camel.spi.EventNotifier;

import io.jooby.Extension;
import io.jooby.Jooby;
import io.jooby.Reified;
import io.jooby.ServiceRegistry;
import io.jooby.internal.camel.JoobyCamelContext;
import io.jooby.internal.camel.SingletonProvider;
Expand Down Expand Up @@ -157,6 +159,14 @@ public void install(Jooby application) throws Exception {

application.onStarting(
() -> {
// dump configuration as initial properties, enabled camel auto-configuration
var config = application.getConfig();
if (config.hasPath("camel")) {
for (var prop : config.getConfig("camel").entrySet()) {
main.addInitialProperty(
"camel." + prop.getKey(), prop.getValue().unwrapped().toString());
}
}
// build camel
main.init();

Expand All @@ -167,6 +177,14 @@ public void install(Jooby application) throws Exception {
camel.addRoutes(route);
}
}
// Do events
Reified<List<EventNotifier>> eventType = Reified.list(EventNotifier.class);
var events = application.getServices().getOrNull(eventType);
if (events != null) {
for (var event : events) {
camel.getManagementStrategy().addEventNotifier(event);
}
}
// Start camel:
main.start();
});
Expand Down
Loading