Search in sources :

Example 1 with FactoryChannel

use of org.jpos.iso.FactoryChannel 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

ConfigurationException (org.jpos.core.ConfigurationException)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 LogSource (org.jpos.util.LogSource)1