@Bean public HelloBean helloBean() { HelloBean helloBean = new HelloBean (); if (condition) { helloBean.setDependency(dependencyA()); } else { helloBean.setDependency(dependencyB()); } return helloBean; }
public void process(Exchange exchange) throws Exception { // extract the name parameter from the Camel message which we want to use // when invoking the bean String name = exchange.getIn().getBody(String.class); // now create an instance of the bean HelloBean hello = new HelloBean(); // and invoke it with the name parameter String answer = hello.hello(name); // store the reply from the bean on the OUT message exchange.getOut().setBody(answer); } });
public static void main(String[] args) throws Exception { Main main = new Main(); // bind the bean to the Camel registry using the name hello main.bind("hello", new HelloBean()); // add the route main.addRouteBuilder(new HelloRoute()); // run the application main.run(); } }
public void process(Exchange exchange) throws Exception { // extract the name parameter from the Camel message which we want to use // when invoking the bean String name = exchange.getIn().getBody(String.class); // invoke the bean which should have been injected by Spring String answer = hello.hello(name); // store the reply from the bean on the OUT message exchange.getOut().setBody(answer); } });