1
2
3
4
5
6
7
8
9
10
11 package org.mule.providers.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
36 public void close() throws IOException
37 {
38 delegate.close();
39 state.pushLastUpload(new NamedPayload(name, delegate.toByteArray()));
40 super.close();
41 }
42
43 }