/**
* A simple example router from a file system to an ActiveMQ queue and then to a file system
*
* @version $Revision$
*/
@Configuration
public class MyRouteConfig extends SingleRouteCamelConfiguration implements InitializingBean, BundleContextAware {
private BundleContext bundleContext;
/**
* Allow this route to be run as an application
*
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
new Main().run(args);
}
public BundleContext getBundleContext() {
return bundleContext;
}
public void setBundleContext(BundleContext bundleContext) {
this.bundleContext = bundleContext;
}
/**
* Returns the CamelContext which support OSGi
*/
@Override
protected CamelContext createCamelContext() throws Exception {
SpringCamelContextFactory factory = new SpringCamelContextFactory();
factory.setApplicationContext(getApplicationContext());
factory.setBundleContext(getBundleContext());
return factory.createContext();
}
@Override
protected void setupCamelContext(CamelContext camelContext) throws Exception {
JmsComponent answer = new JmsComponent();
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
connectionFactory.setBrokerURL("vm:);
answer.setConnectionFactory(connectionFactory);
camelContext.addComponent("jms", answer);
}
public static class SomeBean {
public void someMethod(String body) {
System.out.println("Received: " + body);
}
}
@Bean
@Override
public RouteBuilder route() {
return new RouteBuilder() {
public void configure() {
from("file:src/data?noop=true").
to("jms:test.MyQueue");
from("jms:test.MyQueue").
to("file:);
from("file:).
bean(new SomeBean());
}
};
}
public void afterPropertiesSet() throws Exception {
}
}