We support the injection of various resources using @EndpointInject or @BeanInject. This can be used to inject
- Endpoint instances which can be used for testing when used with Mock endpoints; see the Spring Testing for an example.
- ProducerTemplate instances for POJO Producing
- client side proxies for POJO Producing which is a simple approach to Spring Remoting
From Camel 2.13 onwards you can inject beans (obtained from the Registry) into your beans such as
For example to inject a bean named foo, you can enlist the bean in the Registry such as in a Spring XML file:
And then in a Java
RouteBuilder class, you can inject the bean using
@BeanInject as shown below:
If you omit the name, then Camel does a lookup by type, and injects the bean if there is exactly only one bean of that type enlisted in the Registry.