use of org.jpos.util.LogSource in project jPOS by jpos.
the class QFactory method setLogger.
public void setLogger(Object obj, Element e) {
if (obj instanceof LogSource) {
String loggerName = getAttributeValue(e, "logger");
if (loggerName != null) {
String realm = getAttributeValue(e, "realm");
if (realm == null)
realm = e.getName();
Logger logger = Logger.getLogger(loggerName);
((LogSource) obj).setLogger(logger, realm);
}
}
}
use of org.jpos.util.LogSource in project jPOS by jpos.
the class QServer method initServer.
private void initServer() throws ConfigurationException {
if (port == 0) {
throw new ConfigurationException("Port value not set");
}
newChannel();
if (channel == null) {
throw new ConfigurationException("ISO Channel is null");
}
if (!(channel instanceof ServerChannel)) {
throw new ConfigurationException(channelString + "does not implement ServerChannel");
}
ThreadPool pool = null;
pool = new ThreadPool(minSessions, maxSessions, getName() + "-ThreadPool");
pool.setLogger(log.getLogger(), getName() + ".pool");
server = new ISOServer(port, (ServerChannel) channel, pool);
server.setLogger(log.getLogger(), getName() + ".server");
server.setName(getName());
if (socketFactoryString != null) {
ISOServerSocketFactory sFac = (ISOServerSocketFactory) getFactory().newInstance(socketFactoryString);
if (sFac != null && sFac instanceof LogSource) {
((LogSource) sFac).setLogger(log.getLogger(), getName() + ".socket-factory");
}
server.setSocketFactory(sFac);
}
getFactory().setConfiguration(server, getPersist());
addServerSocketFactory();
// ISORequestListener
addListeners();
addISOServerConnectionListeners();
NameRegistrar.register(getName(), this);
new Thread(server).start();
}
use of org.jpos.util.LogSource in project jPOS by jpos.
the class MultiSessionChannelAdaptor method startService.
public void startService() {
try {
channels = new ISOChannel[sessions];
for (int i = 0; i < sessions; i++) {
ISOChannel c = initChannel();
if (c instanceof LogSource) {
LogSource ls = (LogSource) c;
ls.setLogger(ls.getLogger(), ls.getRealm() + "-" + i);
}
channels[i] = c;
if (!writeOnly)
new Thread(new Receiver(i), "channel-receiver-" + in + "-" + i).start();
}
new Thread(new Sender(), "channel-sender-" + in).start();
} catch (Exception e) {
getLog().warn("error starting service", e);
}
}
use of org.jpos.util.LogSource in project jPOS by jpos.
the class DUKPTTest method initKS.
private void initKS() throws Exception {
ks = new SimpleKeyFile("build/resources/test/org/jpos/security/keys-test");
((LogSource) ks).setLogger(log.getLogger(), "KS");
}
use of org.jpos.util.LogSource in project jPOS by jpos.
the class OneShotChannelAdaptorMK2 method newChannel.
private ISOChannel newChannel(Element e, QFactory f) throws ConfigurationException {
String channelName = QFactory.getAttributeValue(e, "class");
if (channelName == null) {
throw new ConfigurationException("class attribute missing from channel element.");
}
String packagerName = QFactory.getAttributeValue(e, "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", QFactory.getAttributeValue(e, "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;
}
Aggregations