...
Code Block |
---|
|
@Named("foo")
class MyBean {
//...
}
from("direct:inbound").bean("foo"); |
Referring beans from Endpoint URIs
When configuring endpoints using the URI syntax you can refer to beans in the Registry using the #
notation. If the URI parameter value starts with a #
sign then Camel CDI will lookup for a bean of the given type by name, e.g.:
Code Block |
---|
|
from("jms:queue:{{destination}}?transacted=true&transactionManager=#jtaTransactionManager").to("..."); |
Having the following CDI bean qualified with @Named("jtaTransactionManager")
:
Code Block |
---|
|
@Produces
@Named("jtaTransactionManager")
PlatformTransactionManager createTransactionManager(TransactionManager transactionManager, UserTransaction userTransaction) {
JtaTransactionManager jtaTransactionManager = new JtaTransactionManager();
jtaTransactionManager.setUserTransaction(userTransaction);
jtaTransactionManager.setTransactionManager(transactionManager);
jtaTransactionManager.afterPropertiesSet();
return jtaTransactionManager;
} |
...