AmbuSreedharan
AmbuSreedharan

Reputation: 181

Mule ESB 3.4 Context property

How can one access the properties loaded by context:place-holder in a scripting component other than having to use ${property-name}? I want to get to the object that holds these key value pairs. Something like context.getProperty("property-name").

Upvotes: 1

Views: 1010

Answers (1)

genjosanzo
genjosanzo

Reputation: 3264

Spring property placeholders are resolved at configuration time and not stored anywhere, so they cant be loaded afterwards.

If you need to store it you can always inject them into a bean and retrieve that from the registry.

Basically all you need to do is to declare your bean:

<spring:bean class="your.Bean" name="yourBean" >
   <spring:property name="yourBeanAttribute" value="${somePlaceHolder}" />
</spring:bean>

and then you can retrieve it, and the somePlaceHolder value from the registry from within a scripting component/transformer:

<scripting:transformer doc:name="Script">
 <scripting:script engine="Groovy">
  <scripting:text><![CDATA[
def val = muleContext.getRegistry().lookupObject('yourBean').getYourBeanAttribute()
]]></scripting:text>
  </scripting:script>
 </scripting:transformer>

HTH

Upvotes: 5

Related Questions