1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.impl.model.streaming; |
12 | |
|
13 | |
import java.io.IOException; |
14 | |
import java.io.InputStream; |
15 | |
|
16 | |
import edu.emory.mathcs.backport.java.util.concurrent.CountDownLatch; |
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
public class CloseCountDownInputStream extends InputStream |
22 | |
{ |
23 | |
|
24 | |
private InputStream delegate; |
25 | |
private CountDownLatch latch; |
26 | |
|
27 | |
public CloseCountDownInputStream(InputStream delegate, CountDownLatch latch) |
28 | 0 | { |
29 | 0 | this.delegate = delegate; |
30 | 0 | this.latch = latch; |
31 | 0 | } |
32 | |
|
33 | |
public int read() throws IOException |
34 | |
{ |
35 | 0 | return delegate.read(); |
36 | |
} |
37 | |
|
38 | |
public int read(byte b[]) throws IOException |
39 | |
{ |
40 | 0 | return delegate.read(b); |
41 | |
} |
42 | |
|
43 | |
public int read(byte b[], int off, int len) throws IOException |
44 | |
{ |
45 | 0 | return delegate.read(b, off, len); |
46 | |
} |
47 | |
|
48 | |
public void close() throws IOException |
49 | |
{ |
50 | |
try |
51 | |
{ |
52 | 0 | delegate.close(); |
53 | |
} |
54 | |
finally |
55 | |
{ |
56 | 0 | if (null != latch) |
57 | |
{ |
58 | 0 | latch.countDown(); |
59 | |
} |
60 | |
} |
61 | 0 | } |
62 | |
|
63 | |
} |