Mule ESB 3.4 Context property

匿名 (未验证) 提交于 2019-12-03 10:10:24

问题:

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").

回答1:

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



转载请标明出处:Mule ESB 3.4 Context property
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!