com.github.dockerjava.jaxrs.AbstrAsyncDockerCmdExec Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of org.apache.servicemix.bundles.docker-java
Show all versions of org.apache.servicemix.bundles.docker-java
This OSGi bundle wraps ${pkgArtifactId} ${pkgVersion} jar file.
package com.github.dockerjava.jaxrs;
import java.io.Closeable;
import java.io.IOException;
import javax.ws.rs.client.WebTarget;
import com.github.dockerjava.api.async.ResultCallback;
import com.github.dockerjava.api.command.AsyncDockerCmd;
import com.github.dockerjava.api.command.DockerCmdAsyncExec;
import com.github.dockerjava.core.DockerClientConfig;
import com.github.dockerjava.jaxrs.async.AbstractCallbackNotifier;
public abstract class AbstrAsyncDockerCmdExec, A_RES_T> extends
AbstrDockerCmdExec implements DockerCmdAsyncExec {
public AbstrAsyncDockerCmdExec(WebTarget baseResource, DockerClientConfig dockerClientConfig) {
super(baseResource, dockerClientConfig);
}
@Override
public Void exec(CMD_T command, ResultCallback resultCallback) {
return execute(command, resultCallback);
}
protected final Void execute(final CMD_T command, final ResultCallback resultCallback) {
ResultCallback delegatingResultCallback = new ResultCallback() {
@Override
public void close() throws IOException {
resultCallback.close();
command.close();
}
@Override
public void onStart(Closeable closeable) {
resultCallback.onStart(closeable);
}
@Override
public void onNext(A_RES_T object) {
resultCallback.onNext(object);
}
@Override
public void onError(Throwable throwable) {
resultCallback.onError(throwable);
}
@Override
public void onComplete() {
resultCallback.onComplete();
command.close();
}
};
AbstractCallbackNotifier callbackNotifier = callbackNotifier(command, delegatingResultCallback);
AbstractCallbackNotifier.startAsyncProcessing(callbackNotifier);
return null;
}
protected abstract AbstractCallbackNotifier callbackNotifier(CMD_T command,
ResultCallback resultCallback);
}