如何在Apache Camel 2.12中重新加载属性文件? [英] How to reload a properties file in Apache Camel 2.12?

查看:150
本文介绍了如何在Apache Camel 2.12中重新加载属性文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做两件事:将属性加载到bean中,并在更新属性时更新bean.

I want to do two things: Load a properties into a bean and update the bean when properties is updated.

我使用JBoss Fuse 6.1来安装我的应用程序包,并在服务器上有一个属性文件,我需要阅读一些配置.这些属性包含以下行:

I use JBoss Fuse 6.1 where to install my application bundle and have a properties file on the server where I need to read some configuration. The properties have the follow line:

mediaTypeList=JSON,DOCX,TXT

我有一个Java Bean,它是文件属性的镜像:

And I have a Java Bean that is a mirror of the file property:

public class MediatType {

    private List<String> mediaTypeList;

    // GETTERs and SETTERs

}

属性 mediaTypeList 指示应用程序允许的HTTP MediaType列表,并且该列表可能会随着时间的推移进行更新,因此应用程序必须查看更改.

The property mediaTypeList indicate the list of HTTP MediaType that the application admit, and this list could be updated over time so the application have to see the changes.

应用程序接收文件上传请求,并且只有在允许文件类型的情况下,才能上传文件.为了验证这一点,我需要使用bean读取属性文件.

The application receive file upload request and only if the file type is admited the file can be uploaded. To validate this I need to read the property file using a bean.

我使用Apache Camel 2.12并通过Java DSL配置路由.另外,我阅读了,以使用 PropertyPlaceholder ,但它不符合我的要求.

I use Apache Camel 2.12 and configure the route by Java DSL. Also I read this for loading properties in beans using PropertyPlaceholder but it does not fit my requirements.

是否可以使用Apache Camel PropertyPlaceholder满足以上要求?还是有另一种方法?

Is there a way to do the above requirements with Apache Camel PropertyPlaceholder? Or there another way?

此致

推荐答案

在蓝图文件中,使用 cm:property-placeholder 并创建名称为 sample.cfg 的属性文件.并将其放在$ FUSE_HOME/etc文件夹中

In blueprint file use cm:property-placeholder and create a property file with name sample.cfg and place it in $FUSE_HOME/etc folder

<cm:property-placeholder persistent-id="sample"
update-strategy="reload">
</cm:property-placeholder>

在骆驼路线中,您可以使用

In camel route you can read property using

<from uri="timer:foo?period={{period}}" />

这篇关于如何在Apache Camel 2.12中重新加载属性文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆