Reputation: 37
I have a properties file that contains a path value that I want to load in for use within my program.
I have the following in my XML
<flow doc:name="Flow1" name="Flow1">
<http:inbound-endpoint doc:description="This endpoint receives an HTTP message."
doc:name="HTTP" exchange-pattern="request-response" host="localhost"
port="8081" contentType="text/html" />
<custom-transformer class="com.test.app.mule.ReadFile" doc:name="Java">
<spring:property name="path" value="${key.path1}" />
</custom-transformer>
and the following in my java code (which loads a file from the specified path from the properties file)
public class ReadFile extends AbstractMessageTransformer {
private String path;
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
/**
* loads the content of the file specified in the parameter
*
* @param filename
* the name of the file
* @return the content of the file
*
*
*/
public String readFile(String filename, String filePath) {
File file1 = new File(path, filePath);
This works fine however I am wondering is there any way to modify what I have to allow for the use of the @value annotation
private @Value("${key.path1") String path;
and get rid of the setters and getters?
Mule doesn't seem to play nice when doing so.
Upvotes: 0
Views: 1053
Reputation: 378
You need to configure the properties on the spring:
Mule ESB:Context Property Placeholder
Mule- Access spring property placeholder inside groovy component
property placeholder in mule configuration is resolved from one file but not from the other
https://docs.mulesoft.com/mule-user-guide/v/3.6/configuring-properties
Upvotes: 1