【问题标题】:Passing back Array from Java to ESQL in IIB在 IIB 中将数组从 Java 传回 ESQL
【发布时间】:2019-02-19 05:15:03
【问题描述】:

我希望将“用户定义”配置列表从 Java 传递回 IIB 中的 ESQL。我可以传回单个值,但要查找完整列表。下面是 Java 和 ESQL 代码。非常感谢任何意见。

ESQL 代码:

CREATE COMPUTE MODULE SiteCodeValdationRoutine_Compute
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
    CALL CopyEntireMessage();           
    CALL getSiteCodeProperties(Environment.MFT.Sitecode);   
    RETURN TRUE;
END;

CREATE PROCEDURE CopyEntireMessage() BEGIN
    SET OutputRoot = InputRoot;
END;

CREATE PROCEDURE getSiteCodeProperties( OUT Sitecode CHARACTER)
    LANGUAGE JAVA EXTERNAL NAME "com.nb.iib.util.SiteCodeParameterLookup.getSiteCodeParameters";
END MODULE;

Java 代码:

package com.nb.iib.util;

import java.util.Properties;
import com.ibm.broker.config.proxy.BrokerProxy;
import com.ibm.broker.config.proxy.ConfigurableService;

public class SiteCodeParameterLookup {

    public static void getSiteCodeParameters(String siteCodeArray[]) {

        siteCodeArray = new String[10];
        BrokerProxy bp = null;
        try {
            // Grab Local Broker Proxy
            bp = BrokerProxy.getLocalInstance();
            if (bp == null) {
                throw new IllegalStateException("Could not obtain Broker Proxy Connection");
            }
            // Search up
            ConfigurableService[] ud_set = bp.getConfigurableServices("UserDefined");
            if (ud_set == null) {
                throw new IllegalStateException("Could not find Site Code value under User Defined Properties: ");
            }

            // Add
            System.out.println("Configurable Service Name :" + ud_set[0].getName());

            for (int i = 0; i < 1; i++) {
                siteCodeArray[i] = ud_set[i].getName();
            }
        } catch (Throwable t) {
            throw new IllegalStateException(
                    "SiteCodeNotConfigured. Sitecode configuration missing in User Definied Properties", t);
        } finally {
            // Disconnect Broker Proxy when use is complete
            if (bp != null)
                bp.disconnect();
        }
    }
}

我需要将 siteCodeArray 传回给 ESQL。

【问题讨论】:

    标签: java integration extended-sql


    【解决方案1】:

    所以 ESQL 不做数组,但您可以在环境树中创建一组节点。获取指向 Environment 树的指针并创建一个子树,其中包含一组节点,每个节点对应数组中的每个条目。

    在您的代码中嵌入类似的内容。

    MbMessage env = assembly.getGlobalEnvironment();
    MbElement siteCodes = env.getRootElement().createElementAsLastChild(MbElement.TYPE_NAME, "SiteCodes", null);
    for(ConfigurableService cs: ud_set) {
        siteCodes.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "SiteCode", cs.getName());
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-05-30
      • 1970-01-01
      • 2017-07-10
      • 2023-04-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多