use of org.jpos.core.ConfigurationException in project jPOS by jpos.
the class QServer method newChannel.
private void newChannel() throws ConfigurationException {
Element persist = getPersist();
Element e = persist.getChild("channel");
if (e == null) {
throw new ConfigurationException("channel element missing");
}
ChannelAdaptor adaptor = new ChannelAdaptor();
channel = adaptor.newChannel(e, getFactory());
}
use of org.jpos.core.ConfigurationException in project jPOS by jpos.
the class QThreadPoolExecutor method initService.
/**
* Handle specific config elements
*
* type := "fixed" | "scheduled" | "cached" corePoolSize := integer
* (required for "fixed" and "scheduled" kinds, optional for "cached" kind)
*/
@Override
protected void initService() throws Exception {
Element rootElt = this.getPersist();
Attribute execSrvTypeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_TYPE, true, "(thread pool executor type among {fixed|cached|scheduled|single})");
execSrvType = execSrvTypeAttr.getValue().trim();
if ("fixed".equals(execSrvType)) {
Attribute corePoolSizeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_COREPOOLSIZE, true, "(number of threads in the pool)");
initialCorePoolSize = corePoolSizeAttr.getIntValue();
} else if ("cached".equals(execSrvType)) {
Attribute corePoolSizeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_COREPOOLSIZE, false, "(number of threads in the pool)");
if (null != corePoolSizeAttr) {
initialCorePoolSize = corePoolSizeAttr.getIntValue();
}
} else if ("scheduled".equals(execSrvType)) {
Attribute corePoolSizeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_COREPOOLSIZE, true, "(number of threads in the pool)");
initialCorePoolSize = corePoolSizeAttr.getIntValue();
} else {
throw new ConfigurationException("Invalid thread pool executor type '%s' (valid types={fixed|cached|scheduled} )");
}
Attribute terminationTimerAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_TERMINATION_TIMER, false, "(termination timer in seconds)");
if (null != terminationTimerAttr) {
terminationTimer = terminationTimerAttr.getIntValue();
}
}
use of org.jpos.core.ConfigurationException 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);
}
}
use of org.jpos.core.ConfigurationException in project jPOS by jpos.
the class IncomingListener method setConfiguration.
@SuppressWarnings("unchecked")
public void setConfiguration(Configuration cfg) throws ConfigurationException {
timeout = cfg.getLong("timeout", 15000L);
sp = (Space<String, Context>) SpaceFactory.getSpace(cfg.get("space"));
queue = cfg.get("queue", null);
if (queue == null)
throw new ConfigurationException("queue property not specified");
source = cfg.get("source", ContextConstants.SOURCE.toString());
request = cfg.get("request", ContextConstants.REQUEST.toString());
timestamp = cfg.get("timestamp", ContextConstants.TIMESTAMP.toString());
remote = cfg.getBoolean("remote") || cfg.get("space").startsWith("rspace:");
Map<String, String> m = new HashMap<>();
cfg.keySet().stream().filter(s -> s.startsWith("ctx.")).forEach(s -> m.put(s.substring(4), cfg.get(s)));
if (m.size() > 0)
additionalContextEntries = m;
}
use of org.jpos.core.ConfigurationException in project jPOS by jpos.
the class ChannelPool method setConfiguration.
public synchronized void setConfiguration(Configuration cfg) throws ConfigurationException {
this.cfg = cfg;
String[] channelName = cfg.getAll("channel");
for (String aChannelName : channelName) {
try {
addChannel(aChannelName);
} catch (NameRegistrar.NotFoundException e) {
throw new ConfigurationException(e);
}
}
}
Aggregations