Fixed CS
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/2f5626df Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2f5626df Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2f5626df Branch: refs/heads/master Commit: 2f5626df6580f731477953bfb93b2fdc43b0f381 Parents: fb9556d Author: Claus Ibsen <davscl...@apache.org> Authored: Mon Feb 23 08:11:16 2015 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Mon Feb 23 08:11:16 2015 +0100 ---------------------------------------------------------------------- .../component/docker/DockerClientFactory.java | 66 ++-- .../component/docker/DockerClientProfile.java | 117 +++++-- .../camel/component/docker/DockerComponent.java | 32 +- .../component/docker/DockerConfiguration.java | 6 +- .../camel/component/docker/DockerConstants.java | 140 +++++--- .../camel/component/docker/DockerEndpoint.java | 8 +- .../camel/component/docker/DockerHelper.java | 119 ++++--- .../camel/component/docker/DockerOperation.java | 332 ++++++++++--------- .../docker/consumer/DockerEventsConsumer.java | 52 +-- .../docker/exception/DockerException.java | 2 +- .../docker/producer/DockerProducer.java | 205 ++++++------ .../component/docker/ssl/NoImplSslConfig.java | 1 - .../docker/DockerClientProfileRegistryTest.java | 18 +- .../docker/DockerClientProfileTest.java | 11 +- .../docker/DockerConfigurationTest.java | 16 +- .../component/docker/DockerHelperTest.java | 3 +- .../component/docker/RemoveImageCmdUriTest.java | 17 +- .../headers/AttachContainerCmdHeaderTest.java | 14 +- .../docker/headers/AuthCmdHeaderTest.java | 20 +- .../docker/headers/BaseDockerHeaderTest.java | 58 ++-- .../docker/headers/BuildImageCmdHeaderTest.java | 31 +- .../headers/CommitContainerCmdHeaderTest.java | 21 +- .../headers/CopyFileContainerCmdHeaderTest.java | 13 +- .../headers/CreateContainerCmdHeaderTest.java | 21 +- .../headers/CreateImageCmdHeaderTest.java | 19 +- .../headers/DiffContainerCmdHeaderTest.java | 13 +- .../docker/headers/ExecCreateCmdHeaderTest.java | 22 +- .../docker/headers/ExecStartCmdHeaderTest.java | 19 +- .../docker/headers/InfoCmdHeaderTest.java | 11 +- .../headers/InspectContainerCmdHeaderTest.java | 13 +- .../headers/InspectImageCmdHeaderTest.java | 15 +- .../headers/KillContainerCmdHeaderTest.java | 13 +- .../headers/ListContainersCmdHeaderTest.java | 14 +- .../docker/headers/ListImagesCmdHeaderTest.java | 15 +- .../headers/LogContainerCmdHeaderTest.java | 13 +- .../headers/PauseContainerCmdHeaderTest.java | 15 +- .../docker/headers/PingCmdHeaderTest.java | 9 +- .../docker/headers/PullImageCmdHeaderTest.java | 15 +- .../docker/headers/PushImageCmdHeaderTest.java | 23 +- .../headers/RemoveContainerCmdHeaderTest.java | 14 +- .../headers/RemoveImageCmdHeaderTest.java | 14 +- .../headers/RestartContainerCmdHeaderTest.java | 15 +- .../headers/SearchImagesCmdHeaderTest.java | 11 +- .../headers/StartContainerCmdHeaderTest.java | 29 +- .../headers/StopContainerCmdHeaderTest.java | 15 +- .../docker/headers/TagImageCmdHeaderTest.java | 17 +- .../headers/TopContainerCmdHeaderTest.java | 15 +- .../headers/UnpauseContainerCmdHeaderTest.java | 15 +- .../docker/headers/VersionCmdHeaderTest.java | 11 +- .../headers/WaitContainerCmdHeaderTest.java | 15 +- .../docker/it/DockerProducerTestIT.java | 8 +- 51 files changed, 891 insertions(+), 840 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/2f5626df/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerClientFactory.java ---------------------------------------------------------------------- diff --git a/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerClientFactory.java b/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerClientFactory.java index 2ec9929..dfd7531 100644 --- a/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerClientFactory.java +++ b/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerClientFactory.java @@ -32,44 +32,38 @@ import org.apache.camel.util.ObjectHelper; * Methods for communicating with Docker */ public final class DockerClientFactory { - + private DockerClientFactory() { //Helper class } - - + /** * Produces a {@link DockerClient} to communicate with Docker - * - * @param dockerConfiguration - * @param endpointClientProfile a {@link DockerClientProfile} specified on the Endpoint - * @param message the Camel message - * @return a DockerClient - * @throws DockerException */ public static DockerClient getDockerClient(DockerConfiguration dockerConfiguration, Message message) throws DockerException { - + ObjectHelper.notNull(dockerConfiguration, "dockerConfiguration"); - + DockerClientProfile endpointClientProfile = dockerConfiguration.getClientProfile(); - - DockerClientProfile clientProfile = null; - DockerClient client = null; + + DockerClientProfile clientProfile; + DockerClient client; // Check if profile is specified in configuration - if(endpointClientProfile != null) { + if (endpointClientProfile != null) { clientProfile = endpointClientProfile; - } - else { - + } else { + clientProfile = new DockerClientProfile(); - + Integer port = DockerHelper.getProperty(DockerConstants.DOCKER_PORT, dockerConfiguration, message, Integer.class, clientProfile.getPort()); String host = DockerHelper.getProperty(DockerConstants.DOCKER_HOST, dockerConfiguration, message, String.class, clientProfile.getHost()); - - Integer maxTotalConnections = DockerHelper.getProperty(DockerConstants.DOCKER_MAX_TOTAL_CONNECTIONS, dockerConfiguration, message, Integer.class, clientProfile.getMaxTotalConnections()); - Integer maxPerRouteConnections = DockerHelper.getProperty(DockerConstants.DOCKER_MAX_PER_ROUTE_CONNECTIONS, dockerConfiguration, message, Integer.class, clientProfile.getMaxPerRouteConnections()); - + + Integer maxTotalConnections = DockerHelper.getProperty(DockerConstants.DOCKER_MAX_TOTAL_CONNECTIONS, dockerConfiguration, + message, Integer.class, clientProfile.getMaxTotalConnections()); + Integer maxPerRouteConnections = DockerHelper.getProperty(DockerConstants.DOCKER_MAX_PER_ROUTE_CONNECTIONS, dockerConfiguration, + message, Integer.class, clientProfile.getMaxPerRouteConnections()); + String username = DockerHelper.getProperty(DockerConstants.DOCKER_USERNAME, dockerConfiguration, message, String.class, clientProfile.getUsername()); String password = DockerHelper.getProperty(DockerConstants.DOCKER_PASSWORD, dockerConfiguration, message, String.class, clientProfile.getPassword()); String email = DockerHelper.getProperty(DockerConstants.DOCKER_EMAIL, dockerConfiguration, message, String.class, clientProfile.getEmail()); @@ -77,7 +71,7 @@ public final class DockerClientFactory { String serverAddress = DockerHelper.getProperty(DockerConstants.DOCKER_SERVER_ADDRESS, dockerConfiguration, message, String.class, clientProfile.getServerAddress()); String certPath = DockerHelper.getProperty(DockerConstants.DOCKER_CERT_PATH, dockerConfiguration, message, String.class, clientProfile.getCertPath()); Boolean secure = DockerHelper.getProperty(DockerConstants.DOCKER_SECURE, dockerConfiguration, message, Boolean.class, clientProfile.isSecure()); - + clientProfile.setHost(host); clientProfile.setPort(port); clientProfile.setEmail(email); @@ -89,7 +83,6 @@ public final class DockerClientFactory { clientProfile.setMaxTotalConnections(maxTotalConnections); clientProfile.setMaxPerRouteConnections(maxPerRouteConnections); clientProfile.setSecure(secure); - } client = dockerConfiguration.getClient(clientProfile); @@ -100,36 +93,29 @@ public final class DockerClientFactory { SSLConfig sslConfig; if (clientProfile.isSecure() != null && clientProfile.isSecure()) { - ObjectHelper.notNull(clientProfile.getCertPath(), "certPath must be specified in secure mode"); - sslConfig = new LocalDirectorySSLConfig(clientProfile.getCertPath()); - } - else { + } else { // docker-java requires an implementation of SslConfig interface // to be available for DockerCmdExecFactoryImpl sslConfig = new NoImplSslConfig(); } - + DockerClientConfig.DockerClientConfigBuilder configBuilder = new DockerClientConfig.DockerClientConfigBuilder() - .withUsername(clientProfile.getUsername()).withPassword(clientProfile.getPassword()).withEmail(clientProfile.getEmail()).withReadTimeout(clientProfile.getRequestTimeout()) - .withUri(clientProfile.toUrl()).withMaxPerRouteConnections(clientProfile.getMaxPerRouteConnections()).withMaxTotalConnections(clientProfile.getMaxTotalConnections()) - .withSSLConfig(sslConfig).withServerAddress(clientProfile.getServerAddress()); - - if(clientProfile.getCertPath() != null) { + .withUsername(clientProfile.getUsername()).withPassword(clientProfile.getPassword()).withEmail(clientProfile.getEmail()).withReadTimeout(clientProfile.getRequestTimeout()) + .withUri(clientProfile.toUrl()).withMaxPerRouteConnections(clientProfile.getMaxPerRouteConnections()).withMaxTotalConnections(clientProfile.getMaxTotalConnections()) + .withSSLConfig(sslConfig).withServerAddress(clientProfile.getServerAddress()); + + if (clientProfile.getCertPath() != null) { configBuilder.withDockerCertPath(clientProfile.getCertPath()); } DockerClientConfig config = configBuilder.build(); - DockerCmdExecFactory dockerClientFactory = new DockerCmdExecFactoryImpl(); - client = DockerClientBuilder.getInstance(config).withDockerCmdExecFactory(dockerClientFactory).build(); - dockerConfiguration.setClient(clientProfile, client); - + return client; - } } http://git-wip-us.apache.org/repos/asf/camel/blob/2f5626df/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerClientProfile.java ---------------------------------------------------------------------- diff --git a/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerClientProfile.java b/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerClientProfile.java index 7a53a08..f1a147c 100644 --- a/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerClientProfile.java +++ b/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerClientProfile.java @@ -21,67 +21,82 @@ import java.net.URL; import org.apache.camel.component.docker.exception.DockerException; import org.apache.camel.spi.UriParam; +import org.apache.camel.spi.UriParams; import org.apache.camel.util.ObjectHelper; /** * The elements representing a client initiating a connection to Docker */ +@UriParams public class DockerClientProfile { - + @UriParam(defaultValue = "localhost") private String host = "localhost"; - @UriParam(defaultValue = "2375") private Integer port = 2375; - + @UriParam private String username; + @UriParam private String password; + @UriParam private String email; + @UriParam private String serverAddress; + @UriParam private Integer requestTimeout; + @UriParam private Boolean secure; + @UriParam private String certPath; - @UriParam(defaultValue = "100") private Integer maxTotalConnections = 100; - @UriParam(defaultValue = "100") private Integer maxPerRouteConnections = 100; - public String getHost() { return host; } + public void setHost(String host) { this.host = host; } + public Integer getPort() { return port; } + public void setPort(Integer port) { this.port = port; } + public String getUsername() { return username; } + public void setUsername(String username) { this.username = username; } + public String getPassword() { return password; } + public void setPassword(String password) { this.password = password; } + public String getEmail() { return email; } + public void setEmail(String email) { this.email = email; } + public String getServerAddress() { return serverAddress; } + public void setServerAddress(String serverAddress) { this.serverAddress = serverAddress; } @@ -89,33 +104,43 @@ public class DockerClientProfile { public Integer getRequestTimeout() { return requestTimeout; } + public void setRequestTimeout(Integer requestTimeout) { this.requestTimeout = requestTimeout; } + public Boolean isSecure() { return secure; } + public void setSecure(Boolean secure) { this.secure = secure; } + public String getCertPath() { return certPath; } + public void setCertPath(String certPath) { this.certPath = certPath; } + public Integer getMaxTotalConnections() { return maxTotalConnections; } + public void setMaxTotalConnections(Integer maxTotalConnections) { this.maxTotalConnections = maxTotalConnections; } + public Integer getMaxPerRouteConnections() { return maxPerRouteConnections; } + public void setMaxPerRouteConnections(Integer maxPerRouteConnections) { this.maxPerRouteConnections = maxPerRouteConnections; } + public String toUrl() throws DockerException { ObjectHelper.notNull(this.host, "host"); ObjectHelper.notNull(this.port, "port"); @@ -131,6 +156,7 @@ public class DockerClientProfile { return uri.toString(); } + @Override public int hashCode() { final int prime = 31; @@ -148,72 +174,97 @@ public class DockerClientProfile { result = prime * result + ((username == null) ? 0 : username.hashCode()); return result; } + @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; - DockerClientProfile other = (DockerClientProfile)obj; + } + DockerClientProfile other = (DockerClientProfile) obj; if (certPath == null) { - if (other.certPath != null) + if (other.certPath != null) { return false; - } else if (!certPath.equals(other.certPath)) + } + } else if (!certPath.equals(other.certPath)) { return false; + } if (email == null) { - if (other.email != null) + if (other.email != null) { return false; - } else if (!email.equals(other.email)) + } + } else if (!email.equals(other.email)) { return false; + } if (host == null) { - if (other.host != null) + if (other.host != null) { return false; - } else if (!host.equals(other.host)) + } + } else if (!host.equals(other.host)) { return false; + } if (maxPerRouteConnections == null) { - if (other.maxPerRouteConnections != null) + if (other.maxPerRouteConnections != null) { return false; - } else if (!maxPerRouteConnections.equals(other.maxPerRouteConnections)) + } + } else if (!maxPerRouteConnections.equals(other.maxPerRouteConnections)) { return false; + } if (maxTotalConnections == null) { - if (other.maxTotalConnections != null) + if (other.maxTotalConnections != null) { return false; - } else if (!maxTotalConnections.equals(other.maxTotalConnections)) + } + } else if (!maxTotalConnections.equals(other.maxTotalConnections)) { return false; + } if (password == null) { - if (other.password != null) + if (other.password != null) { return false; - } else if (!password.equals(other.password)) + } + } else if (!password.equals(other.password)) { return false; + } if (port == null) { - if (other.port != null) + if (other.port != null) { return false; - } else if (!port.equals(other.port)) + } + } else if (!port.equals(other.port)) { return false; + } if (requestTimeout == null) { - if (other.requestTimeout != null) + if (other.requestTimeout != null) { return false; - } else if (!requestTimeout.equals(other.requestTimeout)) + } + } else if (!requestTimeout.equals(other.requestTimeout)) { return false; + } if (secure == null) { - if (other.secure != null) + if (other.secure != null) { return false; - } else if (!secure.equals(other.secure)) + } + } else if (!secure.equals(other.secure)) { return false; + } if (serverAddress == null) { - if (other.serverAddress != null) + if (other.serverAddress != null) { return false; - } else if (!serverAddress.equals(other.serverAddress)) + } + } else if (!serverAddress.equals(other.serverAddress)) { return false; + } if (username == null) { - if (other.username != null) + if (other.username != null) { return false; - } else if (!username.equals(other.username)) + } + } else if (!username.equals(other.username)) { return false; + } return true; } - } http://git-wip-us.apache.org/repos/asf/camel/blob/2f5626df/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerComponent.java b/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerComponent.java index 261adf3..b89b5d8 100644 --- a/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerComponent.java +++ b/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerComponent.java @@ -26,50 +26,50 @@ import org.apache.camel.impl.DefaultComponent; * Represents the component that manages {@link DockerEndpoint}. */ public class DockerComponent extends DefaultComponent { - + private DockerConfiguration configuration; - + public DockerComponent() { - + } - + public DockerComponent(DockerConfiguration configuration) { this.configuration = configuration; } - + @Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { - + // Each endpoint can have its own configuration so make // a copy of the configuration DockerConfiguration configuration = getConfiguration().copy(); - + String normalizedRemaining = remaining.replaceAll("/", ""); - + DockerOperation operation = DockerOperation.getDockerOperation(normalizedRemaining); - + if (operation == null) { throw new DockerException(remaining + " is not a valid operation"); } - + configuration.setOperation(operation); - + // Validate URI Parameters DockerHelper.validateParameters(operation, parameters); - + Endpoint endpoint = new DockerEndpoint(uri, this, configuration); setProperties(configuration, parameters); configuration.setParameters(parameters); - + return endpoint; } - + protected DockerConfiguration getConfiguration() { if (configuration == null) { configuration = new DockerConfiguration(); } - + return configuration; } - + } http://git-wip-us.apache.org/repos/asf/camel/blob/2f5626df/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerConfiguration.java ---------------------------------------------------------------------- diff --git a/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerConfiguration.java b/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerConfiguration.java index 9268a36..bd60604 100644 --- a/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerConfiguration.java +++ b/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerConfiguration.java @@ -16,13 +16,13 @@ */ package org.apache.camel.component.docker; -import com.github.dockerjava.api.DockerClient; - import java.util.HashMap; import java.util.Map; +import com.github.dockerjava.api.DockerClient; import org.apache.camel.RuntimeCamelException; import org.apache.camel.component.docker.exception.DockerException; +import org.apache.camel.spi.UriParam; import org.apache.camel.spi.UriParams; import org.apache.camel.spi.UriPath; @@ -32,6 +32,7 @@ public class DockerConfiguration implements Cloneable { @UriPath private DockerOperation operation; + @UriParam private DockerClientProfile clientProfile; private Map<String, Object> parameters = new HashMap<String, Object>(); @@ -78,5 +79,4 @@ public class DockerConfiguration implements Cloneable { } - } http://git-wip-us.apache.org/repos/asf/camel/blob/2f5626df/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerConstants.java ---------------------------------------------------------------------- diff --git a/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerConstants.java b/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerConstants.java index d70b6df..8428940 100644 --- a/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerConstants.java +++ b/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerConstants.java @@ -23,15 +23,19 @@ import java.util.Map; * Docker Component constants */ public final class DockerConstants { - + public static final String DOCKER_PREFIX = "CamelDocker"; public static final Map<String, Class<?>> DOCKER_DEFAULT_PARAMETERS = new HashMap<String, Class<?>>(); - /** Connectivity **/ + /** + * Connectivity * + */ public static final String DOCKER_CLIENT_PROFILE = "CamelDockerClientProfile"; - /** Connectivity **/ + /** + * Connectivity * + */ public static final String DOCKER_API_REQUEST_TIMEOUT = "CamelDockerRequestTimeout"; public static final String DOCKER_CERT_PATH = "CamelDockerCertPath"; public static final String DOCKER_HOST = "CamelDockerHost"; @@ -39,84 +43,122 @@ public final class DockerConstants { public static final String DOCKER_MAX_PER_ROUTE_CONNECTIONS = "CamelDockerMaxPerRouteConnections"; public static final String DOCKER_MAX_TOTAL_CONNECTIONS = "CamelDockerMaxTotalConnections"; public static final String DOCKER_SECURE = "CamelDockerSecure"; - - /** List Images **/ + + /** + * List Images * + */ public static final String DOCKER_FILTER = "CamelDockerFilter"; public static final String DOCKER_SHOW_ALL = "CamelDockerShowAll"; - /** Common **/ + /** + * Common * + */ public static final String DOCKER_CONTAINER_ID = "CamelDockerContainerId"; public static final String DOCKER_IMAGE_ID = "CamelDockerImageId"; - /** Auth **/ + /** + * Auth * + */ public static final String DOCKER_EMAIL = "CamelDockerEmail"; public static final String DOCKER_PASSWORD = "CamelDockerPassword"; public static final String DOCKER_SERVER_ADDRESS = "CamelDockerServerAddress"; public static final String DOCKER_USERNAME = "CamelDockerUsername"; - - /** Pull **/ + + /** + * Pull * + */ public static final String DOCKER_REGISTRY = "CamelDockerRegistry"; public static final String DOCKER_REPOSITORY = "CamelDockerRepository"; public static final String DOCKER_TAG = "CamelDockerTag"; - - /** Push **/ + + /** + * Push * + */ public static final String DOCKER_NAME = "CamelDockerName"; - - /** Search **/ + + /** + * Search * + */ public static final String DOCKER_TERM = "CamelDockerTerm"; - - /** Remove **/ + + /** + * Remove * + */ public static final String DOCKER_FORCE = "CamelDockerForce"; public static final String DOCKER_NO_PRUNE = "CamelDockerNoPrune"; - - /** Events **/ + + /** + * Events * + */ public static final String DOCKER_INITIAL_RANGE = "CamelDockerInitialRange"; - - /** List Container **/ + + /** + * List Container * + */ public static final String DOCKER_BEFORE = "CamelDockerBefore"; public static final String DOCKER_LIMIT = "CamelDockerLimit"; public static final String DOCKER_SHOW_SIZE = "CamelDockerShowSize"; public static final String DOCKER_SINCE = "CamelDockerSince"; - /** Remove Container **/ + /** + * Remove Container * + */ public static final String DOCKER_REMOVE_VOLUMES = "CamelDockerRemoveVolumes"; - /** Attach Container **/ + /** + * Attach Container * + */ public static final String DOCKER_FOLLOW_STREAM = "CamelDockerFollowStream"; public static final String DOCKER_LOGS = "CamelDockerLogs"; public static final String DOCKER_STD_ERR = "CamelDockerStdErr"; public static final String DOCKER_STD_OUT = "CamelDockerStdOut"; public static final String DOCKER_TIMESTAMPS = "CamelDockerTimestamps"; - - /** Logs **/ + + /** + * Logs * + */ public static final String DOCKER_TAIL = "CamelDockerTail"; public static final String DOCKER_TAIL_ALL = "CamelDockerTailAll"; - - /** Copy **/ + + /** + * Copy * + */ public static final String DOCKER_HOST_PATH = "CamelDockerHostPath"; public static final String DOCKER_RESOURCE = "CamelDockerResource"; - /** Diff Container **/ + /** + * Diff Container * + */ public static final String DOCKER_CONTAINER_ID_DIFF = "CamelDockerContainerIdDiff"; - /** Stop Container **/ + /** + * Stop Container * + */ public static final String DOCKER_TIMEOUT = "CamelDockerTimeout"; - /** Kill Container **/ + /** + * Kill Container * + */ public static final String DOCKER_SIGNAL = "CamelDockerSignal"; - - /** Top Container **/ + + /** + * Top Container * + */ public static final String DOCKER_PS_ARGS = "CamelDockerPsArgs"; - - /** Build Image **/ + + /** + * Build Image * + */ public static final String DOCKER_NO_CACHE = "CamelDockerNoCache"; public static final String DOCKER_QUIET = "CamelDockerQuiet"; public static final String DOCKER_REMOVE = "CamelDockerRemove"; public static final String DOCKER_TAR_INPUT_STREAM = "CamelDockerTarInputStream"; - - - /** Commit Container **/ + + + /** + * Commit Container * + */ public static final String DOCKER_ATTACH_STD_ERR = "CamelDockerAttachStdErr"; public static final String DOCKER_ATTACH_STD_IN = "CamelDockerAttachStdIn"; public static final String DOCKER_ATTACH_STD_OUT = "CamelDockerAttachStdOut"; @@ -139,33 +181,39 @@ public final class DockerConstants { public static final String DOCKER_VOLUMES = "CamelDockerVolumes"; public static final String DOCKER_WORKING_DIR = "CamelDockerWorkingDir"; - /** Create Container **/ + /** + * Create Container * + */ public static final String DOCKER_CPU_SHARES = "CamelDockerCpuShares"; public static final String DOCKER_DNS = "CamelDockerDns"; public static final String DOCKER_ENTRYPOINT = "CamelDockerEntryPoint"; public static final String DOCKER_HOST_CONFIG = "CamelDockerHostConfig"; public static final String DOCKER_IMAGE = "CamelDockerImage"; - public static final String DOCKER_MEMORY_LIMIT = "CamelDockerMemoryLimit"; + public static final String DOCKER_MEMORY_LIMIT = "CamelDockerMemoryLimit"; public static final String DOCKER_STD_IN_OPEN = "CamelDockerStdInOpen"; public static final String DOCKER_VOLUMES_FROM = "CamelDockerVolumesFrom"; - - /** Start Container **/ - public static final String DOCKER_BINDS = "CamelDockerBinds"; + + /** + * Start Container * + */ + public static final String DOCKER_BINDS = "CamelDockerBinds"; public static final String DOCKER_CAP_ADD = "CamelDockerCapAdd"; public static final String DOCKER_CAP_DROP = "CamelDockerCapDrop"; public static final String DOCKER_DEVICES = "CamelDockeDevices"; public static final String DOCKER_DNS_SEARCH = "CamelDockerDnsSearch"; - public static final String DOCKER_LINKS = "CamelDockerLinks"; - public static final String DOCKER_LXC_CONF = "CamelDockerLxcConf"; + public static final String DOCKER_LINKS = "CamelDockerLinks"; + public static final String DOCKER_LXC_CONF = "CamelDockerLxcConf"; public static final String DOCKER_NETWORK_MODE = "CamelNetworkMode"; public static final String DOCKER_PORT_BINDINGS = "CamelDockerPortBinding"; public static final String DOCKER_PORTS = "CamelDockerPorts"; public static final String DOCKER_PRIVILEGED = "CamelDockerDnsPrivileged"; public static final String DOCKER_PUBLISH_ALL_PORTS = "CamelDockerPublishAllPorts"; public static final String DOCKER_RESTART_POLICY = "CamelDockerRestartPolicy"; - - /** Exec **/ + + /** + * Exec * + */ public static final String DOCKER_DETACH = "CamelDockerDetach"; public static final String DOCKER_EXEC_ID = "CamelDockerExecId"; @@ -181,9 +229,9 @@ public final class DockerConstants { DOCKER_DEFAULT_PARAMETERS.put(DOCKER_SERVER_ADDRESS, String.class); DOCKER_DEFAULT_PARAMETERS.put(DOCKER_USERNAME, String.class); } - + private DockerConstants() { // Helper class } - + } http://git-wip-us.apache.org/repos/asf/camel/blob/2f5626df/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerEndpoint.java b/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerEndpoint.java index e6330b7..b023d73 100644 --- a/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerEndpoint.java +++ b/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerEndpoint.java @@ -49,7 +49,7 @@ public class DockerEndpoint extends DefaultEndpoint { public Producer createProducer() throws Exception { DockerOperation operation = configuration.getOperation(); - + if (operation != null && operation.canProduce()) { return new DockerProducer(this); } else { @@ -67,9 +67,7 @@ public class DockerEndpoint extends DefaultEndpoint { default: throw new DockerException(operation + " is not a valid consumer operation"); } - } - public boolean isSingleton() { return true; @@ -78,11 +76,11 @@ public class DockerEndpoint extends DefaultEndpoint { public DockerConfiguration getConfiguration() { return configuration; } - + @Override public boolean isLenientProperties() { return true; } - + } http://git-wip-us.apache.org/repos/asf/camel/blob/2f5626df/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerHelper.java ---------------------------------------------------------------------- diff --git a/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerHelper.java b/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerHelper.java index b7934ca..8003a6d 100644 --- a/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerHelper.java +++ b/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerHelper.java @@ -21,8 +21,6 @@ import java.util.HashMap; import java.util.Map; import com.github.dockerjava.api.DockerClientException; -import com.github.dockerjava.api.model.AuthConfig; - import org.apache.camel.Message; import org.apache.camel.util.ObjectHelper; import org.apache.commons.lang.BooleanUtils; @@ -31,16 +29,16 @@ import org.apache.commons.lang.BooleanUtils; * Utility methods for Docker Component */ public final class DockerHelper { - + private static final String STRING_DELIMITER = ";"; - + private DockerHelper() { //Helpser class } - + /** * Validates the URI parameters for a given {@link DockerOperation} - * + * * @param dockerOperation * @param parameters */ @@ -48,80 +46,82 @@ public final class DockerHelper { Map<String, Class<?>> validParamMap = new HashMap<String, Class<?>>(); validParamMap.putAll(DockerConstants.DOCKER_DEFAULT_PARAMETERS); validParamMap.putAll(dockerOperation.getParameters()); - + for (String key : parameters.keySet()) { - + String transformedKey = DockerHelper.transformToHeaderName(key); - + // Validate URI parameter name if (!validParamMap.containsKey(transformedKey)) { throw new DockerClientException(key + " is not a valid URI parameter"); } - - + + try { Class<?> parameterClass = validParamMap.get(transformedKey); Object parameterValue = parameters.get(key); - + if (parameterClass == null || parameterValue == null) { throw new DockerClientException("Failed to validate parameter type for property " + key); - } - + } + if (Integer.class == parameterClass) { - Integer.parseInt((String)parameterValue); + Integer.parseInt((String) parameterValue); } else if (Boolean.class == parameterClass) { - BooleanUtils.toBooleanObject((String)parameterValue, "true", "false", "null"); + BooleanUtils.toBooleanObject((String) parameterValue, "true", "false", "null"); } } catch (Exception e) { - throw new DockerClientException("Failed to validate parameter type for property " + key); + throw new DockerClientException("Failed to validate parameter type for property " + key); } } - + } - + /** * Transforms a Docker Component header value to its' analogous URI parameter + * * @param name * @return */ public static String transformFromHeaderName(String name) { ObjectHelper.notEmpty(name, "name"); - + StringBuilder formattedName = new StringBuilder(); - + String nameSubstring = name.substring(DockerConstants.DOCKER_PREFIX.length()); - + if (nameSubstring.length() > 0) { formattedName.append(nameSubstring.substring(0, 1).toLowerCase()); - formattedName.append(nameSubstring.substring(1)); + formattedName.append(nameSubstring.substring(1)); } - + return formattedName.toString(); } /** * Transforms a Docker Component URI parameter to its' analogous header value + * * @param name * @return */ public static String transformToHeaderName(String name) { ObjectHelper.notEmpty(name, "name"); - + StringBuilder formattedName = new StringBuilder(DockerConstants.DOCKER_PREFIX); - - + + if (name.length() > 0) { formattedName.append(name.substring(0, 1).toUpperCase()); - formattedName.append(name.substring(1)); + formattedName.append(name.substring(1)); } - + return formattedName.toString(); } /** - * Attempts to locate a given property name within a URI parameter or the message header. + * Attempts to locate a given property name within a URI parameter or the message header. * A found value in a message header takes precedence over a URI parameter. - * + * * @param name * @param configuration * @param message @@ -147,40 +147,39 @@ public final class DockerHelper { @SuppressWarnings("unchecked") public static <T> T getProperty(String name, DockerConfiguration configuration, Message message, Class<T> clazz, T defaultValue) { // First attempt to locate property from Message Header, then fallback to Endpoint property - + if (message != null) { T headerProperty = message.getHeader(name, clazz); - + if (headerProperty != null) { return headerProperty; } } - + Object prop = configuration.getParameters().get(transformFromHeaderName(name)); - + if (prop != null) { - + if (prop.getClass().isAssignableFrom(clazz)) { return (T) prop; } else if (Integer.class == clazz) { - return (T) Integer.valueOf((String)prop); + return (T) Integer.valueOf((String) prop); } else if (Boolean.class == clazz) { - return (T)BooleanUtils.toBooleanObject((String)prop, "true", "false", "null"); + return (T) BooleanUtils.toBooleanObject((String) prop, "true", "false", "null"); } - } - else if (defaultValue != null) { + } else if (defaultValue != null) { return defaultValue; } - + return null; - - + + } - + /** - * Attempts to locate a given property which is an array by name within a URI parameter or the message header. + * Attempts to locate a given property which is an array by name within a URI parameter or the message header. * A found value in a message header takes precedence over a URI parameter. - * + * * @param name * @param message * @param clazz @@ -188,47 +187,47 @@ public final class DockerHelper { */ @SuppressWarnings("unchecked") public static <T> T[] getArrayProperty(String name, Message message, Class<T> clazz) { - + if (message != null) { Object header = message.getHeader(name); - + if (header != null) { if (header.getClass().isAssignableFrom(clazz)) { - - T[] headerArray = (T[])Array.newInstance(clazz, 1); - headerArray[0] = (T)header; + + T[] headerArray = (T[]) Array.newInstance(clazz, 1); + headerArray[0] = (T) header; return headerArray; } if (header.getClass().isArray()) { if (header.getClass().getComponentType().isAssignableFrom(clazz) || header.getClass().getDeclaringClass().isAssignableFrom(clazz)) { - return (T[])header; + return (T[]) header; } } } } - + return null; - + } - + /** * @param headerName name of the header - * @param message the Camel message + * @param message the Camel message * @return */ public static String[] parseDelimitedStringHeader(String headerName, Message message) { Object header = message.getHeader(headerName); - + if (header != null) { - + if (header instanceof String) { return ((String) header).split(STRING_DELIMITER); } - + if (header instanceof String[]) { return (String[]) header; } @@ -237,5 +236,5 @@ public final class DockerHelper { return null; } - + } http://git-wip-us.apache.org/repos/asf/camel/blob/2f5626df/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerOperation.java ---------------------------------------------------------------------- diff --git a/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerOperation.java b/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerOperation.java index 0fb15cb..248b5a3 100644 --- a/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerOperation.java +++ b/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerOperation.java @@ -24,239 +24,249 @@ import java.util.Map; * Operations the Docker Component supports */ public enum DockerOperation { - - /** Events **/ + + /** + * Events * + */ EVENTS("events", false, true, - DockerConstants.DOCKER_INITIAL_RANGE, Long.class), - - /** General **/ + DockerConstants.DOCKER_INITIAL_RANGE, Long.class), + + /** + * General * + */ AUTH("auth", false, true, - DockerConstants.DOCKER_USERNAME, String.class, - DockerConstants.DOCKER_PASSWORD, String.class, - DockerConstants.DOCKER_EMAIL, String.class, - DockerConstants.DOCKER_SERVER_ADDRESS, String.class), + DockerConstants.DOCKER_USERNAME, String.class, + DockerConstants.DOCKER_PASSWORD, String.class, + DockerConstants.DOCKER_EMAIL, String.class, + DockerConstants.DOCKER_SERVER_ADDRESS, String.class), INFO("info", false, true), PING("ping", false, true), VERSION("version", false, true), - - /** Images **/ + + /** + * Images * + */ BUILD_IMAGE("imagebuild", false, true, - DockerConstants.DOCKER_NO_CACHE, Boolean.class, - DockerConstants.DOCKER_REMOVE, Boolean.class, - DockerConstants.DOCKER_QUIET, Boolean.class), + DockerConstants.DOCKER_NO_CACHE, Boolean.class, + DockerConstants.DOCKER_REMOVE, Boolean.class, + DockerConstants.DOCKER_QUIET, Boolean.class), CREATE_IMAGE("imagecreate", false, true, - DockerConstants.DOCKER_REPOSITORY, String.class), + DockerConstants.DOCKER_REPOSITORY, String.class), INSPECT_IMAGE("imageinspect", false, true, - DockerConstants.DOCKER_IMAGE_ID, String.class, - DockerConstants.DOCKER_NO_PRUNE, Boolean.class, - DockerConstants.DOCKER_FORCE, Boolean.class), + DockerConstants.DOCKER_IMAGE_ID, String.class, + DockerConstants.DOCKER_NO_PRUNE, Boolean.class, + DockerConstants.DOCKER_FORCE, Boolean.class), LIST_IMAGES("imagelist", false, true, - DockerConstants.DOCKER_FILTER, String.class, - DockerConstants.DOCKER_SHOW_ALL, Boolean.class), + DockerConstants.DOCKER_FILTER, String.class, + DockerConstants.DOCKER_SHOW_ALL, Boolean.class), PULL_IMAGE("imagepull", false, true, - DockerConstants.DOCKER_REGISTRY, String.class, - DockerConstants.DOCKER_TAG, String.class, - DockerConstants.DOCKER_REPOSITORY, String.class), + DockerConstants.DOCKER_REGISTRY, String.class, + DockerConstants.DOCKER_TAG, String.class, + DockerConstants.DOCKER_REPOSITORY, String.class), PUSH_IMAGE("imagepush", false, true, - DockerConstants.DOCKER_NAME, String.class, - DockerConstants.DOCKER_TAG, String.class), + DockerConstants.DOCKER_NAME, String.class, + DockerConstants.DOCKER_TAG, String.class), REMOVE_IMAGE("imageremove", false, true, - DockerConstants.DOCKER_IMAGE_ID, String.class, - DockerConstants.DOCKER_FORCE, Boolean.class, - DockerConstants.DOCKER_NO_PRUNE, String.class), + DockerConstants.DOCKER_IMAGE_ID, String.class, + DockerConstants.DOCKER_FORCE, Boolean.class, + DockerConstants.DOCKER_NO_PRUNE, String.class), SEARCH_IMAGES("imagesearch", false, true, - DockerConstants.DOCKER_TERM, String.class), + DockerConstants.DOCKER_TERM, String.class), TAG_IMAGE("imagetag", false, true, - DockerConstants.DOCKER_FORCE, Boolean.class, - DockerConstants.DOCKER_IMAGE_ID, String.class, - DockerConstants.DOCKER_REPOSITORY, String.class), - - /** Container **/ + DockerConstants.DOCKER_FORCE, Boolean.class, + DockerConstants.DOCKER_IMAGE_ID, String.class, + DockerConstants.DOCKER_REPOSITORY, String.class), + + /** + * Container * + */ ATTACH_CONTAINER("containerattach", false, true, - DockerConstants.DOCKER_CONTAINER_ID, String.class, - DockerConstants.DOCKER_FOLLOW_STREAM, Boolean.class, - DockerConstants.DOCKER_LOGS, Boolean.class, - DockerConstants.DOCKER_STD_OUT, Boolean.class, - DockerConstants.DOCKER_STD_ERR, Boolean.class, - DockerConstants.DOCKER_TIMESTAMPS, Boolean.class), + DockerConstants.DOCKER_CONTAINER_ID, String.class, + DockerConstants.DOCKER_FOLLOW_STREAM, Boolean.class, + DockerConstants.DOCKER_LOGS, Boolean.class, + DockerConstants.DOCKER_STD_OUT, Boolean.class, + DockerConstants.DOCKER_STD_ERR, Boolean.class, + DockerConstants.DOCKER_TIMESTAMPS, Boolean.class), COMMIT_CONTAINER("containercommit", false, true, - DockerConstants.DOCKER_ATTACH_STD_ERR, Boolean.class, - DockerConstants.DOCKER_ATTACH_STD_IN, Boolean.class, - DockerConstants.DOCKER_ATTACH_STD_OUT, Boolean.class, - DockerConstants.DOCKER_AUTHOR, String.class, - DockerConstants.DOCKER_CMD, String.class, - DockerConstants.DOCKER_CONTAINER_ID, String.class, - DockerConstants.DOCKER_DISABLE_NETWORK, String.class, - DockerConstants.DOCKER_ENV, String.class, - DockerConstants.DOCKER_EXPOSED_PORTS, String.class, - DockerConstants.DOCKER_HOSTNAME, String.class, - DockerConstants.DOCKER_MEMORY, Integer.class, - DockerConstants.DOCKER_MEMORY_SWAP, Integer.class, - DockerConstants.DOCKER_MESSAGE, String.class, - DockerConstants.DOCKER_OPEN_STD_IN, Boolean.class, - DockerConstants.DOCKER_PAUSE, Boolean.class, - DockerConstants.DOCKER_PORT_SPECS, String.class, - DockerConstants.DOCKER_REPOSITORY, String.class, - DockerConstants.DOCKER_STD_IN_ONCE, Boolean.class, - DockerConstants.DOCKER_TAG, String.class, - DockerConstants.DOCKER_TTY, Boolean.class, - DockerConstants.DOCKER_USER, String.class, - DockerConstants.DOCKER_VOLUMES, String.class, - DockerConstants.DOCKER_WORKING_DIR, String.class), + DockerConstants.DOCKER_ATTACH_STD_ERR, Boolean.class, + DockerConstants.DOCKER_ATTACH_STD_IN, Boolean.class, + DockerConstants.DOCKER_ATTACH_STD_OUT, Boolean.class, + DockerConstants.DOCKER_AUTHOR, String.class, + DockerConstants.DOCKER_CMD, String.class, + DockerConstants.DOCKER_CONTAINER_ID, String.class, + DockerConstants.DOCKER_DISABLE_NETWORK, String.class, + DockerConstants.DOCKER_ENV, String.class, + DockerConstants.DOCKER_EXPOSED_PORTS, String.class, + DockerConstants.DOCKER_HOSTNAME, String.class, + DockerConstants.DOCKER_MEMORY, Integer.class, + DockerConstants.DOCKER_MEMORY_SWAP, Integer.class, + DockerConstants.DOCKER_MESSAGE, String.class, + DockerConstants.DOCKER_OPEN_STD_IN, Boolean.class, + DockerConstants.DOCKER_PAUSE, Boolean.class, + DockerConstants.DOCKER_PORT_SPECS, String.class, + DockerConstants.DOCKER_REPOSITORY, String.class, + DockerConstants.DOCKER_STD_IN_ONCE, Boolean.class, + DockerConstants.DOCKER_TAG, String.class, + DockerConstants.DOCKER_TTY, Boolean.class, + DockerConstants.DOCKER_USER, String.class, + DockerConstants.DOCKER_VOLUMES, String.class, + DockerConstants.DOCKER_WORKING_DIR, String.class), COPY_FILE_CONTAINER("containercopyfile", false, true, - DockerConstants.DOCKER_CONTAINER_ID, String.class, - DockerConstants.DOCKER_HOST_PATH, String.class, - DockerConstants.DOCKER_RESOURCE, String.class), + DockerConstants.DOCKER_CONTAINER_ID, String.class, + DockerConstants.DOCKER_HOST_PATH, String.class, + DockerConstants.DOCKER_RESOURCE, String.class), CREATE_CONTAINER("containercreate", false, true, - DockerConstants.DOCKER_ATTACH_STD_ERR, Boolean.class, - DockerConstants.DOCKER_ATTACH_STD_IN, Boolean.class, - DockerConstants.DOCKER_ATTACH_STD_OUT, Boolean.class, - DockerConstants.DOCKER_CAP_ADD, String.class, - DockerConstants.DOCKER_CAP_DROP, String.class, - DockerConstants.DOCKER_CMD, String.class, - DockerConstants.DOCKER_CPU_SHARES, Integer.class, - DockerConstants.DOCKER_DISABLE_NETWORK, Boolean.class, - DockerConstants.DOCKER_DNS, String.class, - DockerConstants.DOCKER_ENTRYPOINT, String.class, - DockerConstants.DOCKER_ENV, String.class, - DockerConstants.DOCKER_EXPOSED_PORTS, String.class, - DockerConstants.DOCKER_HOST_CONFIG, String.class, - DockerConstants.DOCKER_HOSTNAME, String.class, - DockerConstants.DOCKER_IMAGE, String.class, - DockerConstants.DOCKER_NAME, String.class, - DockerConstants.DOCKER_PORT_SPECS, String.class, - DockerConstants.DOCKER_STD_IN_OPEN, Boolean.class, - DockerConstants.DOCKER_STD_IN_ONCE, Boolean.class, - DockerConstants.DOCKER_TTY, Boolean.class, - DockerConstants.DOCKER_USER, String.class, - DockerConstants.DOCKER_VOLUMES, String.class, - DockerConstants.DOCKER_VOLUMES_FROM, String.class, - DockerConstants.DOCKER_WORKING_DIR, String.class), + DockerConstants.DOCKER_ATTACH_STD_ERR, Boolean.class, + DockerConstants.DOCKER_ATTACH_STD_IN, Boolean.class, + DockerConstants.DOCKER_ATTACH_STD_OUT, Boolean.class, + DockerConstants.DOCKER_CAP_ADD, String.class, + DockerConstants.DOCKER_CAP_DROP, String.class, + DockerConstants.DOCKER_CMD, String.class, + DockerConstants.DOCKER_CPU_SHARES, Integer.class, + DockerConstants.DOCKER_DISABLE_NETWORK, Boolean.class, + DockerConstants.DOCKER_DNS, String.class, + DockerConstants.DOCKER_ENTRYPOINT, String.class, + DockerConstants.DOCKER_ENV, String.class, + DockerConstants.DOCKER_EXPOSED_PORTS, String.class, + DockerConstants.DOCKER_HOST_CONFIG, String.class, + DockerConstants.DOCKER_HOSTNAME, String.class, + DockerConstants.DOCKER_IMAGE, String.class, + DockerConstants.DOCKER_NAME, String.class, + DockerConstants.DOCKER_PORT_SPECS, String.class, + DockerConstants.DOCKER_STD_IN_OPEN, Boolean.class, + DockerConstants.DOCKER_STD_IN_ONCE, Boolean.class, + DockerConstants.DOCKER_TTY, Boolean.class, + DockerConstants.DOCKER_USER, String.class, + DockerConstants.DOCKER_VOLUMES, String.class, + DockerConstants.DOCKER_VOLUMES_FROM, String.class, + DockerConstants.DOCKER_WORKING_DIR, String.class), DIFF_CONTAINER("containerdiff", false, true, - DockerConstants.DOCKER_CONTAINER_ID, String.class), + DockerConstants.DOCKER_CONTAINER_ID, String.class), INSPECT_CONTAINER("inspectcontainer", false, true, - DockerConstants.DOCKER_CONTAINER_ID, String.class), + DockerConstants.DOCKER_CONTAINER_ID, String.class), KILL_CONTAINER("containerkill", false, true, - DockerConstants.DOCKER_CONTAINER_ID, String.class, - DockerConstants.DOCKER_SIGNAL, String.class), + DockerConstants.DOCKER_CONTAINER_ID, String.class, + DockerConstants.DOCKER_SIGNAL, String.class), LIST_CONTAINERS("containerlist", false, true, - DockerConstants.DOCKER_BEFORE, String.class, - DockerConstants.DOCKER_LIMIT, String.class, - DockerConstants.DOCKER_SHOW_ALL, Boolean.class, - DockerConstants.DOCKER_SHOW_SIZE, Boolean.class, - DockerConstants.DOCKER_SINCE, String.class), + DockerConstants.DOCKER_BEFORE, String.class, + DockerConstants.DOCKER_LIMIT, String.class, + DockerConstants.DOCKER_SHOW_ALL, Boolean.class, + DockerConstants.DOCKER_SHOW_SIZE, Boolean.class, + DockerConstants.DOCKER_SINCE, String.class), LOG_CONTAINER("containerlog", false, true, - DockerConstants.DOCKER_CONTAINER_ID, String.class, - DockerConstants.DOCKER_FOLLOW_STREAM, Boolean.class, - DockerConstants.DOCKER_STD_ERR, Boolean.class, - DockerConstants.DOCKER_STD_OUT, Boolean.class, - DockerConstants.DOCKER_TAIL, Integer.class, - DockerConstants.DOCKER_TAIL_ALL, Boolean.class, - DockerConstants.DOCKER_TIMESTAMPS, Boolean.class), + DockerConstants.DOCKER_CONTAINER_ID, String.class, + DockerConstants.DOCKER_FOLLOW_STREAM, Boolean.class, + DockerConstants.DOCKER_STD_ERR, Boolean.class, + DockerConstants.DOCKER_STD_OUT, Boolean.class, + DockerConstants.DOCKER_TAIL, Integer.class, + DockerConstants.DOCKER_TAIL_ALL, Boolean.class, + DockerConstants.DOCKER_TIMESTAMPS, Boolean.class), PAUSE_CONTAINER("containerpause", false, true, - DockerConstants.DOCKER_CONTAINER_ID, String.class), + DockerConstants.DOCKER_CONTAINER_ID, String.class), RESTART_CONTAINER("containerrestart", false, true, - DockerConstants.DOCKER_CONTAINER_ID, String.class, - DockerConstants.DOCKER_TIMEOUT, Integer.class), + DockerConstants.DOCKER_CONTAINER_ID, String.class, + DockerConstants.DOCKER_TIMEOUT, Integer.class), REMOVE_CONTAINER("containerremove", false, true, - DockerConstants.DOCKER_CONTAINER_ID, String.class, - DockerConstants.DOCKER_FORCE, Boolean.class, - DockerConstants.DOCKER_REMOVE_VOLUMES, Boolean.class), + DockerConstants.DOCKER_CONTAINER_ID, String.class, + DockerConstants.DOCKER_FORCE, Boolean.class, + DockerConstants.DOCKER_REMOVE_VOLUMES, Boolean.class), START_CONTAINER("containerstart", false, true, - DockerConstants.DOCKER_BINDS, String.class, - DockerConstants.DOCKER_CAP_ADD, String.class, - DockerConstants.DOCKER_CAP_DROP, String.class, - DockerConstants.DOCKER_CONTAINER_ID, String.class, - DockerConstants.DOCKER_DEVICES, String.class, - DockerConstants.DOCKER_DNS_SEARCH, String.class, - DockerConstants.DOCKER_DNS, String.class, - DockerConstants.DOCKER_LINKS, String.class, - DockerConstants.DOCKER_LXC_CONF, String.class, - DockerConstants.DOCKER_NETWORK_MODE, String.class, - DockerConstants.DOCKER_PORTS, String.class, - DockerConstants.DOCKER_PORT_BINDINGS, String.class, - DockerConstants.DOCKER_PRIVILEGED, Boolean.class, - DockerConstants.DOCKER_PUBLISH_ALL_PORTS, Boolean.class, - DockerConstants.DOCKER_RESTART_POLICY, String.class, - DockerConstants.DOCKER_VOLUMES_FROM, String.class), + DockerConstants.DOCKER_BINDS, String.class, + DockerConstants.DOCKER_CAP_ADD, String.class, + DockerConstants.DOCKER_CAP_DROP, String.class, + DockerConstants.DOCKER_CONTAINER_ID, String.class, + DockerConstants.DOCKER_DEVICES, String.class, + DockerConstants.DOCKER_DNS_SEARCH, String.class, + DockerConstants.DOCKER_DNS, String.class, + DockerConstants.DOCKER_LINKS, String.class, + DockerConstants.DOCKER_LXC_CONF, String.class, + DockerConstants.DOCKER_NETWORK_MODE, String.class, + DockerConstants.DOCKER_PORTS, String.class, + DockerConstants.DOCKER_PORT_BINDINGS, String.class, + DockerConstants.DOCKER_PRIVILEGED, Boolean.class, + DockerConstants.DOCKER_PUBLISH_ALL_PORTS, Boolean.class, + DockerConstants.DOCKER_RESTART_POLICY, String.class, + DockerConstants.DOCKER_VOLUMES_FROM, String.class), STOP_CONTAINER("containerstop", false, true, - DockerConstants.DOCKER_CONTAINER_ID, String.class, - DockerConstants.DOCKER_TIMEOUT, Integer.class), + DockerConstants.DOCKER_CONTAINER_ID, String.class, + DockerConstants.DOCKER_TIMEOUT, Integer.class), TOP_CONTAINER("containertop", false, true, - DockerConstants.DOCKER_CONTAINER_ID, String.class, - DockerConstants.DOCKER_PS_ARGS, String.class), + DockerConstants.DOCKER_CONTAINER_ID, String.class, + DockerConstants.DOCKER_PS_ARGS, String.class), UNPAUSE_CONTAINER("containerunpause", false, true, - DockerConstants.DOCKER_CONTAINER_ID, String.class), + DockerConstants.DOCKER_CONTAINER_ID, String.class), WAIT_CONTAINER("containerwait", false, true, - DockerConstants.DOCKER_CONTAINER_ID, String.class), - - - /** Exec **/ + DockerConstants.DOCKER_CONTAINER_ID, String.class), + + + /** + * Exec * + */ EXEC_CREATE("execcreate", false, true, - DockerConstants.DOCKER_ATTACH_STD_ERR, Boolean.class, - DockerConstants.DOCKER_ATTACH_STD_IN, Boolean.class, - DockerConstants.DOCKER_ATTACH_STD_OUT, Boolean.class, - DockerConstants.DOCKER_TTY, Boolean.class), + DockerConstants.DOCKER_ATTACH_STD_ERR, Boolean.class, + DockerConstants.DOCKER_ATTACH_STD_IN, Boolean.class, + DockerConstants.DOCKER_ATTACH_STD_OUT, Boolean.class, + DockerConstants.DOCKER_TTY, Boolean.class), EXEC_START("execstart", false, true, - DockerConstants.DOCKER_DETACH, Boolean.class, - DockerConstants.DOCKER_EXEC_ID, String.class, - DockerConstants.DOCKER_TTY, Boolean.class); - - + DockerConstants.DOCKER_DETACH, Boolean.class, + DockerConstants.DOCKER_EXEC_ID, String.class, + DockerConstants.DOCKER_TTY, Boolean.class); + + private String text; private boolean canConsume; private boolean canProduce; private Map<String, Class<?>> parameters; - - + + private DockerOperation(String text, boolean canConsume, boolean canProduce, Object... params) { - + this.text = text; this.canConsume = canConsume; this.canProduce = canProduce; - + parameters = new HashMap<String, Class<?>>(); - + if (params.length > 0) { - + if (params.length % 2 != 0) { throw new IllegalArgumentException("Invalid parameter list, " - + "must be of the form 'String name1, Class class1, String name2, Class class2..."); + + "must be of the form 'String name1, Class class1, String name2, Class class2..."); } - + int nParameters = params.length / 2; - + for (int i = 0; i < nParameters; i++) { parameters.put((String) params[i * 2], (Class<?>) params[i * 2 + 1]); } } } - + @Override public String toString() { return text; } - + public boolean canConsume() { return canConsume; } - + public boolean canProduce() { return canProduce; } - + public Map<String, Class<?>> getParameters() { return parameters; } - + public static DockerOperation getDockerOperation(String name) { for (DockerOperation dockerOperation : DockerOperation.values()) { if (dockerOperation.toString().equals(name)) { return dockerOperation; } } - + return null; } http://git-wip-us.apache.org/repos/asf/camel/blob/2f5626df/components/camel-docker/src/main/java/org/apache/camel/component/docker/consumer/DockerEventsConsumer.java ---------------------------------------------------------------------- diff --git a/components/camel-docker/src/main/java/org/apache/camel/component/docker/consumer/DockerEventsConsumer.java b/components/camel-docker/src/main/java/org/apache/camel/component/docker/consumer/DockerEventsConsumer.java index 49ae57a..e9c4985 100644 --- a/components/camel-docker/src/main/java/org/apache/camel/component/docker/consumer/DockerEventsConsumer.java +++ b/components/camel-docker/src/main/java/org/apache/camel/component/docker/consumer/DockerEventsConsumer.java @@ -42,74 +42,74 @@ public class DockerEventsConsumer extends DefaultConsumer implements EventCallba private static final transient Logger LOGGER = LoggerFactory.getLogger(DockerEventsConsumer.class); private DockerEndpoint endpoint; - + private EventsCmd eventsCmd; - + private ExecutorService eventsExecutorService; public DockerEventsConsumer(DockerEndpoint endpoint, Processor processor) throws Exception { super(endpoint, processor); this.endpoint = endpoint; - + } @Override public DockerEndpoint getEndpoint() { - return (DockerEndpoint)super.getEndpoint(); + return (DockerEndpoint) super.getEndpoint(); } - + /** * Determine the point in time to begin streaming events */ - private long processInitialEvent() { + private long processInitialEvent() { long currentTime = new Date().getTime(); - + Long initialRange = DockerHelper.getProperty(DockerConstants.DOCKER_INITIAL_RANGE, endpoint.getConfiguration(), null, Long.class); if (initialRange != null) { currentTime = currentTime - initialRange; - } - + } + return currentTime; - - + + } @Override protected void doStart() throws Exception { - - eventsCmd = DockerClientFactory.getDockerClient(endpoint.getConfiguration(),null).eventsCmd(this); - + + eventsCmd = DockerClientFactory.getDockerClient(endpoint.getConfiguration(), null).eventsCmd(this); + eventsCmd.withSince(String.valueOf(processInitialEvent())); - eventsExecutorService = eventsCmd.exec(); + eventsExecutorService = eventsCmd.exec(); super.doStart(); } @Override protected void doStop() throws Exception { - + if (eventsExecutorService != null && !eventsExecutorService.isTerminated()) { LOGGER.trace("Stopping Docker events Executor Service"); - + eventsExecutorService.shutdown(); } super.doStop(); } - + @Override public void onEvent(Event event) { - + LOGGER.debug("Received Docker Event: " + event); - + final Exchange exchange = getEndpoint().createExchange(); Message message = exchange.getIn(); message.setBody(event); - + try { LOGGER.trace("Processing exchange [{}]...", exchange); getAsyncProcessor().process(exchange, new AsyncCallback() { @@ -124,7 +124,7 @@ public class DockerEventsConsumer extends DefaultConsumer implements EventCallba if (exchange.getException() != null) { getExceptionHandler().handleException("Error processing exchange", exchange, exchange.getException()); } - + } @Override @@ -134,14 +134,14 @@ public class DockerEventsConsumer extends DefaultConsumer implements EventCallba @Override public void onCompletion(int numEvents) { - + LOGGER.debug("Docker events connection completed. Events processed : {}", numEvents); - + eventsCmd.withSince(null); - + LOGGER.debug("Reestablishing connection with Docker"); eventsCmd.exec(); - + } @Override http://git-wip-us.apache.org/repos/asf/camel/blob/2f5626df/components/camel-docker/src/main/java/org/apache/camel/component/docker/exception/DockerException.java ---------------------------------------------------------------------- diff --git a/components/camel-docker/src/main/java/org/apache/camel/component/docker/exception/DockerException.java b/components/camel-docker/src/main/java/org/apache/camel/component/docker/exception/DockerException.java index 77ce343..73728a6 100644 --- a/components/camel-docker/src/main/java/org/apache/camel/component/docker/exception/DockerException.java +++ b/components/camel-docker/src/main/java/org/apache/camel/component/docker/exception/DockerException.java @@ -26,7 +26,7 @@ public class DockerException extends Exception { public DockerException(String message) { super(message); } - + public DockerException(Throwable throwable) { super(throwable); } http://git-wip-us.apache.org/repos/asf/camel/blob/2f5626df/components/camel-docker/src/main/java/org/apache/camel/component/docker/producer/DockerProducer.java ---------------------------------------------------------------------- diff --git a/components/camel-docker/src/main/java/org/apache/camel/component/docker/producer/DockerProducer.java b/components/camel-docker/src/main/java/org/apache/camel/component/docker/producer/DockerProducer.java index aa7dacd..8bc3b3d 100644 --- a/components/camel-docker/src/main/java/org/apache/camel/component/docker/producer/DockerProducer.java +++ b/components/camel-docker/src/main/java/org/apache/camel/component/docker/producer/DockerProducer.java @@ -16,6 +16,9 @@ */ package org.apache.camel.component.docker.producer; +import java.io.File; +import java.io.InputStream; + import com.github.dockerjava.api.DockerClient; import com.github.dockerjava.api.command.AttachContainerCmd; import com.github.dockerjava.api.command.AuthCmd; @@ -64,10 +67,6 @@ import com.github.dockerjava.api.model.Ports; import com.github.dockerjava.api.model.RestartPolicy; import com.github.dockerjava.api.model.Volume; import com.github.dockerjava.api.model.Volumes; - -import java.io.File; -import java.io.InputStream; - import org.apache.camel.Exchange; import org.apache.camel.Message; import org.apache.camel.component.docker.DockerClientFactory; @@ -97,7 +96,7 @@ public class DockerProducer extends DefaultProducer { public void process(Exchange exchange) throws Exception { DockerCmd<?> dockerCmd = null; - + Message message = exchange.getIn(); DockerClient client = DockerClientFactory.getDockerClient(configuration, message); @@ -228,7 +227,7 @@ public class DockerProducer extends DefaultProducer { /** * Produces a Authorization request - * + * * @param client * @param message * @return @@ -238,10 +237,10 @@ public class DockerProducer extends DefaultProducer { LOGGER.debug("Executing Docker Auth Request"); AuthCmd authCmd = client.authCmd(); - + AuthConfig authConfig = client.authConfig(); - - if(authCmd != null) { + + if (authCmd != null) { authCmd.withAuthConfig(authConfig); } @@ -250,7 +249,7 @@ public class DockerProducer extends DefaultProducer { /** * Produces a platform information request - * + * * @param client * @param message * @return @@ -267,7 +266,7 @@ public class DockerProducer extends DefaultProducer { /** * Executes a ping platform request - * + * * @param client * @param message * @return @@ -284,7 +283,7 @@ public class DockerProducer extends DefaultProducer { /** * Executes a platform version request - * + * * @param client * @param message * @return @@ -305,7 +304,7 @@ public class DockerProducer extends DefaultProducer { /** * Produces a build image request - * + * * @param client * @param message * @return @@ -320,9 +319,9 @@ public class DockerProducer extends DefaultProducer { BuildImageCmd buildImageCmd; if (body != null && body instanceof InputStream) { - buildImageCmd = client.buildImageCmd((InputStream)body); + buildImageCmd = client.buildImageCmd((InputStream) body); } else if (body != null && body instanceof File) { - buildImageCmd = client.buildImageCmd((File)body); + buildImageCmd = client.buildImageCmd((File) body); } else { throw new DockerException("Unable to location source Image"); } @@ -355,10 +354,10 @@ public class DockerProducer extends DefaultProducer { } - + /** * Performs a create image request - * + * * @param client * @param message * @return @@ -370,20 +369,20 @@ public class DockerProducer extends DefaultProducer { String repository = DockerHelper.getProperty(DockerConstants.DOCKER_REPOSITORY, configuration, message, String.class); InputStream inputStream = message.getBody(InputStream.class); - - if(repository == null || inputStream == null) { + + if (repository == null || inputStream == null) { throw new IllegalArgumentException("Inputstream must be present on message body and repository must be specified"); } - + CreateImageCmd createImageCmd = client.createImageCmd(repository, inputStream); return createImageCmd; } - + /** * Produces a inspect image request - * + * * @param client * @param message * @return @@ -402,10 +401,10 @@ public class DockerProducer extends DefaultProducer { } - + /** * Performs a list images request - * + * * @param client * @param message * @return @@ -435,7 +434,7 @@ public class DockerProducer extends DefaultProducer { /** * Produces a pull image request - * + * * @param client * @param message * @return @@ -473,7 +472,7 @@ public class DockerProducer extends DefaultProducer { /** * Produces a push image request - * + * * @param client * @param message * @return @@ -503,10 +502,10 @@ public class DockerProducer extends DefaultProducer { return pushImageCmd; } - + /** * Produces a remove image request - * + * * @param client * @param message * @return @@ -559,10 +558,10 @@ public class DockerProducer extends DefaultProducer { } - + /** * Produces a tag image request - * + * * @param client * @param message * @return @@ -594,14 +593,13 @@ public class DockerProducer extends DefaultProducer { } - /********************* * Container Requests ********************/ /** * Produce a attach container request - * + * * @param client * @param message * @return @@ -621,19 +619,19 @@ public class DockerProducer extends DefaultProducer { if (followStream != null) { attachContainerCmd.withFollowStream(followStream); } - + Boolean logs = DockerHelper.getProperty(DockerConstants.DOCKER_LOGS, configuration, message, Boolean.class); if (logs != null) { attachContainerCmd.withLogs(logs); } - + Boolean stdErr = DockerHelper.getProperty(DockerConstants.DOCKER_STD_ERR, configuration, message, Boolean.class); if (stdErr != null) { attachContainerCmd.withStdErr(stdErr); } - + Boolean stdOut = DockerHelper.getProperty(DockerConstants.DOCKER_STD_OUT, configuration, message, Boolean.class); if (stdOut != null) { @@ -650,10 +648,10 @@ public class DockerProducer extends DefaultProducer { return attachContainerCmd; } - + /** * Produces a commit container request - * + * * @param client * @param message * @return @@ -666,15 +664,15 @@ public class DockerProducer extends DefaultProducer { String containerId = DockerHelper.getProperty(DockerConstants.DOCKER_CONTAINER_ID, configuration, message, String.class); ObjectHelper.notNull(containerId, "Container ID must be specified"); - + CommitCmd commitCmd = client.commitCmd(containerId); - + String author = DockerHelper.getProperty(DockerConstants.DOCKER_AUTHOR, configuration, message, String.class); if (author != null) { commitCmd.withAuthor(author); } - + Boolean attachStdErr = DockerHelper.getProperty(DockerConstants.DOCKER_ATTACH_STD_ERR, configuration, message, Boolean.class); if (attachStdErr != null) { @@ -710,7 +708,7 @@ public class DockerProducer extends DefaultProducer { if (envs != null) { commitCmd.withEnv(envs); } - + ExposedPorts exposedPorts = DockerHelper.getProperty(DockerConstants.DOCKER_EXPOSED_PORTS, configuration, message, ExposedPorts.class); if (exposedPorts != null) { @@ -746,7 +744,7 @@ public class DockerProducer extends DefaultProducer { if (openStdIn != null) { commitCmd.withOpenStdin(openStdIn); } - + Boolean pause = DockerHelper.getProperty(DockerConstants.DOCKER_PAUSE, configuration, message, Boolean.class); if (pause != null) { @@ -758,13 +756,13 @@ public class DockerProducer extends DefaultProducer { if (portSpecs != null) { commitCmd.withPortSpecs(portSpecs); } - + String repository = DockerHelper.getProperty(DockerConstants.DOCKER_REPOSITORY, configuration, message, String.class); if (repository != null) { commitCmd.withRepository(repository); } - + Boolean stdInOnce = DockerHelper.getProperty(DockerConstants.DOCKER_STD_IN_ONCE, configuration, message, Boolean.class); if (stdInOnce != null) { @@ -804,10 +802,10 @@ public class DockerProducer extends DefaultProducer { return commitCmd; } - + /** * Produces a copy file/folder from container request - * + * * @param client * @param message * @return @@ -834,10 +832,10 @@ public class DockerProducer extends DefaultProducer { return copyFileContainerCmd; } - + /** * Produce a create container request - * + * * @param client * @param message * @return @@ -857,7 +855,7 @@ public class DockerProducer extends DefaultProducer { if (attachStdErr != null) { createContainerCmd.withAttachStderr(attachStdErr); } - + Boolean attachStdIn = DockerHelper.getProperty(DockerConstants.DOCKER_ATTACH_STD_IN, configuration, message, Boolean.class); if (attachStdIn != null) { @@ -869,7 +867,7 @@ public class DockerProducer extends DefaultProducer { if (attachStdOut != null) { createContainerCmd.withAttachStdout(attachStdOut); } - + Capability[] capAdd = DockerHelper.getArrayProperty(DockerConstants.DOCKER_CAP_ADD, message, Capability.class); if (capAdd != null) { @@ -881,25 +879,25 @@ public class DockerProducer extends DefaultProducer { if (capDrop != null) { createContainerCmd.withCapDrop(capDrop); } - + String[] cmd = DockerHelper.parseDelimitedStringHeader(DockerConstants.DOCKER_CMD, message); if (cmd != null) { createContainerCmd.withCmd(cmd); } - + Integer cpuShares = DockerHelper.getProperty(DockerConstants.DOCKER_CPU_SHARES, configuration, message, Integer.class); if (cpuShares != null) { createContainerCmd.withCpuShares(cpuShares); } - + Boolean disableNetwork = DockerHelper.getProperty(DockerConstants.DOCKER_DISABLE_NETWORK, configuration, message, Boolean.class); if (disableNetwork != null) { createContainerCmd.withDisableNetwork(disableNetwork); } - + String[] dns = DockerHelper.parseDelimitedStringHeader(DockerConstants.DOCKER_DNS, message); if (dns != null) { @@ -911,7 +909,7 @@ public class DockerProducer extends DefaultProducer { if (env != null) { createContainerCmd.withEnv(env); } - + String[] entrypoint = DockerHelper.getArrayProperty(DockerConstants.DOCKER_ENTRYPOINT, message, String.class); if (entrypoint != null) { @@ -923,7 +921,7 @@ public class DockerProducer extends DefaultProducer { if (exposedPorts != null) { createContainerCmd.withExposedPorts(exposedPorts); } - + HostConfig hostConfig = DockerHelper.getProperty(DockerConstants.DOCKER_HOST_CONFIG, configuration, message, HostConfig.class); if (hostConfig != null) { @@ -935,7 +933,7 @@ public class DockerProducer extends DefaultProducer { if (hostName != null) { createContainerCmd.withHostName(hostName); } - + Long memoryLimit = DockerHelper.getProperty(DockerConstants.DOCKER_MEMORY_LIMIT, configuration, message, Long.class); if (memoryLimit != null) { @@ -977,7 +975,7 @@ public class DockerProducer extends DefaultProducer { if (tty != null) { createContainerCmd.withTty(tty); } - + String user = DockerHelper.getProperty(DockerConstants.DOCKER_USER, configuration, message, String.class); if (user != null) { @@ -995,7 +993,7 @@ public class DockerProducer extends DefaultProducer { if (volumesFrom != null) { createContainerCmd.withVolumesFrom(volumesFrom); } - + String workingDir = DockerHelper.getProperty(DockerConstants.DOCKER_WORKING_DIR, configuration, message, String.class); if (workingDir != null) { @@ -1005,10 +1003,10 @@ public class DockerProducer extends DefaultProducer { return createContainerCmd; } - + /** * Produces a diff container request - * + * * @param client * @param message * @return @@ -1035,7 +1033,7 @@ public class DockerProducer extends DefaultProducer { /** * Produce a inspect container request - * + * * @param client * @param message * @return @@ -1053,10 +1051,10 @@ public class DockerProducer extends DefaultProducer { return inspectContainerCmd; } - + /** * Produces a kill container request - * + * * @param client * @param message * @return @@ -1080,10 +1078,10 @@ public class DockerProducer extends DefaultProducer { return killContainerCmd; } - + /** * Produces a list containers request - * + * * @param client * @param message * @return @@ -1095,32 +1093,32 @@ public class DockerProducer extends DefaultProducer { ListContainersCmd listContainersCmd = client.listContainersCmd(); String before = DockerHelper.getProperty(DockerConstants.DOCKER_BEFORE, configuration, message, String.class); - + if (before != null) { listContainersCmd.withBefore(before); } - + Integer limit = DockerHelper.getProperty(DockerConstants.DOCKER_LIMIT, configuration, message, Integer.class); - + if (limit != null) { listContainersCmd.withLimit(limit); } - + Boolean showAll = DockerHelper.getProperty(DockerConstants.DOCKER_SHOW_ALL, configuration, message, Boolean.class); - + if (showAll != null) { listContainersCmd.withShowAll(showAll); } - + Boolean showSize = DockerHelper.getProperty(DockerConstants.DOCKER_SHOW_SIZE, configuration, message, Boolean.class); - + if (showSize != null) { listContainersCmd.withShowSize(showSize); } String since = DockerHelper.getProperty(DockerConstants.DOCKER_SINCE, configuration, message, String.class); - + if (since != null) { listContainersCmd.withSince(since); } @@ -1128,10 +1126,10 @@ public class DockerProducer extends DefaultProducer { return listContainersCmd; } - + /** * Produce a log container request - * + * * @param client * @param message * @return @@ -1145,13 +1143,13 @@ public class DockerProducer extends DefaultProducer { ObjectHelper.notNull(containerId, "Container ID must be specified"); LogContainerCmd logContainerCmd = client.logContainerCmd(containerId); - + Boolean followStream = DockerHelper.getProperty(DockerConstants.DOCKER_FOLLOW_STREAM, configuration, message, Boolean.class); if (followStream != null) { logContainerCmd.withFollowStream(followStream); } - + Boolean stdErr = DockerHelper.getProperty(DockerConstants.DOCKER_STD_ERR, configuration, message, Boolean.class); if (stdErr != null) { @@ -1163,13 +1161,13 @@ public class DockerProducer extends DefaultProducer { if (stdOut != null) { logContainerCmd.withStdOut(stdOut); } - + Integer tail = DockerHelper.getProperty(DockerConstants.DOCKER_TAIL, configuration, message, Integer.class); if (tail != null) { logContainerCmd.withTail(tail); } - + Boolean tailAll = DockerHelper.getProperty(DockerConstants.DOCKER_TAIL_ALL, configuration, message, Boolean.class); if (tailAll != null && tailAll) { @@ -1188,7 +1186,7 @@ public class DockerProducer extends DefaultProducer { /** * Produces a pause container request - * + * * @param client * @param message * @return @@ -1206,10 +1204,10 @@ public class DockerProducer extends DefaultProducer { return pauseContainerCmd; } - + /** * Produces a remove container request - * + * * @param client * @param message * @return @@ -1242,7 +1240,7 @@ public class DockerProducer extends DefaultProducer { /** * Produces a restart container request - * + * * @param client * @param message * @return @@ -1268,7 +1266,7 @@ public class DockerProducer extends DefaultProducer { /** * Produce a start container request - * + * * @param client * @param message * @return @@ -1288,7 +1286,7 @@ public class DockerProducer extends DefaultProducer { if (binds != null) { startContainerCmd.withBinds(binds); } - + Capability[] capAdd = DockerHelper.getArrayProperty(DockerConstants.DOCKER_CAP_ADD, message, Capability.class); if (capAdd != null) { @@ -1300,13 +1298,13 @@ public class DockerProducer extends DefaultProducer { if (capDrop != null) { startContainerCmd.withCapDrop(capDrop); } - + Device[] devices = DockerHelper.getArrayProperty(DockerConstants.DOCKER_DEVICES, message, Device.class); if (devices != null) { startContainerCmd.withDevices(devices); } - + String[] dns = DockerHelper.parseDelimitedStringHeader(DockerConstants.DOCKER_DNS, message); if (dns != null) { @@ -1330,7 +1328,7 @@ public class DockerProducer extends DefaultProducer { if (lxcConf != null) { startContainerCmd.withLxcConf(lxcConf); } - + String networkMode = DockerHelper.getProperty(DockerConstants.DOCKER_NETWORK_MODE, configuration, message, String.class); if (networkMode != null) { @@ -1360,7 +1358,7 @@ public class DockerProducer extends DefaultProducer { if (publishAllPorts != null) { startContainerCmd.withPublishAllPorts(publishAllPorts); } - + RestartPolicy restartPolicy = DockerHelper.getProperty(DockerConstants.DOCKER_RESTART_POLICY, configuration, message, RestartPolicy.class); if (restartPolicy != null) { @@ -1376,10 +1374,10 @@ public class DockerProducer extends DefaultProducer { return startContainerCmd; } - + /** * Produces a stop container request - * + * * @param client * @param message * @return @@ -1404,7 +1402,7 @@ public class DockerProducer extends DefaultProducer { /** * Produces a top container request - * + * * @param client * @param message * @return @@ -1428,10 +1426,10 @@ public class DockerProducer extends DefaultProducer { return topContainerCmd; } - + /** * Produces a unpause container request - * + * * @param client * @param message * @return @@ -1449,11 +1447,11 @@ public class DockerProducer extends DefaultProducer { return unpauseContainerCmd; } - + /** * Produce a wait container request - * + * * @param client * @param message * @return @@ -1471,8 +1469,7 @@ public class DockerProducer extends DefaultProducer { return waitContainerCmd; } - - + /********************* * Exec Requests @@ -1481,7 +1478,7 @@ public class DockerProducer extends DefaultProducer { /** * Produces a exec create request - * + * * @param client * @param message * @return @@ -1503,7 +1500,7 @@ public class DockerProducer extends DefaultProducer { if (attachStdErr != null) { execCreateCmd.withAttachStderr(attachStdErr); } - + if (attachStdIn != null) { execCreateCmd.withAttachStdin(attachStdIn); } @@ -1513,7 +1510,7 @@ public class DockerProducer extends DefaultProducer { if (attachStdOut != null) { execCreateCmd.withAttachStdout(attachStdOut); } - + String[] cmd = DockerHelper.parseDelimitedStringHeader(DockerConstants.DOCKER_CMD, message); if (cmd != null) { @@ -1532,7 +1529,7 @@ public class DockerProducer extends DefaultProducer { /** * Produces a exec start request - * + * * @param client * @param message * @return @@ -1552,7 +1549,7 @@ public class DockerProducer extends DefaultProducer { if (detach != null) { execStartCmd.withDetach(detach); } - + Boolean tty = DockerHelper.getProperty(DockerConstants.DOCKER_TTY, configuration, message, Boolean.class); if (tty != null) {