我会创建一个动态的路线建设者,例如
public class MyRouteBuilder extends RouteBuilder { private String another; private String letter; public MyRouteBuilder(CamelContext context,String another, String letter) { super(context); this.another=another; this.letter=letter; } @Override public void configure() throws Exception { super.configure(); from("restlet:/"+another+"?restletMethods=GET") .to("first:run_"+letter) .to("second:jump_"+letter) .to("third:fly_"+letter); } }
并添加到某个事件,例如
public class ApplicationContextProvider implements ApplicationContextAware { @Override public void setApplicationContext(ApplicationContext context) throws BeansException { camelContext=(CamelContext)context.getBean("mainCamelContext"); camelContext.addRoutes(new MyRouteBuilder(camelContext, "another1","A")); camelContext.addRoutes(new MyRouteBuilder(camelContext, "another2","B"));..
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)