camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Blair <blair.nils...@gmail.com>
Subject Re: How do I stop the RouteBuilders from caching the routes they build?
Date Tue, 22 Mar 2011 04:35:46 GMT
ok, after changing how I was going about this, I have found a elegant enough
way of doing this.


@Component
public class ReloadRoutes implements ApplicationContextAware {

    public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {
        this.applicationContext = applicationContext;
    }

    ApplicationContext applicationContext;

    public String reload(String camelContextName) throws Exception {
        CamelContextFactoryBean camelContextFactory =
applicationContext.getBean("&" + camelContextName,
CamelContextFactoryBean.class);
        SpringCamelContext camelContext = camelContextFactory.getContext();
        camelContext.stop();
        camelContext.destroy();
        camelContextFactory.setContext(null);
        for (RouteBuilder
rb:applicationContext.getBeansOfType(RouteBuilder.class).values()) {
            rb.getRouteCollection().setRoutes(new ArrayList()); // must
clear the routes!
            rb.configure();
        }
        camelContextFactory.afterPropertiesSet();
        camelContextFactory.getContext(true).start();
        return "ok";
    }

}


--
View this message in context: http://camel.465427.n5.nabble.com/How-do-I-stop-the-RouteBuilders-from-caching-the-routes-they-build-tp4248807p4248915.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message