0

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.

gio10245
  • 37
  • 2
  • 13

1 Answers1

1

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

Community
  • 1
  • 1
Ismael G.
  • 378
  • 1
  • 2
  • 10
  • On the spring? That's very vague, none of the links provided help with this issue. – gio10245 Oct 15 '15 at 13:26
  • What you trying to do is to access the properties by annotation. The way I know is configure the context place holder on the Mule and then inject the property by @Value. I will find an example to post here. – Ismael G. Oct 15 '15 at 14:04