diff --git a/jpos/src/main/java/org/jpos/iso/BaseChannel.java b/jpos/src/main/java/org/jpos/iso/BaseChannel.java index 1f4db83217..8252e1470c 100644 --- a/jpos/src/main/java/org/jpos/iso/BaseChannel.java +++ b/jpos/src/main/java/org/jpos/iso/BaseChannel.java @@ -291,6 +291,20 @@ protected void connect (Socket socket) setChanged(); notifyObservers(); } + + /** + * Allow the channel to be connected to a pair of input and output streams. + *

+ * For instance for taking input from or outputting to a file or standard input/ouput. + * + * @param in Where to read from. + * @param out Where to write to. + */ + protected void connect(InputStream in, OutputStream out) { + usable = in != null || out != null; //at least one of them has to be not null + if (in != null) serverIn = new DataInputStream(in); + if (out != null) serverOut = new DataOutputStream(out); + } protected void postConnectHook() throws IOException { // do nothing } diff --git a/jpos/src/main/java/org/jpos/iso/channel/XMLChannel.java b/jpos/src/main/java/org/jpos/iso/channel/XMLChannel.java index 5a7f852acc..4d0f077846 100644 --- a/jpos/src/main/java/org/jpos/iso/channel/XMLChannel.java +++ b/jpos/src/main/java/org/jpos/iso/channel/XMLChannel.java @@ -22,9 +22,12 @@ import org.jpos.iso.packager.XMLPackager; import java.io.BufferedReader; +import java.io.DataInputStream; import java.io.EOFException; import java.io.IOException; +import java.io.InputStream; import java.io.InputStreamReader; +import java.io.OutputStream; import java.net.ServerSocket; import java.net.Socket; @@ -117,4 +120,9 @@ public void disconnect () throws IOException { reader.close (); reader = null; } + + protected void connect(InputStream in, OutputStream out) { + super.connect(in, out); + reader = new BufferedReader(new InputStreamReader(in)); + } }