Mule ESB 3.4上下文属性 [英] Mule ESB 3.4 Context property

查看:160
本文介绍了Mule ESB 3.4上下文属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

除了必须使用${property-name}之外,如何才能访问脚本组件中context:place-holder加载的属性?我想找到包含这些键值对的对象. context.getProperty("property-name")之类的东西.

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

推荐答案

Spring属性占位符在配置时解析,并且不存储在任何地方,因此以后无法加载.

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

如果需要存储它,可以随时将它们注入到bean中,然后从注册表中检索出来.

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

基本上,您需要做的就是声明您的bean:

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>

然后您可以从脚本组件/转换器中从注册表中检索它以及somePlaceHolder值:

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上下文属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆