File tree Expand file tree Collapse file tree
modules/jooby-camel/src/main/java/io/jooby/camel Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717import org .apache .camel .builder .RouteBuilder ;
1818import org .apache .camel .impl .DefaultCamelContext ;
1919import org .apache .camel .main .SimpleMain ;
20+ import org .apache .camel .spi .EventNotifier ;
2021
2122import io .jooby .Extension ;
2223import io .jooby .Jooby ;
24+ import io .jooby .Reified ;
2325import io .jooby .ServiceRegistry ;
2426import io .jooby .internal .camel .JoobyCamelContext ;
2527import 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 });
You can’t perform that action at this time.
0 commit comments