Search in sources :

Example 16 with ConfigurationException

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

the class QServer method grabSpace.

private LocalSpace grabSpace(Element e) throws ConfigurationException {
    String uri = e != null ? e.getText() : "";
    Space sp = SpaceFactory.getSpace(uri);
    if (sp instanceof LocalSpace) {
        return (LocalSpace) sp;
    }
    throw new ConfigurationException("Invalid space " + uri);
}
Also used : LocalSpace(org.jpos.space.LocalSpace) Space(org.jpos.space.Space) LocalSpace(org.jpos.space.LocalSpace) ConfigurationException(org.jpos.core.ConfigurationException)

Example 17 with ConfigurationException

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

the class QServer method initServer.

private void initServer() throws ConfigurationException {
    if (port == 0) {
        throw new ConfigurationException("Port value not set");
    }
    newChannel();
    if (channel == null) {
        throw new ConfigurationException("ISO Channel is null");
    }
    if (!(channel instanceof ServerChannel)) {
        throw new ConfigurationException(channelString + "does not implement ServerChannel");
    }
    ThreadPool pool = null;
    pool = new ThreadPool(minSessions, maxSessions, getName() + "-ThreadPool");
    pool.setLogger(log.getLogger(), getName() + ".pool");
    server = new ISOServer(port, (ServerChannel) channel, pool);
    server.setLogger(log.getLogger(), getName() + ".server");
    server.setName(getName());
    if (socketFactoryString != null) {
        ISOServerSocketFactory sFac = (ISOServerSocketFactory) getFactory().newInstance(socketFactoryString);
        if (sFac != null && sFac instanceof LogSource) {
            ((LogSource) sFac).setLogger(log.getLogger(), getName() + ".socket-factory");
        }
        server.setSocketFactory(sFac);
    }
    getFactory().setConfiguration(server, getPersist());
    addServerSocketFactory();
    // ISORequestListener
    addListeners();
    addISOServerConnectionListeners();
    NameRegistrar.register(getName(), this);
    new Thread(server).start();
}
Also used : ISOServer(org.jpos.iso.ISOServer) ISOServerSocketFactory(org.jpos.iso.ISOServerSocketFactory) ConfigurationException(org.jpos.core.ConfigurationException) LogSource(org.jpos.util.LogSource) ThreadPool(org.jpos.util.ThreadPool) ServerChannel(org.jpos.iso.ServerChannel)

Example 18 with ConfigurationException

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

the class LoggerAdaptor method addListener.

private void addListener(Element e) throws ConfigurationException {
    QFactory factory = getServer().getFactory();
    String clazz = e.getAttributeValue("class");
    LogListener listener = (LogListener) factory.newInstance(clazz);
    if (listener instanceof Configurable) {
        try {
            ((Configurable) listener).setConfiguration(factory.getConfiguration(e));
        } catch (ConfigurationException ex) {
            throw new ConfigurationException(ex);
        }
    }
    logger.addListener(listener);
}
Also used : LogListener(org.jpos.util.LogListener) ConfigurationException(org.jpos.core.ConfigurationException) QFactory(org.jpos.q2.QFactory) Configurable(org.jpos.core.Configurable)

Example 19 with ConfigurationException

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

the class LoggerService method setConfiguration.

@Override
public void setConfiguration(Configuration cfg) throws ConfigurationException {
    super.setConfiguration(cfg);
    queueName = cfg.get("queue", null);
    if (queueName == null)
        throw new ConfigurationException("'queue' property not configured");
    sp = SpaceFactory.getSpace(cfg.get("space"));
    timeout = cfg.getLong("timeout", timeout);
}
Also used : ConfigurationException(org.jpos.core.ConfigurationException)

Example 20 with ConfigurationException

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

the class ISOChannelAdaptor method setConfiguration.

public void setConfiguration(Configuration cfg) throws ConfigurationException {
    this.cfg = cfg;
    try {
        to = get("to");
        from = get("from");
        channel = (ISOChannel) NameRegistrar.get("channel." + get("channel"));
        ready = channel.toString() + ".ready";
        new Thread(new Sender()).start();
        new Thread(new Receiver()).start();
    } 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