The service is then able to trigger some useful actions on the Camel contexts it owns, described below. See the javadoc for more details.
// Start a new context for the application
this.camelContextName = this.camelService.startNewContext();
// Stop a Camel context
this.camelService.stop(this.camelContextName);;
...
// Prepare a route to add in the created context
RouteBuilder builder = new RouteBuilder() {
@Override
public void configure() throws Exception {
this.from("joram:queue:queueSample").to("file:///tmp/test");
}
};
// Add the route in the camel context.
this.camelService.addRoutes(builder, this.camelContextName);
...
// Add the registry entries
ClassLoader cl = this.getClass().getClassLoader();
InputStream input = cl.getResourceAsStream("registry.xml");
this.camelService.addRegistry(input, this.camelContextName);
// Remove entries from the registry
ClassLoader cl = this.getClass().getClassLoader();
InputStream input = cl.getResourceAsStream("registry.xml");
this.camelService.removeRegistry(input, this.camelContextName);
// Add the JORAM component
JmsComponent joram = new JmsComponent();
ConnectionFactory connectionFactory;
connectionFactory = (ConnectionFactory) new InitialContext().lookup("CF");
joram.setConnectionFactory(connectionFactory);
JndiDestinationResolver jndiDestinationResolver = new JndiDestinationResolver();
jndiDestinationResolver.setCache(true);
joram.setDestinationResolver(jndiDestinationResolver);
this.camelService.addComponent("joram", joram, this.camelContextName);
...
// Prepare a route to add in the created context
RouteBuilder builder = new RouteBuilder() {
@Override
public void configure() throws Exception {
this.from("joram:queue:queueSample").to("file:///tmp/test");
}
};
...