1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.ftp.server;
12
13 import java.io.IOException;
14 import java.io.OutputStream;
15
16 import org.apache.commons.io.output.ByteArrayOutputStream;
17
18 public class SignallingOutputStream extends OutputStream
19 {
20
21 private String name;
22 private ServerState state;
23 private ByteArrayOutputStream delegate = new ByteArrayOutputStream();
24
25 public SignallingOutputStream(String name, ServerState state)
26 {
27 this.name = name;
28 this.state = state;
29 }
30
31 public void write(int b) throws IOException {
32 delegate.write(b);
33 }
34
35 public void write(byte b[]) throws IOException
36 {
37 delegate.write(b);
38 }
39
40 public void write(byte b[], int off, int len) throws IOException
41 {
42 delegate.write(b, off, len);
43 }
44
45
46 public void close() throws IOException
47 {
48 delegate.close();
49 state.pushLastUpload(new NamedPayload(name, delegate.toByteArray()));
50 super.close();
51 }
52
53 }