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);
}
}
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;
}
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();
}
}
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;
}
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);
}
Aggregations