SimpleRegistry实际上是基于Map的注册,它主要被用于测试,或者单独的运行camel。
下面举一个例子,使用SimpleRegistry去单元测试Camel路由。
public class HelloBean {
public String hello(String name) {
return "Hello " + name;
}
}
public class SimpleRegistryTest extends TestCase {
private CamelContext context;
private ProducerTemplate template;
protected void setUp() throws Exception {
SimpleRegistry registry = new SimpleRegistry();
registry.put("helloBean", new HelloBean());
context = new DefaultCamelContext(registry);
template = context.createProducerTemplate();
context.addRoutes(new RouteBuilder() {
public void configure() throws Exception {
from("direct:hello").beanRef("helloBean");
}
});
context.start();
}
protected void