...
Code Block | ||
---|---|---|
| ||
@ApplicationScoped class CustomCamelContext extends DefaultCamelContext { @PostConstruct void customize() { // Set the Camel context name setName("custom"); // Disable JMX disableJMX(); } @PreDestroy void cleanUp() { // ... } } |
Producer and disposer methods can also be used as well to customize the Camel context bean, e.g.:
Code Block | ||
---|---|---|
| ||
class CamelContextFactory { @Produces @ApplicationScoped CamelContext customize() { DefaultCamelContext context = new DefaultCamelContext(); context.setName("custom"); return context; } void cleanUp(@Disposes CamelContext context) { // ... } } |
...
The corresponding CDI beans are automatically deployed and can be injected, e.g.:
Code Block | ||
---|---|---|
| ||
@Inject @ContextName("foo") CamelContext context; @Inject @Named("bar") Endpoint endpoint; |
...
A reference to that bean can be declared in the imported Camel XML configuration, e.g.:
Code Block | ||
---|---|---|
| ||
<camelContext id="foo"> <route> <from uri="..."/> <process ref="baz"/> </route> <camelContext/> |
...