Search in sources :

Example 11 with ConfigurationException

use of org.jpos.core.ConfigurationException in project jPOS by jpos.

the class MD5Filter method setConfiguration.

/**
 * @param cfg
 * <ul>
 * <li>key    - initial key
 * <li>fields - Space separated field list
 * </ul>
 */
public void setConfiguration(Configuration cfg) throws ConfigurationException {
    key = cfg.get("key");
    String fieldList = cfg.get("fields");
    if (fieldList == null)
        throw new ConfigurationException("'fields' property not present");
    StringTokenizer st = new StringTokenizer(fieldList);
    int[] f = new int[st.countTokens()];
    for (int i = 0; i < f.length; i++) f[i] = Integer.parseInt(st.nextToken());
    fields = f;
}
Also used : StringTokenizer(java.util.StringTokenizer) ConfigurationException(org.jpos.core.ConfigurationException)

Example 12 with ConfigurationException

use of org.jpos.core.ConfigurationException in project jPOS by jpos.

the class XSLTFilter method setConfiguration.

/**
 * configure filter.
 *
 * <ul>
 *  <li>xsltfile - source XSL-T file
 *  <li>reread   - something != "no" will re-read source file
 * </ul>
 *
 * @param cfg new ConfigurationFile
 */
public void setConfiguration(Configuration cfg) throws ConfigurationException {
    try {
        transformer = tfactory.newTransformer(new StreamSource(cfg.get("xsltfile")));
        String s = cfg.get("reread");
        reread = s == null || s.equals("no");
    } catch (Exception e) {
        throw new ConfigurationException(e);
    }
}
Also used : ConfigurationException(org.jpos.core.ConfigurationException) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) StreamSource(javax.xml.transform.stream.StreamSource) ConfigurationException(org.jpos.core.ConfigurationException) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) ISOException(org.jpos.iso.ISOException)

Example 13 with ConfigurationException

use of org.jpos.core.ConfigurationException in project jPOS by jpos.

the class ChannelAdaptor method initSpaceAndQueues.

protected void initSpaceAndQueues() throws ConfigurationException {
    Element persist = getPersist();
    sp = grabSpace(persist.getChild("space"));
    in = persist.getChildTextTrim("in");
    out = persist.getChildTextTrim("out");
    writeOnly = "yes".equalsIgnoreCase(getPersist().getChildTextTrim("write-only"));
    if (in == null || (out == null && !writeOnly)) {
        throw new ConfigurationException("Misconfigured channel. Please verify in/out queues");
    }
    String s = persist.getChildTextTrim("reconnect-delay");
    // reasonable default
    delay = s != null ? Long.parseLong(s) : 10000;
    keepAlive = "yes".equalsIgnoreCase(persist.getChildTextTrim("keep-alive"));
    ignoreISOExceptions = "yes".equalsIgnoreCase(persist.getChildTextTrim("ignore-iso-exceptions"));
    String t = persist.getChildTextTrim("timeout");
    timeout = t != null && t.length() > 0 ? Long.parseLong(t) : 0l;
    ready = getName() + ".ready";
    reconnect = getName() + ".reconnect";
    waitForWorkersOnStop = "yes".equalsIgnoreCase(persist.getChildTextTrim("wait-for-workers-on-stop"));
}
Also used : ConfigurationException(org.jpos.core.ConfigurationException) Element(org.jdom2.Element)

Example 14 with ConfigurationException

use of org.jpos.core.ConfigurationException in project jPOS by jpos.

the class MUXPool method initService.

public void initService() throws ConfigurationException {
    Element e = getPersist();
    muxName = toStringArray(e.getChildTextTrim("muxes"));
    strategy = getStrategy(e.getChildTextTrim("strategy"));
    overrideMTIs = toStringArray(e.getChildTextTrim("follower-override"));
    originalChannelField = e.getChildTextTrim("original-channel-field");
    splitField = e.getChildTextTrim("split-field");
    checkEnabled = cfg.getBoolean("check-enabled");
    sp = grabSpace(e.getChild("space"));
    mux = new MUX[muxName.length];
    try {
        for (int i = 0; i < mux.length; i++) mux[i] = QMUX.getMUX(muxName[i]);
    } catch (NameRegistrar.NotFoundException ex) {
        throw new ConfigurationException(ex);
    }
    NameRegistrar.register("mux." + getName(), this);
}
Also used : NameRegistrar(org.jpos.util.NameRegistrar) ConfigurationException(org.jpos.core.ConfigurationException) Element(org.jdom2.Element)

Example 15 with ConfigurationException

use of org.jpos.core.ConfigurationException in project jPOS by jpos.

the class QMUX method initService.

public void initService() throws ConfigurationException {
    Element e = getPersist();
    sp = grabSpace(e.getChild("space"));
    isp = cfg.getBoolean("reuse-space", false) ? sp : new TSpace();
    in = e.getChildTextTrim("in");
    out = e.getChildTextTrim("out");
    if (in == null || out == null) {
        throw new ConfigurationException("Misconfigured QMUX. Please verify in/out queues");
    }
    ignorerc = e.getChildTextTrim("ignore-rc");
    key = toStringArray(DEFAULT_KEY, ", ", null);
    returnRejects = cfg.getBoolean("return-rejects", false);
    for (Element keyElement : e.getChildren("key")) {
        String mtiOverride = keyElement.getAttributeValue("mti");
        if (mtiOverride != null && mtiOverride.length() >= 2) {
            mtiKey.put(mtiOverride.substring(0, 2), toStringArray(keyElement.getTextTrim(), ", ", null));
        } else {
            key = toStringArray(e.getChildTextTrim("key"), ", ", DEFAULT_KEY);
        }
    }
    ready = toStringArray(e.getChildTextTrim("ready"));
    mtiMapping = toStringArray(e.getChildTextTrim("mtimapping"));
    if (mtiMapping == null || mtiMapping.length != 3)
        mtiMapping = new String[] { nomap, nomap, "0022446789" };
    addListeners();
    unhandled = e.getChildTextTrim("unhandled");
    NameRegistrar.register("mux." + getName(), this);
}
Also used : ConfigurationException(org.jpos.core.ConfigurationException) Element(org.jdom2.Element)

Aggregations

ConfigurationException (org.jpos.core.ConfigurationException)52 Element (org.jdom2.Element)10 SimpleConfiguration (org.jpos.core.SimpleConfiguration)10 Test (org.junit.Test)9 Configuration (org.jpos.core.Configuration)8 Configurable (org.jpos.core.Configurable)5 SubConfiguration (org.jpos.core.SubConfiguration)5 NameRegistrar (org.jpos.util.NameRegistrar)4 IOException (java.io.IOException)3 Date (java.util.Date)3 Properties (java.util.Properties)3 LogSource (org.jpos.util.LogSource)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ParseException (java.text.ParseException)2 SimpleDateFormat (java.text.SimpleDateFormat)2 StringTokenizer (java.util.StringTokenizer)2 Timer (java.util.Timer)2 ISOException (org.jpos.iso.ISOException)2 Logger (org.jpos.util.Logger)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1