手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

Apache Camel框架之Freemarker做数据转换

[日期:2012-02-12] 来源:Linux社区  作者:kkdelta [字体:大 中 小]

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参数上.

linux
相关资讯       Apache 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款