Skip to content

Commit 9b93299

Browse files
author
Marcus Linke
committed
Refactored async commands for passing result callback into exec() method
1 parent f65b03f commit 9b93299

File tree

108 files changed

+409
-494
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+409
-494
lines changed

src/main/java/com/github/dockerjava/api/DockerClient.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ public interface DockerClient extends Closeable {
7171
* * IMAGE API *
7272
*/
7373

74-
public PullImageCmd pullImageCmd(String repository, ResultCallback<PullResponseItem> resultCallback);
74+
public PullImageCmd pullImageCmd(String repository);
7575

76-
public PushImageCmd pushImageCmd(String name, ResultCallback<PushResponseItem> resultCallback);
76+
public PushImageCmd pushImageCmd(String name);
7777

78-
public PushImageCmd pushImageCmd(Identifier identifier, ResultCallback<PushResponseItem> resultCallback);
78+
public PushImageCmd pushImageCmd(Identifier identifier);
7979

8080
public CreateImageCmd createImageCmd(String repository, InputStream imageStream);
8181

@@ -117,13 +117,13 @@ public interface DockerClient extends Closeable {
117117

118118
public WaitContainerCmd waitContainerCmd(String containerId);
119119

120-
public AttachContainerCmd attachContainerCmd(String containerId, ResultCallback<Frame> resultCallback);
120+
public AttachContainerCmd attachContainerCmd(String containerId);
121121

122122
public ExecStartCmd execStartCmd(String containerId);
123123

124124
public InspectExecCmd inspectExecCmd(String execId);
125125

126-
public LogContainerCmd logContainerCmd(String containerId, ResultCallback<Frame> resultCallback);
126+
public LogContainerCmd logContainerCmd(String containerId);
127127

128128
public CopyFileFromContainerCmd copyFileFromContainerCmd(String containerId, String resource);
129129

@@ -137,11 +137,11 @@ public interface DockerClient extends Closeable {
137137

138138
public CommitCmd commitCmd(String containerId);
139139

140-
public BuildImageCmd buildImageCmd(ResultCallback<BuildResponseItem> resultCallback);
140+
public BuildImageCmd buildImageCmd();
141141

142-
public BuildImageCmd buildImageCmd(File dockerFileOrFolder, ResultCallback<BuildResponseItem> resultCallback);
142+
public BuildImageCmd buildImageCmd(File dockerFileOrFolder);
143143

144-
public BuildImageCmd buildImageCmd(InputStream tarInputStream, ResultCallback<BuildResponseItem> resultCallback);
144+
public BuildImageCmd buildImageCmd(InputStream tarInputStream);
145145

146146
public TopContainerCmd topContainerCmd(String containerId);
147147

@@ -151,9 +151,9 @@ public interface DockerClient extends Closeable {
151151

152152
public UnpauseContainerCmd unpauseContainerCmd(String containerId);
153153

154-
public EventsCmd eventsCmd(ResultCallback<Event> resultCallback);
154+
public EventsCmd eventsCmd();
155155

156-
public StatsCmd statsCmd(ResultCallback<Statistics> resultCallback);
156+
public StatsCmd statsCmd();
157157

158158
@Override
159159
public void close() throws IOException;

src/main/java/com/github/dockerjava/api/async/ResultCallback.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
/**
66
* Result callback
77
*/
8-
public interface ResultCallback<RES_T> extends Closeable {
8+
public interface ResultCallback<A_RES_T> extends Closeable {
99
/**
1010
* Called when the async processing starts. The passed {@link Closeable} can be used to close/interrupt the
1111
* processing
1212
*/
1313
void onStart(Closeable closeable);
1414

1515
/** Called when an async result event occurs */
16-
void onNext(RES_T object);
16+
void onNext(A_RES_T object);
1717

1818
/** Called when an exception occurs while processing */
1919
void onError(Throwable throwable);

src/main/java/com/github/dockerjava/api/command/AsyncDockerCmd.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@
1111
* @author marcus
1212
*
1313
*/
14-
public interface AsyncDockerCmd<CMD_T extends AsyncDockerCmd<CMD_T, A_RES_T, RES_T>, A_RES_T, RES_T> extends DockerCmd<RES_T> {
14+
public interface AsyncDockerCmd<CMD_T extends AsyncDockerCmd<CMD_T, A_RES_T>, A_RES_T> extends DockerCmd<Void> {
1515

16-
public ResultCallback<A_RES_T> getResultCallback();
1716

18-
public CMD_T withResultCallback(ResultCallback<A_RES_T> resultCallback);
17+
public <T extends ResultCallback<A_RES_T>> T exec(T resultCallback);
1918

2019
}

src/main/java/com/github/dockerjava/api/command/AttachContainerCmd.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import java.io.InputStream;
44

55
import com.github.dockerjava.api.DockerClient;
6-
import com.github.dockerjava.api.NotFoundException;
76
import com.github.dockerjava.api.model.Frame;
87

98
/**
@@ -21,7 +20,7 @@
2120
* @param timestamps
2221
* - true or false, if true, print timestamps for every log line. Defaults to false.
2322
*/
24-
public interface AttachContainerCmd extends AsyncDockerCmd<AttachContainerCmd, Frame, Void> {
23+
public interface AttachContainerCmd extends AsyncDockerCmd<AttachContainerCmd, Frame> {
2524

2625
public String getContainerId();
2726

@@ -63,14 +62,7 @@ public interface AttachContainerCmd extends AsyncDockerCmd<AttachContainerCmd, F
6362

6463
public AttachContainerCmd withLogs();
6564

66-
/**
67-
* @throws NotFoundException
68-
* No such container
69-
*/
70-
@Override
71-
public Void exec();
72-
73-
public static interface Exec extends DockerCmdExec<AttachContainerCmd, Void> {
65+
public static interface Exec extends DockerCmdAsyncExec<AttachContainerCmd, Frame> {
7466
}
7567

7668
}

src/main/java/com/github/dockerjava/api/command/AuthCmd.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
import com.github.dockerjava.api.model.AuthResponse;
66

77
/**
8-
*
8+
*
99
* Authenticate with the server, useful for checking authentication.
10-
*
10+
*
1111
*/
12-
public interface AuthCmd extends DockerCmd<AuthResponse> {
12+
public interface AuthCmd extends SyncDockerCmd<AuthResponse> {
1313

1414
public AuthConfig getAuthConfig();
1515

@@ -24,7 +24,7 @@ public interface AuthCmd extends DockerCmd<AuthResponse> {
2424
@Override
2525
public AuthResponse exec() throws UnauthorizedException;
2626

27-
public static interface Exec extends DockerCmdExec<AuthCmd, AuthResponse> {
27+
public static interface Exec extends DockerCmdSyncExec<AuthCmd, AuthResponse> {
2828
}
2929

3030
}

src/main/java/com/github/dockerjava/api/command/BuildImageCmd.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* TODO: http://docs.docker.com/reference/builder/#dockerignore
1414
*
1515
*/
16-
public interface BuildImageCmd extends AsyncDockerCmd<BuildImageCmd, BuildResponseItem, Void> {
16+
public interface BuildImageCmd extends AsyncDockerCmd<BuildImageCmd, BuildResponseItem> {
1717

1818
public BuildImageCmd withTag(String tag);
1919

@@ -57,7 +57,7 @@ public interface BuildImageCmd extends AsyncDockerCmd<BuildImageCmd, BuildRespon
5757

5858
public BuildImageCmd withBuildAuthConfigs(AuthConfigurations authConfig);
5959

60-
public static interface Exec extends DockerCmdExec<BuildImageCmd, Void> {
60+
public static interface Exec extends DockerCmdAsyncExec<BuildImageCmd, BuildResponseItem> {
6161
}
6262

6363

src/main/java/com/github/dockerjava/api/command/CommitCmd.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Create a new image from a container's changes. Returns the new image ID.
1010
*
1111
*/
12-
public interface CommitCmd extends DockerCmd<String> {
12+
public interface CommitCmd extends SyncDockerCmd<String> {
1313

1414
public String getContainerId();
1515

@@ -110,7 +110,7 @@ public interface CommitCmd extends DockerCmd<String> {
110110
@Override
111111
public String exec() throws NotFoundException;
112112

113-
public static interface Exec extends DockerCmdExec<CommitCmd, String> {
113+
public static interface Exec extends DockerCmdSyncExec<CommitCmd, String> {
114114
}
115115

116116
}

src/main/java/com/github/dockerjava/api/command/ContainerDiffCmd.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import com.github.dockerjava.api.NotFoundException;
88
import com.github.dockerjava.api.model.ChangeLog;
99

10-
public interface ContainerDiffCmd extends DockerCmd<List<ChangeLog>> {
10+
public interface ContainerDiffCmd extends SyncDockerCmd<List<ChangeLog>> {
1111

1212
public String getContainerId();
1313

@@ -27,7 +27,7 @@ public interface ContainerDiffCmd extends DockerCmd<List<ChangeLog>> {
2727
@Override
2828
public List<ChangeLog> exec() throws NotFoundException;
2929

30-
public static interface Exec extends DockerCmdExec<ContainerDiffCmd, List<ChangeLog>> {
30+
public static interface Exec extends DockerCmdSyncExec<ContainerDiffCmd, List<ChangeLog>> {
3131
}
3232

3333
}

src/main/java/com/github/dockerjava/api/command/CopyFileFromContainerCmd.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import com.github.dockerjava.api.NotFoundException;
66

7-
public interface CopyFileFromContainerCmd extends DockerCmd<InputStream> {
7+
public interface CopyFileFromContainerCmd extends SyncDockerCmd<InputStream> {
88

99
public String getContainerId();
1010

@@ -20,14 +20,14 @@ public interface CopyFileFromContainerCmd extends DockerCmd<InputStream> {
2020

2121
/**
2222
* Its the responsibility of the caller to consume and/or close the {@link InputStream} to prevent connection leaks.
23-
*
23+
*
2424
* @throws NotFoundException
2525
* No such container
2626
*/
2727
@Override
2828
public InputStream exec() throws NotFoundException;
2929

30-
public static interface Exec extends DockerCmdExec<CopyFileFromContainerCmd, InputStream> {
30+
public static interface Exec extends DockerCmdSyncExec<CopyFileFromContainerCmd, InputStream> {
3131
}
3232

3333
}

src/main/java/com/github/dockerjava/api/command/CreateContainerCmd.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
import com.github.dockerjava.api.model.Volume;
1818
import com.github.dockerjava.api.model.VolumesFrom;
1919

20-
public interface CreateContainerCmd extends DockerCmd<CreateContainerResponse> {
20+
public interface CreateContainerCmd extends SyncDockerCmd<CreateContainerResponse> {
2121

22-
public static interface Exec extends DockerCmdExec<CreateContainerCmd, CreateContainerResponse> {
22+
public static interface Exec extends DockerCmdSyncExec<CreateContainerCmd, CreateContainerResponse> {
2323
}
2424

2525
/**

0 commit comments

Comments
 (0)