Skip to content

Commit a241d34

Browse files
committed
Added 'delay' property
See http://jpos.org/blog/2013/06/padchannel-delay for details
1 parent 8ba1981 commit a241d34

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

jpos/src/main/java/org/jpos/iso/channel/PADChannel.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
package org.jpos.iso.channel;
2020

21+
import org.jpos.core.Configuration;
22+
import org.jpos.core.ConfigurationException;
2123
import org.jpos.iso.*;
2224
import org.jpos.util.LogEvent;
2325
import org.jpos.util.Logger;
@@ -40,6 +42,7 @@
4042
*/
4143
public class PADChannel extends BaseChannel {
4244
BufferedReader reader = null;
45+
long delay = 0L;
4346
/**
4447
* No-args constructor
4548
*/
@@ -76,7 +79,10 @@ public PADChannel (ISOPackager p, ServerSocket serverSocket)
7679
throws IOException
7780
{
7881
super (p, serverSocket);
82+
if (delay > 0L)
83+
ISOUtil.sleep(delay);
7984
}
85+
@Override
8086
public ISOMsg receive() throws IOException, ISOException {
8187
byte[] header = null;
8288
ISOMsg m = new ISOMsg ();
@@ -85,7 +91,7 @@ public ISOMsg receive() throws IOException, ISOException {
8591
int hLen = getHeaderLength();
8692
LogEvent evt = new LogEvent (this, "receive");
8793
try {
88-
synchronized (serverIn) {
94+
synchronized (serverInLock) {
8995
if (hLen > 0) {
9096
header = new byte [hLen];
9197
serverIn.readFully(header);
@@ -122,6 +128,16 @@ public ISOMsg receive() throws IOException, ISOException {
122128
Logger.log (evt);
123129
return m;
124130
}
131+
@Override
132+
public void send (ISOMsg m) throws IOException, ISOException {
133+
super.send(m);
134+
}
135+
@Override
136+
public void setConfiguration (Configuration cfg)
137+
throws ConfigurationException {
138+
super.setConfiguration(cfg);
139+
delay = cfg.getLong("delay", 0L);
140+
}
125141

126142
/**
127143
* @param header Hex representation of header

0 commit comments

Comments
 (0)