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

查看:38
本文介绍了如何在 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 配置路由.我还阅读了 this 以使用 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天全站免登陆