Search in sources :

Example 1 with ConfigurationException

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

the class SpaceProxy method setConfiguration.

public void setConfiguration(Configuration cfg) throws ConfigurationException {
    this.cfg = cfg;
    try {
        InitialContext ctx = new InitialContext();
        ctx.rebind(cfg.get("name"), stub);
    } catch (NamingException e) {
        throw new ConfigurationException(e);
    }
}
Also used : ConfigurationException(org.jpos.core.ConfigurationException) NamingException(javax.naming.NamingException) InitialContext(javax.naming.InitialContext)

Example 2 with ConfigurationException

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

the class TransactionManager method setConfiguration.

@Override
public void setConfiguration(Configuration cfg) throws ConfigurationException {
    super.setConfiguration(cfg);
    debug = cfg.getBoolean("debug", true);
    debugContext = cfg.getBoolean("debug-context", debug);
    profiler = cfg.getBoolean("profiler", debug);
    if (profiler || debugContext)
        // profiler and/or debugContext needs debug
        debug = true;
    doRecover = cfg.getBoolean("recover", true);
    retryInterval = cfg.getLong("retry-interval", retryInterval);
    retryTimeout = cfg.getLong("retry-timeout", retryTimeout);
    pauseTimeout = cfg.getLong("pause-timeout", pauseTimeout);
    abortOnPauseTimeout = cfg.getBoolean("abort-on-pause-timeout", true);
    maxActiveSessions = cfg.getInt("max-active-sessions", 0);
    sessions = cfg.getInt("sessions", 1);
    threshold = cfg.getInt("threshold", sessions / 2);
    maxSessions = cfg.getInt("max-sessions", sessions);
    if (maxSessions < sessions)
        throw new ConfigurationException("max-sessions < sessions");
    if (maxActiveSessions > 0) {
        if (maxActiveSessions < sessions)
            throw new ConfigurationException("max-active-sessions < sessions");
        if (maxActiveSessions < maxSessions)
            throw new ConfigurationException("max-active-sessions < max-sessions");
    }
    callSelectorOnAbort = cfg.getBoolean("call-selector-on-abort", true);
    if (profiler)
        metrics = new Metrics(new AtomicHistogram(cfg.getLong("metrics-highest-trackable-value", 60000), 2));
}
Also used : ConfigurationException(org.jpos.core.ConfigurationException) AtomicHistogram(org.HdrHistogram.AtomicHistogram)

Example 3 with ConfigurationException

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

the class TransactionManager method initParticipants.

protected void initParticipants(Element config) throws ConfigurationException {
    groups.put(DEFAULT_GROUP, initGroup(config));
    for (Element e : config.getChildren("group")) {
        String name = e.getAttributeValue("name");
        if (name == null)
            throw new ConfigurationException("missing group name");
        if (groups.containsKey(name)) {
            throw new ConfigurationException("Group '" + name + "' already defined");
        }
        groups.put(name, initGroup(e));
    }
}
Also used : ConfigurationException(org.jpos.core.ConfigurationException) Element(org.jdom2.Element)

Example 4 with ConfigurationException

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

the class SendResponse method setConfiguration.

@Override
public void setConfiguration(Configuration cfg) throws ConfigurationException {
    source = cfg.get("source", SOURCE.toString());
    request = cfg.get("request", REQUEST.toString());
    response = cfg.get("response", RESPONSE.toString());
    timeout = cfg.getLong("timeout", timeout);
    try {
        headerStrategy = HeaderStrategy.valueOf(cfg.get("header-strategy", "PRESERVE_RESPONSE").toUpperCase());
    } catch (IllegalArgumentException e) {
        throw new ConfigurationException(e.getMessage());
    }
}
Also used : ConfigurationException(org.jpos.core.ConfigurationException)

Example 5 with ConfigurationException

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

the class RotateLogListener method setConfiguration.

/**
 * Configure this RotateLogListener<br>
 * Properties:<br>
 * <ul>
 *  <li>file      base log filename
 *  <li>[window]  in seconds (default 0 - never rotate)
 *  <li>[count]   number of copies (default 0 == single copy)
 *  <li>[maxsize] max log size in bytes (aprox)
 * </ul>
 * @param cfg Configuration
 * @throws ConfigurationException
 */
public void setConfiguration(Configuration cfg) throws ConfigurationException {
    maxCopies = cfg.getInt("copies");
    sleepTime = cfg.getInt("window") * 1000;
    logName = cfg.get("file");
    maxSize = cfg.getLong("maxsize");
    maxSize = maxSize <= 0 ? DEFAULT_MAXSIZE : maxSize;
    try {
        openLogFile();
    } catch (IOException e) {
        throw new ConfigurationException(e);
    }
    Timer timer = DefaultTimer.getTimer();
    if (sleepTime != 0)
        timer.schedule(rotate = new Rotate(), sleepTime, sleepTime);
}
Also used : Timer(java.util.Timer) ConfigurationException(org.jpos.core.ConfigurationException) IOException(java.io.IOException)

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