0

我希望将“用户定义”配置列表从 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。

4

1 回答 1

0

所以 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());
}
于 2018-11-05T08:30:08.967 回答