问题
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