5,Spring的配置文件如下:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://camel.apache.org/schema/spring"
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"
default-autowire="byName" default-init-method="init">
<bean id="fmBean" class="com.test.camel.freemarker.FmProcessorBean"/>
<camelContext id="testCamelContext" xmlns="http://camel.apache.org/schema/spring">
<package>com.test.camel.freemarker</package>
</camelContext>
</beans>
6,启动Spring,在D:\temp\outbox文件夹下,每隔10秒钟,会根据freemarker模板生成一个fm.xml文件.
ApplicationContext ac = new ClassPathXmlApplicationContext("config/camelFreemarker.xml");
while (true) {
Thread.sleep(2000);
}
对本例beanRef("fmBean","prepareFMValues")的解释:
其意思是调用fmBean的prepareFMValues方法,Camel会负责将message的body绑定到要调用方法的第一个参数上面,其中可能做相应的类型转换.(本例中的方法的第一个参数为Exchange,没有转换的过程 ),这里给一个如下示例图解释这个绑定转换的过程:Camel将Exchange的的input message(exchange.getIn())转换为String,绑定到mtd方法的name参数上.

