如何使用Spring声明骆驼生产商
我不熟悉spring和Camel,很难准确理解Camel bean集成的这一部分需要什么: “如果一个bean是在SpringXML中定义的,或者使用Spring组件扫描机制扫描的,并且使用了一个或一个CamelBeanPostProcessor,那么我们将处理大量的Camel注释” 我在spring上下文文件中声明了一个驼峰上下文,并将其部署为OSGI捆绑包:如何使用Spring声明骆驼生产商,spring,apache-camel,Spring,Apache Camel,我不熟悉spring和Camel,很难准确理解Camel bean集成的这一部分需要什么: “如果一个bean是在SpringXML中定义的,或者使用Spring组件扫描机制扫描的,并且使用了一个或一个CamelBeanPostProcessor,那么我们将处理大量的Camel注释” 我在spring上下文文件中声明了一个驼峰上下文,并将其部署为OSGI捆绑包: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="timer://myTimer?fixedRate=true&period=2000"/>
<to uri="log:ExampleRouter"/>
</route>
</camelContext>
</beans>
。。。因此,正在加载配置文件,但有一些线路缺失,我无法确定
谢谢
=============编辑============
再进一步研究一下,由于没有使用Aspect Weaver,我显然需要使用spring管理的bean来实现这些注释。似乎在OSGI上下文中,我应该从由Camel bundle启动的Spring应用程序上下文中获取bean。
因此,我将POJO中的@product注释替换为以下java代码:
Dictionary<String,String> filter = new Hashtable<>();
filter.put("org.springframework.context.service.name",
<name of my camel bundle");
tracker = ServiceHelper.create(context, ApplicationContext.class, filter);
producer = tracker.getService().getBean(CrudEditProducer.class);
字典过滤器=新哈希表();
filter.put(“org.springframework.context.service.name”,
defining beans [CrudEditManager]; root of factory hierarchy
Dictionary<String,String> filter = new Hashtable<>();
filter.put("org.springframework.context.service.name",
<name of my camel bundle");
tracker = ServiceHelper.create(context, ApplicationContext.class, filter);
producer = tracker.getService().getBean(CrudEditProducer.class);