Search in sources :

Example 1 with ThreadPool

use of org.jpos.util.ThreadPool 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 ThreadPool

use of org.jpos.util.ThreadPool in project jPOS by jpos.

the class SslChannelIntegrationTest method newIsoServer.

private ISOServer newIsoServer() throws IOException, ISOException {
    XMLChannel clientSide = new XMLChannel(new XMLPackager());
    clientSide.setLogger(logger, "server.channel");
    ISOServer isoServer = new ISOServer(PORT, clientSide, new ThreadPool());
    isoServer.setSocketFactory(new SunJSSESocketFactory());
    isoServer.setConfiguration(serverConfiguration());
    isoServer.setLogger(logger, "server");
    isoServer.addISORequestListener(new TestListener());
    return isoServer;
}
Also used : XMLPackager(org.jpos.iso.packager.XMLPackager) ThreadPool(org.jpos.util.ThreadPool) XMLChannel(org.jpos.iso.channel.XMLChannel)

Example 3 with ThreadPool

use of org.jpos.util.ThreadPool in project jPOS by jpos.

the class DirPollAdaptor method initService.

protected void initService() throws Exception {
    QFactory factory = getServer().getFactory();
    dirPoll = createDirPoll();
    dirPoll.setPath(getPath());
    dirPoll.setThreadPool(new ThreadPool(1, poolSize));
    dirPoll.setPollInterval(pollInterval);
    if (priorities != null)
        dirPoll.setPriorities(priorities);
    dirPoll.setLogger(getLog().getLogger(), getLog().getRealm());
    Configuration cfg = factory.getConfiguration(getPersist());
    dirPoll.setConfiguration(cfg);
    dirPoll.createDirs();
    Object dpp = factory.newInstance(getProcessor());
    if (dpp instanceof LogSource) {
        ((LogSource) dpp).setLogger(getLog().getLogger(), getLog().getRealm());
    }
    if (dpp instanceof Configurable) {
        ((Configurable) dpp).setConfiguration(cfg);
    }
    dirPoll.setProcessor(dpp);
}
Also used : Configuration(org.jpos.core.Configuration) LogSource(org.jpos.util.LogSource) ThreadPool(org.jpos.util.ThreadPool) QFactory(org.jpos.q2.QFactory) Configurable(org.jpos.core.Configurable)

Aggregations

ThreadPool (org.jpos.util.ThreadPool)3 LogSource (org.jpos.util.LogSource)2 Configurable (org.jpos.core.Configurable)1 Configuration (org.jpos.core.Configuration)1 ConfigurationException (org.jpos.core.ConfigurationException)1 ISOServer (org.jpos.iso.ISOServer)1 ISOServerSocketFactory (org.jpos.iso.ISOServerSocketFactory)1 ServerChannel (org.jpos.iso.ServerChannel)1 XMLChannel (org.jpos.iso.channel.XMLChannel)1 XMLPackager (org.jpos.iso.packager.XMLPackager)1 QFactory (org.jpos.q2.QFactory)1