I am looking to pass back the list of 'Userdefined' configuration list from Java to ESQL in IIB. I can pass back the single value but looking for the complete list. Below is the Java and ESQL code. Any inputs are much appreciated.
ESQL code:
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 Code:
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();
}
}
}
I need to pass back the siteCodeArray
to ESQL.
So ESQL doesn't do arrays but you can create a set of nodes in the Environment tree. Get a pointer to the Environment tree and create a subtree containing a set of nodes one for each entry in the array.
Embed something like this into your code.