如何从 WSO2 ESB 和注册表访问系统属性 [英] How to access system property from WSO2 ESB and Registry

查看:25
本文介绍了如何从 WSO2 ESB 和注册表访问系统属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 WSO2 ESB 代理服务引用了一个端点,该端点位于各种环境中的不同 URL 中 - DEV、TEST、PROD.根据 WSO2 文档,我需要将端点定义存储在治理注册表中,并在每个环境中修改端点 XML 文件中的 URL.对于拥有 1 或 2 个代理的组织来说,这可能很好,但对于 10 个以上的代理来说,这会成为一笔巨大的开销.

My WSO2 ESB proxy service references an endpoint which is located at different URLs in various environments - DEV, TEST, PROD. According to the WSO2 documentation, I need to store the endpoint definition in the Governance Registry and modify the URL in endpoint XML file in each environment. That might work fine for the organizations with 1 or 2 proxies, but becomes a significant overhead for a 10+ proxies.

另一种情况是我需要在 ESB 序列中读取某些特定于环境的属性.

Another scenario is when I need to read certain environment-specific properties in my ESB sequence.

有没有办法在外部 *.properties 文件中定义一堆属性,然后在 ESB 和注册表定义中读取它们?

Is there a way to define a bunch of properties in the external *.properties file and then read them within the ESB and Registry definitions?

推荐答案

您可以使用脚本中介访问 ESB 序列/代理服务内的系统属性,如下所示;

You can access system properties inside ESB sequences/proxy services using the script mediator as follows;

    <script language="js">mc.setProperty("file.separator",java.lang.System.getProperty("file.separator"));</script>
    <log level="custom">
       <property name="file.separator" expression="get-property('file.separator')"/>
    </log>

此处file.separator"属性设置为脚本中介器内消息上下文中的属性,可用于后续中介器.

Here "file.separator" property is set as the property in the message context inside the script mediator and it can be used in subsequent mediators.

您还可以访问在 ESB 注册表中的文件中定义的属性.例如,如果您在配置注册表 (test.xml) 中有一个包含以下内容的文件,

You also can access properties defined in a file in ESB registry. For example if you have a file in configuration registry (test.xml) with the following content,

<a>Helloo<b>World</b></a>

中的文本元素World"可以使用属性中介访问,如下所示,

The text element "World" in <b> can be accessed using property mediator as follows,

<property name="test" expression="get-property('registry','conf:/test.xml')" scope="default" type="OM"/>
<log level="custom">
      <property name="test.b" expression="$ctx:test//b"/>
</log>

这篇关于如何从 WSO2 ESB 和注册表访问系统属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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