Search in sources :

Example 6 with Configurable

use of org.jpos.core.Configurable 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 Configurable

use of org.jpos.core.Configurable in project jPOS by jpos.

the class ISOServer method setConfiguration.

@Override
public void setConfiguration(Configuration cfg) throws ConfigurationException {
    this.cfg = cfg;
    configureConnectionPerms();
    backlog = cfg.getInt("backlog", 0);
    ignoreISOExceptions = cfg.getBoolean("ignore-iso-exceptions");
    String ip = cfg.get("bind-address", null);
    if (ip != null) {
        try {
            bindAddr = InetAddress.getByName(ip);
        } catch (UnknownHostException e) {
            throw new ConfigurationException("Invalid bind-address " + ip, e);
        }
    }
    if (socketFactory == null) {
        socketFactory = this;
    }
    if (socketFactory != this && socketFactory instanceof Configurable) {
        ((Configurable) socketFactory).setConfiguration(cfg);
    }
}
Also used : UnknownHostException(java.net.UnknownHostException) ConfigurationException(org.jpos.core.ConfigurationException) Configurable(org.jpos.core.Configurable)

Aggregations

Configurable (org.jpos.core.Configurable)7 ConfigurationException (org.jpos.core.ConfigurationException)4 QFactory (org.jpos.q2.QFactory)4 Element (org.jdom2.Element)2 UnknownHostException (java.net.UnknownHostException)1 Configuration (org.jpos.core.Configuration)1 LogListener (org.jpos.util.LogListener)1 LogSource (org.jpos.util.LogSource)1 ThreadPool (org.jpos.util.ThreadPool)1