2

As we can access values from properties file using ${}, anywhere inside the mule flow,how can we access these values from a groovy script?

shrinathM
  • 362
  • 3
  • 22

2 Answers2

6
  1. Refer the properties file under property placeholder element in xml.
  2. Refer the values from properties file using ${key} at any place in Groovy script.
shrinathM
  • 362
  • 3
  • 22
3

${} properties get expanded in your xml when starting your application, the solution would be the same than for any other value you want available in the groovy script. I would save it as a flow variable and then retrieve it from Groovy through the message:

<flow name="reading-properties">
    <set-variable variableName="myvar" value="${myvar}" />
    <scripting:transformer name="readingProperties">
        <scripting:script engine="groovy">
            myvar = message.getInvocationProperty('myvar')
            ....
         </scripting:script>
    </scripting:transformer> 
</flow>
Ale Sequeira
  • 2,039
  • 1
  • 11
  • 19
  • Actually I found the solution myself and it seems to be working. You can use ${} inside the script and the values from property placeholder are replaced from properties file. Your solution can be a workaround at times.Thanks. – shrinathM Jul 17 '14 at 09:15
  • Can you add your answer so is highlighted? – Ale Sequeira Jul 17 '14 at 13:24