1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.jumpmind.symmetric.transport.internal;
22
23 import java.io.BufferedReader;
24 import java.io.BufferedWriter;
25 import java.io.IOException;
26 import java.io.InputStream;
27 import java.io.OutputStream;
28
29 import org.apache.commons.io.IOUtils;
30 import org.jumpmind.symmetric.transport.IOutgoingWithResponseTransport;
31 import org.jumpmind.symmetric.transport.TransportUtils;
32
33 public class InternalOutgoingWithResponseTransport implements IOutgoingWithResponseTransport {
34
35 BufferedWriter writer = null;
36
37 BufferedReader reader = null;
38
39 boolean open = true;
40
41 InternalOutgoingWithResponseTransport(OutputStream pushOs, InputStream respIs) throws IOException {
42 writer = TransportUtils.toWriter(pushOs);
43 reader = TransportUtils.toReader(respIs);
44 }
45
46 public BufferedReader readResponse() throws IOException {
47 IOUtils.closeQuietly(writer);
48 return reader;
49 }
50
51 public void close() throws IOException {
52 IOUtils.closeQuietly(writer);
53 IOUtils.closeQuietly(reader);
54 open = false;
55 }
56
57 public boolean isOpen() {
58 return open;
59 }
60
61 public BufferedWriter open() throws IOException {
62 return writer;
63 }
64
65 }