Search in sources :

Example 46 with ConfigurationException

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

the class QServer method newChannel.

private void newChannel() throws ConfigurationException {
    Element persist = getPersist();
    Element e = persist.getChild("channel");
    if (e == null) {
        throw new ConfigurationException("channel element missing");
    }
    ChannelAdaptor adaptor = new ChannelAdaptor();
    channel = adaptor.newChannel(e, getFactory());
}
Also used : ConfigurationException(org.jpos.core.ConfigurationException) Element(org.jdom2.Element)

Example 47 with ConfigurationException

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

the class QThreadPoolExecutor method initService.

/**
 * Handle specific config elements
 *
 * type := "fixed" | "scheduled" | "cached" corePoolSize := integer
 * (required for "fixed" and "scheduled" kinds, optional for "cached" kind)
 */
@Override
protected void initService() throws Exception {
    Element rootElt = this.getPersist();
    Attribute execSrvTypeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_TYPE, true, "(thread pool executor type among {fixed|cached|scheduled|single})");
    execSrvType = execSrvTypeAttr.getValue().trim();
    if ("fixed".equals(execSrvType)) {
        Attribute corePoolSizeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_COREPOOLSIZE, true, "(number of threads in the pool)");
        initialCorePoolSize = corePoolSizeAttr.getIntValue();
    } else if ("cached".equals(execSrvType)) {
        Attribute corePoolSizeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_COREPOOLSIZE, false, "(number of threads in the pool)");
        if (null != corePoolSizeAttr) {
            initialCorePoolSize = corePoolSizeAttr.getIntValue();
        }
    } else if ("scheduled".equals(execSrvType)) {
        Attribute corePoolSizeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_COREPOOLSIZE, true, "(number of threads in the pool)");
        initialCorePoolSize = corePoolSizeAttr.getIntValue();
    } else {
        throw new ConfigurationException("Invalid thread pool executor type '%s' (valid types={fixed|cached|scheduled} )");
    }
    Attribute terminationTimerAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_TERMINATION_TIMER, false, "(termination timer in seconds)");
    if (null != terminationTimerAttr) {
        terminationTimer = terminationTimerAttr.getIntValue();
    }
}
Also used : Attribute(org.jdom2.Attribute) ConfigurationException(org.jpos.core.ConfigurationException) Element(org.jdom2.Element)

Example 48 with ConfigurationException

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

the class ISOServer method setConfiguration.

@Override
public void setConfiguration(Configuration cfg) throws ConfigurationException {
    this.cfg = cfg;
    configureConnectionPerms();
    backlog = cfg.getInt("backlog", 0);
    ignoreISOExceptions = cfg.getBoolean("ignore-iso-exceptions");
    String ip = cfg.get("bind-address", null);
    if (ip != null) {
        try {
            bindAddr = InetAddress.getByName(ip);
        } catch (UnknownHostException e) {
            throw new ConfigurationException("Invalid bind-address " + ip, e);
        }
    }
    if (socketFactory == null) {
        socketFactory = this;
    }
    if (socketFactory != this && socketFactory instanceof Configurable) {
        ((Configurable) socketFactory).setConfiguration(cfg);
    }
}
Also used : UnknownHostException(java.net.UnknownHostException) ConfigurationException(org.jpos.core.ConfigurationException) Configurable(org.jpos.core.Configurable)

Example 49 with ConfigurationException

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

the class IncomingListener method setConfiguration.

@SuppressWarnings("unchecked")
public void setConfiguration(Configuration cfg) throws ConfigurationException {
    timeout = cfg.getLong("timeout", 15000L);
    sp = (Space<String, Context>) SpaceFactory.getSpace(cfg.get("space"));
    queue = cfg.get("queue", null);
    if (queue == null)
        throw new ConfigurationException("queue property not specified");
    source = cfg.get("source", ContextConstants.SOURCE.toString());
    request = cfg.get("request", ContextConstants.REQUEST.toString());
    timestamp = cfg.get("timestamp", ContextConstants.TIMESTAMP.toString());
    remote = cfg.getBoolean("remote") || cfg.get("space").startsWith("rspace:");
    Map<String, String> m = new HashMap<>();
    cfg.keySet().stream().filter(s -> s.startsWith("ctx.")).forEach(s -> m.put(s.substring(4), cfg.get(s)));
    if (m.size() > 0)
        additionalContextEntries = m;
}
Also used : Context(org.jpos.transaction.Context) Context(org.jpos.transaction.Context) SpaceFactory(org.jpos.space.SpaceFactory) ConfigurationException(org.jpos.core.ConfigurationException) Date(java.util.Date) SpaceSource(org.jpos.space.SpaceSource) LocalSpace(org.jpos.space.LocalSpace) Log(org.jpos.util.Log) HashMap(java.util.HashMap) Configurable(org.jpos.core.Configurable) ContextConstants(org.jpos.transaction.ContextConstants) Space(org.jpos.space.Space) Configuration(org.jpos.core.Configuration) Map(java.util.Map) ConfigurationException(org.jpos.core.ConfigurationException) HashMap(java.util.HashMap)

Example 50 with ConfigurationException

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

the class ChannelPool method setConfiguration.

public synchronized void setConfiguration(Configuration cfg) throws ConfigurationException {
    this.cfg = cfg;
    String[] channelName = cfg.getAll("channel");
    for (String aChannelName : channelName) {
        try {
            addChannel(aChannelName);
        } catch (NameRegistrar.NotFoundException e) {
            throw new ConfigurationException(e);
        }
    }
}
Also used : NameRegistrar(org.jpos.util.NameRegistrar) ConfigurationException(org.jpos.core.ConfigurationException)

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