11package com .github .dockerjava .jaxrs ;
22
3- import com .fasterxml .jackson .databind .node .ObjectNode ;
4- import com .github .dockerjava .api .command .WaitContainerCmd ;
5- import com .github .dockerjava .core .DockerClientConfig ;
6- import org .slf4j .Logger ;
7- import org .slf4j .LoggerFactory ;
3+ import static javax .ws .rs .client .Entity .entity ;
84
95import javax .ws .rs .client .WebTarget ;
106import javax .ws .rs .core .MediaType ;
117
12- public class WaitContainerCmdExec extends AbstrSyncDockerCmdExec <WaitContainerCmd , Integer > implements
8+ import org .slf4j .Logger ;
9+ import org .slf4j .LoggerFactory ;
10+
11+ import com .github .dockerjava .api .async .ResultCallback ;
12+ import com .github .dockerjava .api .command .WaitContainerCmd ;
13+ import com .github .dockerjava .api .model .WaitResponse ;
14+ import com .github .dockerjava .core .DockerClientConfig ;
15+ import com .github .dockerjava .core .async .JsonStreamProcessor ;
16+ import com .github .dockerjava .jaxrs .async .AbstractCallbackNotifier ;
17+ import com .github .dockerjava .jaxrs .async .POSTCallbackNotifier ;
18+
19+ public class WaitContainerCmdExec extends AbstrAsyncDockerCmdExec <WaitContainerCmd , WaitResponse > implements
1320 WaitContainerCmd .Exec {
1421
1522 private static final Logger LOGGER = LoggerFactory .getLogger (WaitContainerCmdExec .class );
@@ -19,14 +26,16 @@ public WaitContainerCmdExec(WebTarget baseResource, DockerClientConfig dockerCli
1926 }
2027
2128 @ Override
22- protected Integer execute (WaitContainerCmd command ) {
29+ protected AbstractCallbackNotifier <WaitResponse > callbackNotifier (WaitContainerCmd command ,
30+ ResultCallback <WaitResponse > resultCallback ) {
31+
2332 WebTarget webResource = getBaseResource ().path ("/containers/{id}/wait" ).resolveTemplate ("id" ,
2433 command .getContainerId ());
2534
2635 LOGGER .trace ("POST: {}" , webResource );
27- ObjectNode ObjectNode = webResource .request ().accept (MediaType .APPLICATION_JSON ).post (null , ObjectNode .class );
2836
29- return ObjectNode .get ("StatusCode" ).asInt ();
37+ return new POSTCallbackNotifier <WaitResponse >(new JsonStreamProcessor <WaitResponse >(
38+ WaitResponse .class ), resultCallback , webResource .request ().accept (MediaType .APPLICATION_JSON ), entity (null , MediaType .APPLICATION_JSON ));
3039 }
3140
3241}
0 commit comments