Search in sources :

Example 1 with ISOServerSocketFactory

use of org.jpos.iso.ISOServerSocketFactory 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 2 with ISOServerSocketFactory

use of org.jpos.iso.ISOServerSocketFactory in project jPOS by jpos.

the class QServer method addServerSocketFactory.

private void addServerSocketFactory() throws ConfigurationException {
    QFactory factory = getFactory();
    Element persist = getPersist();
    Element serverSocketFactoryElement = persist.getChild("server-socket-factory");
    if (serverSocketFactoryElement != null) {
        ISOServerSocketFactory serverSocketFactory = (ISOServerSocketFactory) factory.newInstance(QFactory.getAttributeValue(serverSocketFactoryElement, "class"));
        factory.setLogger(serverSocketFactory, serverSocketFactoryElement);
        factory.setConfiguration(serverSocketFactory, serverSocketFactoryElement);
        server.setSocketFactory(serverSocketFactory);
    }
}
Also used : ISOServerSocketFactory(org.jpos.iso.ISOServerSocketFactory) Element(org.jdom2.Element) QFactory(org.jpos.q2.QFactory)

Aggregations

ISOServerSocketFactory (org.jpos.iso.ISOServerSocketFactory)2 Element (org.jdom2.Element)1 ConfigurationException (org.jpos.core.ConfigurationException)1 ISOServer (org.jpos.iso.ISOServer)1 ServerChannel (org.jpos.iso.ServerChannel)1 QFactory (org.jpos.q2.QFactory)1 LogSource (org.jpos.util.LogSource)1 ThreadPool (org.jpos.util.ThreadPool)1