Camel how to add something to registry - with java, in general

后端 未结 3 885
逝去的感伤
逝去的感伤 2020-12-20 16:39

sometimes I have to add an object to camel registry (of course with java). In most cases it is a dataSource .

My problem is I can\'t figure out a general working way

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-20 16:54

    If you are using Spring with camel you can register your bean in Application context and it will be get registered in ApplicationContextRegistry.

    eg. ConfigurableListableBeanFactory beanFactory = ((ConfigurableApplicationContext) applicationContext).getBeanFactory(); beanFactory.registerSingleton("beantolookup", bean);

    And you can look up camelContext.getRegistry().lookupByName("beantolookup")

提交回复
热议问题