Search in sources :

Example 1 with LogSource

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

the class QFactory method setLogger.

public void setLogger(Object obj, Element e) {
    if (obj instanceof LogSource) {
        String loggerName = getAttributeValue(e, "logger");
        if (loggerName != null) {
            String realm = getAttributeValue(e, "realm");
            if (realm == null)
                realm = e.getName();
            Logger logger = Logger.getLogger(loggerName);
            ((LogSource) obj).setLogger(logger, realm);
        }
    }
}
Also used : LogSource(org.jpos.util.LogSource) Logger(org.jpos.util.Logger)

Example 2 with LogSource

use of org.jpos.util.LogSource 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 3 with LogSource

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

the class MultiSessionChannelAdaptor method startService.

public void startService() {
    try {
        channels = new ISOChannel[sessions];
        for (int i = 0; i < sessions; i++) {
            ISOChannel c = initChannel();
            if (c instanceof LogSource) {
                LogSource ls = (LogSource) c;
                ls.setLogger(ls.getLogger(), ls.getRealm() + "-" + i);
            }
            channels[i] = c;
            if (!writeOnly)
                new Thread(new Receiver(i), "channel-receiver-" + in + "-" + i).start();
        }
        new Thread(new Sender(), "channel-sender-" + in).start();
    } catch (Exception e) {
        getLog().warn("error starting service", e);
    }
}
Also used : LogSource(org.jpos.util.LogSource) ConfigurationException(org.jpos.core.ConfigurationException) IOException(java.io.IOException)

Example 4 with LogSource

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

the class DUKPTTest method initKS.

private void initKS() throws Exception {
    ks = new SimpleKeyFile("build/resources/test/org/jpos/security/keys-test");
    ((LogSource) ks).setLogger(log.getLogger(), "KS");
}
Also used : LogSource(org.jpos.util.LogSource) SimpleKeyFile(org.jpos.security.SimpleKeyFile)

Example 5 with LogSource

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

the class OneShotChannelAdaptorMK2 method newChannel.

private ISOChannel newChannel(Element e, QFactory f) throws ConfigurationException {
    String channelName = QFactory.getAttributeValue(e, "class");
    if (channelName == null) {
        throw new ConfigurationException("class attribute missing from channel element.");
    }
    String packagerName = QFactory.getAttributeValue(e, "packager");
    ISOChannel channel = (ISOChannel) f.newInstance(channelName);
    ISOPackager packager;
    if (packagerName != null) {
        packager = (ISOPackager) f.newInstance(packagerName);
        channel.setPackager(packager);
        f.setConfiguration(packager, e);
    }
    QFactory.invoke(channel, "setHeader", QFactory.getAttributeValue(e, "header"));
    f.setLogger(channel, e);
    f.setConfiguration(channel, e);
    if (channel instanceof FilteredChannel) {
        addFilters((FilteredChannel) channel, e, f);
    }
    String socketFactoryString = getSocketFactory();
    if (socketFactoryString != null && channel instanceof FactoryChannel) {
        ISOClientSocketFactory sFac = (ISOClientSocketFactory) getFactory().newInstance(socketFactoryString);
        if (sFac != null && sFac instanceof LogSource) {
            ((LogSource) sFac).setLogger(log.getLogger(), getName() + ".socket-factory");
        }
        getFactory().setConfiguration(sFac, e);
        ((FactoryChannel) channel).setSocketFactory(sFac);
    }
    return channel;
}
Also used : ISOPackager(org.jpos.iso.ISOPackager) ConfigurationException(org.jpos.core.ConfigurationException) LogSource(org.jpos.util.LogSource) FilteredChannel(org.jpos.iso.FilteredChannel) ISOClientSocketFactory(org.jpos.iso.ISOClientSocketFactory) FactoryChannel(org.jpos.iso.FactoryChannel) ISOChannel(org.jpos.iso.ISOChannel)

Aggregations

LogSource (org.jpos.util.LogSource)7 ConfigurationException (org.jpos.core.ConfigurationException)4 ThreadPool (org.jpos.util.ThreadPool)2 IOException (java.io.IOException)1 Element (org.jdom2.Element)1 Configurable (org.jpos.core.Configurable)1 Configuration (org.jpos.core.Configuration)1 FactoryChannel (org.jpos.iso.FactoryChannel)1 FilteredChannel (org.jpos.iso.FilteredChannel)1 ISOChannel (org.jpos.iso.ISOChannel)1 ISOClientSocketFactory (org.jpos.iso.ISOClientSocketFactory)1 ISOPackager (org.jpos.iso.ISOPackager)1 ISOServer (org.jpos.iso.ISOServer)1 ISOServerSocketFactory (org.jpos.iso.ISOServerSocketFactory)1 ServerChannel (org.jpos.iso.ServerChannel)1 QFactory (org.jpos.q2.QFactory)1 SimpleKeyFile (org.jpos.security.SimpleKeyFile)1 Logger (org.jpos.util.Logger)1