public int getPort () { int port = 0; try { port = Integer.parseInt ( getProperty (getProperties ("channel"), "port") ); } catch (NumberFormatException e) { getLog().error(e); } return port; } public synchronized void setSocketFactory (String sFac) {
public void startService () { try { channel = initChannel (); sender = new Thread(new Sender()); sender.start(); if (!writeOnly) { // fixes #426 && jPOS-20 receiver = new Thread(new Receiver()); receiver.start(); } } catch (Exception e) { getLog().warn ("error starting service", e); } } public void stopService () {
protected void disconnect () { // do not synchronize on this as both Sender and Receiver can deadlock against a thread calling stop() synchronized (disconnectLock) { try { SpaceUtil.wipe(sp, ready); channel.disconnect(); } catch (Exception e) { getLog().warn("disconnect", e); } } } public synchronized void setHost (String host) {
public void stopService () { try { sp.out (in, Boolean.TRUE); if (channel != null) disconnect(); if (waitForWorkersOnStop) { waitForSenderToExit(); if (!writeOnly) { sp.out(ready, new Date()); waitForReceiverToExit(); } } sender = null; receiver = null; } catch (Exception e) { getLog().warn ("error disconnecting from remote host", e); } } private void waitForSenderToExit() {
} catch (ISOException e) { if (running()) { getLog().warn ("channel-receiver-"+out, e); if (!ignoreISOExceptions) { sp.out (reconnect, Boolean.TRUE, delay); getLog().warn ("channel-receiver-"+out, "Read timeout / EOF - reconnecting"); sp.out (reconnect, Boolean.TRUE, delay); disconnect (); getLog().warn ("channel-receiver-"+out, e); sp.out (reconnect, Boolean.TRUE, delay); disconnect ();