7

I am trying to learn Spring and understand how it works. I have followed some tutorials in setting up Spring and Camel, and have had it working using default setups.

I am now attempting to convert as much as possible of my configuration XML-files to Java-classes. So far I have been successful in creating the camel-routes in a Java-class (extending SpringRouteBuilder and implementing configure() ), and all the beans from my spring-configuration file (Bean->Function with @Bean). The only part I am missing is the camelContext definition (?) that starts my camel routes (I think...):

<camel:camelContext id="camel5">
    <camel:package>net.krg.kneip.routing</camel:package>
</camel:camelContext>

What would the equivalent non-XML of this be?

Not sure if it will help, but here is my AppConfig class so far: http://pastebin.com/vsRAbpK1

Thanks!

SOLUTION:

@Bean
public CamelContext camel() throws Exception{   
  CamelContext camelContext = new DefaultCamelContext();    
  camelContext.addRoutes(new net.krg.kneip.routing.Routes());
  camelContext.start();
  return camelContext;      
}
4

1 回答 1

7
CamelContext context = new DefaultCamelContext();

我想这就是你要找的。

在这里阅读更多

于 2013-04-19T09:43:38.820 回答