Search in sources :

Example 6 with LogSource

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

Example 7 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 = e.getAttributeValue("class");
    if (channelName == null) {
        throw new ConfigurationException("class attribute missing from channel element.");
    }
    String packagerName = e.getAttributeValue("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", e.getAttributeValue("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