forked from docker-java/docker-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExecStartResultCallback.java
More file actions
61 lines (52 loc) · 1.76 KB
/
Copy pathExecStartResultCallback.java
File metadata and controls
61 lines (52 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package com.github.dockerjava.core.command;
import com.github.dockerjava.api.model.Frame;
import com.github.dockerjava.core.async.ResultCallbackTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.OutputStream;
/**
*
* @author Marcus Linke
*
* @deprecated use {@link com.github.dockerjava.api.async.ResultCallback.Adapter}
*/
@Deprecated
public class ExecStartResultCallback extends ResultCallbackTemplate<ExecStartResultCallback, Frame> {
private static final Logger LOGGER = LoggerFactory.getLogger(ExecStartResultCallback.class);
private OutputStream stdout, stderr;
public ExecStartResultCallback(OutputStream stdout, OutputStream stderr) {
this.stdout = stdout;
this.stderr = stderr;
}
public ExecStartResultCallback() {
this(null, null);
}
@Override
public void onNext(Frame frame) {
if (frame != null) {
try {
switch (frame.getStreamType()) {
case STDOUT:
case RAW:
if (stdout != null) {
stdout.write(frame.getPayload());
stdout.flush();
}
break;
case STDERR:
if (stderr != null) {
stderr.write(frame.getPayload());
stderr.flush();
}
break;
default:
LOGGER.error("unknown stream type:" + frame.getStreamType());
}
} catch (IOException e) {
onError(e);
}
LOGGER.debug(frame.toString());
}
}
}