Search in sources :

Example 41 with ConfigurationException

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

the class SysLogListener method setConfiguration.

public void setConfiguration(Configuration cfg) throws ConfigurationException {
    this.cfg = cfg;
    try {
        socket = new DatagramSocket();
        port = cfg.getInt("port", SYSLOG_PORT);
        host = InetAddress.getByName(cfg.get("host", "localhost"));
        defaultFacility = cfg.getInt("facility", LOG_USER);
        defaultSeverity = cfg.getInt("severity", PRI_INFO);
        tags = cfg.get("tags", "audit, syslog");
        prefix = cfg.get("prefix", null);
    } catch (Exception e) {
        throw new ConfigurationException(e);
    }
}
Also used : DatagramSocket(java.net.DatagramSocket) ConfigurationException(org.jpos.core.ConfigurationException) ConfigurationException(org.jpos.core.ConfigurationException) IOException(java.io.IOException)

Example 42 with ConfigurationException

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

the class ChannelAdaptor method initChannel.

protected ISOChannel initChannel() throws ConfigurationException {
    Element persist = getPersist();
    Element e = persist.getChild("channel");
    if (e == null)
        throw new ConfigurationException("channel element missing");
    ISOChannel c = newChannel(e, getFactory());
    String socketFactoryString = getSocketFactory();
    if (socketFactoryString != null && c 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) c).setSocketFactory(sFac);
    }
    return c;
}
Also used : ConfigurationException(org.jpos.core.ConfigurationException) LogSource(org.jpos.util.LogSource) Element(org.jdom2.Element)

Example 43 with ConfigurationException

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

the class ContextMaker method setConfiguration.

public void setConfiguration(Configuration cfg) throws ConfigurationException {
    super.setConfiguration(cfg);
    Element persist = getPersist();
    String ssp = persist.getChildText("space");
    sp = SpaceFactory.getSpace(ssp != null ? ssp : "");
    String sTimeout = persist.getChildText("timeout");
    timeout = sTimeout == null ? 10000 : Long.parseLong(sTimeout);
    contextName = persist.getChildText("context-name");
    if (contextName == null) {
        throw new ConfigurationException("Missing 'context-name' property - the context name of the object received on 'in'");
    }
    in = persist.getChildText("in");
    if (in == null) {
        throw new ConfigurationException("Missing 'in' property - the queue to process objects from.");
    }
    out = persist.getChildText("out");
    if (out == null) {
        throw new ConfigurationException("Missing 'out' property - the target queue of the created context");
    }
    Element values = persist.getChild("context-values");
    if (values != null) {
        contextValues = values.getChildren();
    }
}
Also used : ConfigurationException(org.jpos.core.ConfigurationException) Element(org.jdom2.Element)

Example 44 with ConfigurationException

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

Example 45 with ConfigurationException

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

the class OneShotChannelAdaptorMK2 method initService.

@Override
protected void initService() throws Exception {
    Element persist = getPersist();
    channelElement = persist.getChild("channel");
    if (channelElement == null) {
        throw new ConfigurationException("channel element missing");
    }
    sp = grabSpace(persist.getChild("space"));
    in = persist.getChildTextTrim("in");
    out = persist.getChildTextTrim("out");
    ready = getName() + ".ready";
    String s = persist.getChildTextTrim("max-connections");
    maxConnections = s != null ? Integer.parseInt(s) : 1;
    handbackFields = cfg.getInts("handback-field");
    s = persist.getChildTextTrim("delay");
    delay = s != null ? Integer.valueOf(s) : 2500;
    s = persist.getChildTextTrim("check-interval");
    checkInterval = s != null ? Integer.valueOf(s) : 60000;
    NameRegistrar.register(getName(), this);
}
Also used : ConfigurationException(org.jpos.core.ConfigurationException) Element(org.jdom2.Element)

Aggregations

ConfigurationException (org.jpos.core.ConfigurationException)52 Element (org.jdom2.Element)10 SimpleConfiguration (org.jpos.core.SimpleConfiguration)10 Test (org.junit.Test)9 Configuration (org.jpos.core.Configuration)8 Configurable (org.jpos.core.Configurable)5 SubConfiguration (org.jpos.core.SubConfiguration)5 NameRegistrar (org.jpos.util.NameRegistrar)4 IOException (java.io.IOException)3 Date (java.util.Date)3 Properties (java.util.Properties)3 LogSource (org.jpos.util.LogSource)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ParseException (java.text.ParseException)2 SimpleDateFormat (java.text.SimpleDateFormat)2 StringTokenizer (java.util.StringTokenizer)2 Timer (java.util.Timer)2 ISOException (org.jpos.iso.ISOException)2 Logger (org.jpos.util.Logger)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1