简体   繁体   中英

How to access the values from properties file from Groovy script in Mule 3.5

由于我们可以使用$ {}访问属性文件中的值,在mule流中的任何位置,我们如何从groovy脚本中访问这些值?

  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.

${} 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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM