use of org.jpos.core.Configuration in project jPOS by jpos.
the class JPOSLogger method isLevelEnabled.
protected boolean isLevelEnabled(int logLevel) {
Logger logger = log.getLogger();
Configuration cfg = logger.getConfiguration();
if (cfg == null)
cfg = new SimpleConfiguration();
String levelString = cfg.get("slf4j.level", System.getProperty("slf4j.level"));
int currentLogLevel = levelString != null ? stringToLevel(levelString) : DEFAULT_LOG_LEVEL;
return (logLevel >= currentLogLevel);
}
use of org.jpos.core.Configuration in project jPOS by jpos.
the class QFactory method getConfiguration.
public Configuration getConfiguration(Element e) throws ConfigurationException {
String configurationFactoryClazz = e.getAttributeValue("configuration-factory");
ConfigurationFactory cf = configurationFactoryClazz != null ? (ConfigurationFactory) newInstance(configurationFactoryClazz) : defaultConfigurationFactory;
Configuration cfg = cf.getConfiguration(e);
String merge = e.getAttributeValue("merge-configuration");
if (merge != null) {
StringTokenizer st = new StringTokenizer(merge, ", ");
while (st.hasMoreElements()) {
try {
Configuration c = QConfig.getConfiguration(st.nextToken());
for (String k : c.keySet()) {
if (cfg.get(k, null) == null) {
String[] v = c.getAll(k);
switch(v.length) {
case 0:
break;
case 1:
cfg.put(k, v[0]);
break;
default:
cfg.put(k, v);
}
}
}
} catch (NameRegistrar.NotFoundException ex) {
throw new ConfigurationException(ex.getMessage());
}
}
}
return cfg;
}
use of org.jpos.core.Configuration 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);
}
use of org.jpos.core.Configuration 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;
}
Aggregations