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