How to reload a properties file in Apache Camel 2.12?

青春壹個敷衍的年華 提交于 2019-12-25 06:58:15

问题


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

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

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

public class MediatType {

    private List<String> mediaTypeList;

    // GETTERs and SETTERs

}

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.

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.

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.

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

Regards,


回答1:


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}}" />


来源:https://stackoverflow.com/questions/36983965/how-to-reload-a-properties-file-in-apache-camel-2-12

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!