You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@taverna.apache.org by st...@apache.org on 2016/06/22 17:11:47 UTC

[3/5] incubator-taverna-common-activities git commit: Spring enabled configuration for docker container creation phase1.

Spring enabled configuration for docker container creation phase1.


Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/commit/7da6ffef
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/tree/7da6ffef
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/diff/7da6ffef

Branch: refs/heads/docker
Commit: 7da6ffef0bdc8d042867fa29db48443a9019d6f4
Parents: 9f0eb33
Author: Nadeesh Dilanga <na...@gmail.com>
Authored: Sat Jun 18 02:47:22 2016 -0400
Committer: Nadeesh Dilanga <na...@gmail.com>
Committed: Sat Jun 18 02:47:22 2016 -0400

----------------------------------------------------------------------
 .../activities/docker/DockerActivity.java       | 26 +++++-
 .../docker/DockerActivityFactory.java           | 60 ++++++++++++++
 .../taverna/activities/docker/DockerConfig.java | 77 -----------------
 .../docker/DockerContainerConfiguration.java    | 87 ++++++++++++++++++++
 .../activities/docker/DockerHttpResponse.java   |  2 +
 .../taverna/activities/docker/RESTUtil.java     | 78 +++++++++++-------
 .../spring/docker-activity-context-osgi.xml     | 28 +++++++
 .../META-INF/spring/docker-activity-context.xml | 28 +++++++
 .../docker/test/TestCreateContainer.java        | 26 +++---
 9 files changed, 293 insertions(+), 119 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/7da6ffef/taverna-docker-activity/src/main/java/org/apache/taverna/activities/docker/DockerActivity.java
----------------------------------------------------------------------
diff --git a/taverna-docker-activity/src/main/java/org/apache/taverna/activities/docker/DockerActivity.java b/taverna-docker-activity/src/main/java/org/apache/taverna/activities/docker/DockerActivity.java
index c81e9de..902eaac 100644
--- a/taverna-docker-activity/src/main/java/org/apache/taverna/activities/docker/DockerActivity.java
+++ b/taverna-docker-activity/src/main/java/org/apache/taverna/activities/docker/DockerActivity.java
@@ -20,12 +20,14 @@ package org.apache.taverna.activities.docker;
 
 import com.fasterxml.jackson.databind.JsonNode;
 import org.apache.taverna.invocation.InvocationContext;
+import org.apache.taverna.reference.ErrorDocument;
 import org.apache.taverna.reference.ReferenceService;
 import org.apache.taverna.reference.T2Reference;
 import org.apache.taverna.workflowmodel.processor.activity.AbstractAsynchronousActivity;
 import org.apache.taverna.workflowmodel.processor.activity.ActivityConfigurationException;
 import org.apache.taverna.workflowmodel.processor.activity.AsynchronousActivityCallback;
 
+import java.util.HashMap;
 import java.util.Map;
 
 /**
@@ -34,6 +36,11 @@ import java.util.Map;
 public class DockerActivity extends AbstractAsynchronousActivity<JsonNode> {
 
     private JsonNode activityConfig;
+    private DockerContainerConfiguration containerConfiguration;
+
+    public DockerActivity(DockerContainerConfiguration containerConfiguration) {
+        this.containerConfiguration = containerConfiguration;
+    }
 
     @Override
     public void configure(JsonNode activityConfig) throws ActivityConfigurationException {
@@ -50,9 +57,26 @@ public class DockerActivity extends AbstractAsynchronousActivity<JsonNode> {
         callback.requestRun(new Runnable() {
             @Override
             public void run() {
+                Map<String, T2Reference> outputs = new HashMap<String, T2Reference>();
+                T2Reference responseBodyRef = null;
+
                 InvocationContext context = callback.getContext();
                 ReferenceService referenceService = context.getReferenceService();
-                //TODO invoke container remote api and set final response result to callback.receiveResult();
+
+                DockerHttpResponse response = RESTUtil.createContainer(containerConfiguration);
+                if(response != null && response.getStatusCode() == DockerHttpResponse.HTTP_201_CODE){
+                    responseBodyRef = referenceService.register(response.getBody(), 0, true, context);
+                } else {
+                    ErrorDocument errorDocument = referenceService.getErrorDocumentService().registerError(response.getBody(),0,context);
+                    responseBodyRef = referenceService.register(errorDocument, 0, true, context);
+                }
+
+                outputs.put("response_body", responseBodyRef);
+                T2Reference statusRef = referenceService.register(response.getStatusCode(), 0, true, context);
+                outputs.put("response_code", statusRef);
+                //TODO add any more useful parameters to the output
+
+                callback.receiveResult(outputs, new int[0]);
 
             }
         });

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/7da6ffef/taverna-docker-activity/src/main/java/org/apache/taverna/activities/docker/DockerActivityFactory.java
----------------------------------------------------------------------
diff --git a/taverna-docker-activity/src/main/java/org/apache/taverna/activities/docker/DockerActivityFactory.java b/taverna-docker-activity/src/main/java/org/apache/taverna/activities/docker/DockerActivityFactory.java
new file mode 100644
index 0000000..7dea3e8
--- /dev/null
+++ b/taverna-docker-activity/src/main/java/org/apache/taverna/activities/docker/DockerActivityFactory.java
@@ -0,0 +1,60 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+package org.apache.taverna.activities.docker;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import org.apache.taverna.workflowmodel.processor.activity.*;
+
+import java.net.URI;
+import java.util.Set;
+
+public class DockerActivityFactory implements ActivityFactory {
+
+    private DockerContainerConfiguration containerConfiguration;
+
+    @Override
+    public Activity<?> createActivity() {
+        return new DockerActivity(containerConfiguration);
+    }
+
+    @Override
+    public URI getActivityType() {
+        return null;
+    }
+
+    @Override
+    public JsonNode getActivityConfigurationSchema() {
+        return null;
+    }
+
+    @Override
+    public Set<ActivityInputPort> getInputPorts(JsonNode jsonNode) throws ActivityConfigurationException {
+        return null;
+    }
+
+    @Override
+    public Set<ActivityOutputPort> getOutputPorts(JsonNode jsonNode) throws ActivityConfigurationException {
+        return null;
+    }
+
+
+    public void setDockerConfigurationManagerManager(DockerContainerConfiguration dockerContainerConfiguration) {
+        this.containerConfiguration = containerConfiguration;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/7da6ffef/taverna-docker-activity/src/main/java/org/apache/taverna/activities/docker/DockerConfig.java
----------------------------------------------------------------------
diff --git a/taverna-docker-activity/src/main/java/org/apache/taverna/activities/docker/DockerConfig.java b/taverna-docker-activity/src/main/java/org/apache/taverna/activities/docker/DockerConfig.java
deleted file mode 100644
index 30d12c5..0000000
--- a/taverna-docker-activity/src/main/java/org/apache/taverna/activities/docker/DockerConfig.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-package org.apache.taverna.activities.docker;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-public class DockerConfig {
-
-    /**
-     * Hold the hostname of the docker container.
-     */
-    private String containerHost;
-
-    /**
-     * Remote REST API port exposed by Docker
-     */
-    private int remoteAPIPort = 443;
-
-    /**
-     * JSON payload to invoke create container REST API.
-     */
-    private JsonNode createContainerPayload;
-
-    /**
-     * Complete HTTP URL for create container
-     */
-    private final String createContainerURL;
-
-    /**
-     * Docker remote REST resource path for creating a container
-     */
-    public static final String CREATE_CONTAINER_RESOURCE_PATH = "/containers/create";
-
-    /**
-     * Transport protocol
-     */
-    public static final String PROTOCOL = "https";
-
-    public DockerConfig(String containerHost, int remoteAPIPort, JsonNode createContainerPayload) {
-        this.containerHost = containerHost;
-        this.remoteAPIPort = remoteAPIPort;
-        this.createContainerPayload = createContainerPayload;
-        this.createContainerURL = PROTOCOL + "://" + containerHost +  ":" + remoteAPIPort + CREATE_CONTAINER_RESOURCE_PATH ;
-    }
-
-    public String getContainerHost() {
-        return containerHost;
-    }
-
-    public int getRemoteAPIPort() {
-        return remoteAPIPort;
-    }
-
-    public JsonNode getCreateContainerPayload() {
-        return createContainerPayload;
-    }
-
-    public String getCreateContainerURL() {
-        return createContainerURL;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/7da6ffef/taverna-docker-activity/src/main/java/org/apache/taverna/activities/docker/DockerContainerConfiguration.java
----------------------------------------------------------------------
diff --git a/taverna-docker-activity/src/main/java/org/apache/taverna/activities/docker/DockerContainerConfiguration.java b/taverna-docker-activity/src/main/java/org/apache/taverna/activities/docker/DockerContainerConfiguration.java
new file mode 100644
index 0000000..3d8346f
--- /dev/null
+++ b/taverna-docker-activity/src/main/java/org/apache/taverna/activities/docker/DockerContainerConfiguration.java
@@ -0,0 +1,87 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+package org.apache.taverna.activities.docker;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+public class DockerContainerConfiguration {
+
+    /**
+     * Hold the hostname of the docker container.
+     */
+    private String containerHost;
+
+    /**
+     * Remote REST API port exposed by Docker
+     */
+    private int remoteAPIPort = 443;
+
+    /**
+     * JSON payload to invoke create container REST API.
+     */
+    private JsonNode createContainerPayload;
+
+    /**
+     * Complete HTTP URL for create container
+     */
+    private final String createContainerURL;
+
+    /**
+     * Docker remote REST resource path for creating a container
+     */
+    public static final String CREATE_CONTAINER_RESOURCE_PATH = "/containers/create";
+
+    /**
+     * Identifier for Http over SSL protocol
+     */
+    public static final String HTTP_OVER_SSL = "https";
+
+    /**
+     * Transport protocol
+     */
+    private String protocol = "http";
+
+    public DockerContainerConfiguration(String containerHost, int remoteAPIPort, String protocol, JsonNode createContainerPayload) {
+        this.containerHost = containerHost;
+        this.remoteAPIPort = remoteAPIPort;
+        this.protocol = protocol;
+        this.createContainerPayload = createContainerPayload;
+        this.createContainerURL = protocol + "://" + containerHost +  ":" + remoteAPIPort + CREATE_CONTAINER_RESOURCE_PATH ;
+    }
+
+    public String getContainerHost() {
+        return containerHost;
+    }
+
+    public String getProtocol() {
+        return protocol;
+    }
+
+    public int getRemoteAPIPort() {
+        return remoteAPIPort;
+    }
+
+    public JsonNode getCreateContainerPayload() {
+        return createContainerPayload;
+    }
+
+    public String getCreateContainerURL() {
+        return createContainerURL;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/7da6ffef/taverna-docker-activity/src/main/java/org/apache/taverna/activities/docker/DockerHttpResponse.java
----------------------------------------------------------------------
diff --git a/taverna-docker-activity/src/main/java/org/apache/taverna/activities/docker/DockerHttpResponse.java b/taverna-docker-activity/src/main/java/org/apache/taverna/activities/docker/DockerHttpResponse.java
index 336bca9..5ac5b8e 100644
--- a/taverna-docker-activity/src/main/java/org/apache/taverna/activities/docker/DockerHttpResponse.java
+++ b/taverna-docker-activity/src/main/java/org/apache/taverna/activities/docker/DockerHttpResponse.java
@@ -23,6 +23,8 @@ import org.apache.http.Header;
 
 public class DockerHttpResponse {
 
+    public static final int HTTP_201_CODE = 201;
+
     private Header[] headers;
 
     private int statusCode;

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/7da6ffef/taverna-docker-activity/src/main/java/org/apache/taverna/activities/docker/RESTUtil.java
----------------------------------------------------------------------
diff --git a/taverna-docker-activity/src/main/java/org/apache/taverna/activities/docker/RESTUtil.java b/taverna-docker-activity/src/main/java/org/apache/taverna/activities/docker/RESTUtil.java
index 99fff51..b052fdb 100644
--- a/taverna-docker-activity/src/main/java/org/apache/taverna/activities/docker/RESTUtil.java
+++ b/taverna-docker-activity/src/main/java/org/apache/taverna/activities/docker/RESTUtil.java
@@ -23,29 +23,27 @@ import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import org.apache.http.Header;
 import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
 import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.conn.ClientConnectionManager;
 import org.apache.http.conn.scheme.Scheme;
 import org.apache.http.conn.scheme.SchemeRegistry;
-import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
 import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.client.HttpClients;
 import org.apache.http.impl.conn.SingleClientConnManager;
 import org.apache.http.message.BasicHeader;
-import org.apache.http.ssl.SSLContexts;
 import org.apache.log4j.Logger;
 
 import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSocketFactory;
-import javax.security.cert.CertificateException;
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.security.KeyManagementException;
-import java.security.KeyStoreException;
 import java.security.NoSuchAlgorithmException;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -64,45 +62,59 @@ public class RESTUtil {
     private static final String JSON_CONTENT_TYPE = "application/json";
 
     /**
+     *
+     */
+    private static final String DEFAULT_ERROR_MSG= "{\"type\";\"Internal server error\"}";
+
+
+    /**
      * Logger
      */
     private static Logger LOG = Logger.getLogger(RESTUtil.class);
 
 
-    public static boolean createContainer(DockerConfig dockerConfig) {
+    public static DockerHttpResponse createContainer(DockerContainerConfiguration dockerContainerConfiguration) {
+        String errMsg;
         try {
-            URL url = new URL(dockerConfig.getCreateContainerURL());
-            org.apache.http.conn.ssl.SSLSocketFactory factory = new org.apache.http.conn.ssl.SSLSocketFactory(SSLContext.getDefault());
-            Scheme https = new Scheme(DockerConfig.PROTOCOL,factory , url.getPort());
-            SchemeRegistry schemeRegistry = new SchemeRegistry();
-            schemeRegistry.register(https);
-            ClientConnectionManager connectionManager = new SingleClientConnManager(null, schemeRegistry);
+            ClientConnectionManager connectionManager = null;
+            URL url = new URL(dockerContainerConfiguration.getCreateContainerURL());
+            if(DockerContainerConfiguration.HTTP_OVER_SSL.equalsIgnoreCase(dockerContainerConfiguration.getProtocol())) {
+                org.apache.http.conn.ssl.SSLSocketFactory factory = new org.apache.http.conn.ssl.SSLSocketFactory(SSLContext.getDefault());
+                Scheme https = new Scheme(dockerContainerConfiguration.getProtocol(), factory, url.getPort());
+                SchemeRegistry schemeRegistry = new SchemeRegistry();
+                schemeRegistry.register(https);
+                connectionManager = new SingleClientConnManager(null, schemeRegistry);
+            }
+
             Map<String,String> headers = new HashMap<String,String>();
             headers.put(CONTENT_TYPE, JSON_CONTENT_TYPE);
-            DockerHttpResponse response = doPost(connectionManager,dockerConfig.getCreateContainerURL(), headers, dockerConfig.getCreateContainerPayload());
-            if(response.getStatusCode() == 201){
+            DockerHttpResponse response = doPost(connectionManager, dockerContainerConfiguration.getCreateContainerURL(), headers, dockerContainerConfiguration.getCreateContainerPayload());
+            if(response.getStatusCode() == DockerHttpResponse.HTTP_201_CODE){
                 JsonNode node = getJson(response.getBody());
                 LOG.info(String.format("Successfully created Docker container id: %s ", getDockerId(node)));
-                return true;
+                return response;
             }
 
         } catch (MalformedURLException e1) {
-            LOG.error(String.format("Malformed URL encountered. This can be due to invalid URL parts. " +
+            errMsg = String.format("Malformed URL encountered. This can be due to invalid URL parts. " +
                             "Docker Host=%s, Port=%d and Resource Path=%s",
-                    dockerConfig.getContainerHost(),
-                    dockerConfig.getRemoteAPIPort(),
-                    DockerConfig.CREATE_CONTAINER_RESOURCE_PATH), e1);
+                    dockerContainerConfiguration.getContainerHost(),
+                    dockerContainerConfiguration.getRemoteAPIPort(),
+                    DockerContainerConfiguration.CREATE_CONTAINER_RESOURCE_PATH);
+            LOG.error(errMsg, e1);
         } catch (NoSuchAlgorithmException e2) {
-            LOG.error("Failed to create SSLContext for invoking the REST service over https.", e2);
+            errMsg = "Failed to create SSLContext for invoking the REST service over https." + e2.getMessage();
+            LOG.error(dockerContainerConfiguration);
         } catch (IOException e3) {
-            LOG.error("Error occurred while reading the docker http response", e3);
+            errMsg = "Error occurred while reading the docker http response " + e3.getMessage();
+            LOG.error(errMsg, e3);
         }
-        return false;
+        return null;
     }
 
     private static DockerHttpResponse doPost(ClientConnectionManager connectionManager, String url, Map<String, String> headers, JsonNode payload) {
-        DefaultHttpClient httpClient = null;
-        CloseableHttpResponse response = null;
+        HttpClient httpClient = null;
+        HttpResponse response = null;
         DockerHttpResponse dockerResponse = null;
         HttpPost httpPost = null;
         try {
@@ -112,7 +124,8 @@ public class RESTUtil {
             for (Map.Entry<String, String> entry : headers.entrySet()) {
                 httpPost.setHeader(new BasicHeader(entry.getKey(), entry.getValue()));
             }
-            httpClient = new DefaultHttpClient(connectionManager, null);
+            httpClient = connectionManager != null ? new DefaultHttpClient(connectionManager, null):HttpClients.createDefault();;
+
             response = httpClient.execute(httpPost);
             if (response != null) {
                 dockerResponse = new DockerHttpResponse(response.getAllHeaders(), response.getStatusLine().getStatusCode(),readBody(response.getEntity()).toString());
@@ -125,15 +138,24 @@ public class RESTUtil {
                     500,
                     "{\"error\":\"internal server error\", \"message\":\""+ e.getMessage() +"\"}");
         } finally {
+
             if(httpPost != null){
               httpPost.releaseConnection();
             }
             if (httpClient != null) {
-                httpClient.close();
+                if(httpClient instanceof DefaultHttpClient) {
+                    ((DefaultHttpClient) httpClient).close();
+                } else if(httpClient instanceof CloseableHttpClient){
+                    try {
+                        ((CloseableHttpClient) httpClient).close();
+                    } catch (IOException ignore) {}
+                }
             }
             if (response != null) {
                 try {
-                    response.close();
+                    if(response instanceof CloseableHttpResponse) {
+                        ((CloseableHttpResponse)response).close();
+                    }
                 } catch (IOException ignore) {}
             }
         }

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/7da6ffef/taverna-docker-activity/src/main/resources/META-INF/spring/docker-activity-context-osgi.xml
----------------------------------------------------------------------
diff --git a/taverna-docker-activity/src/main/resources/META-INF/spring/docker-activity-context-osgi.xml b/taverna-docker-activity/src/main/resources/META-INF/spring/docker-activity-context-osgi.xml
new file mode 100755
index 0000000..fa93613
--- /dev/null
+++ b/taverna-docker-activity/src/main/resources/META-INF/spring/docker-activity-context-osgi.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<beans:beans xmlns="http://www.springframework.org/schema/osgi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xmlns:beans="http://www.springframework.org/schema/beans"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans
+                      http://www.springframework.org/schema/beans/spring-beans.xsd
+                      http://www.springframework.org/schema/osgi
+                      http://www.springframework.org/schema/osgi/spring-osgi.xsd">
+
+	<reference id="dockerContainerConfiguration" interface="org.apache.taverna.activities.docker.DockerContainerConfiguration" />
+</beans:beans>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/7da6ffef/taverna-docker-activity/src/main/resources/META-INF/spring/docker-activity-context.xml
----------------------------------------------------------------------
diff --git a/taverna-docker-activity/src/main/resources/META-INF/spring/docker-activity-context.xml b/taverna-docker-activity/src/main/resources/META-INF/spring/docker-activity-context.xml
new file mode 100755
index 0000000..0378064
--- /dev/null
+++ b/taverna-docker-activity/src/main/resources/META-INF/spring/docker-activity-context.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans
+                      http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+	<bean id="dockerActivityFactory" class="org.apache.taverna.activities.docker.DockerActivityFactory">
+		<property name="dockerContainerConfiguration" ref="dockerContainerConfiguration" />
+	</bean>
+
+</beans>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/7da6ffef/taverna-docker-activity/src/test/java/org/apache/taverna/activities/docker/test/TestCreateContainer.java
----------------------------------------------------------------------
diff --git a/taverna-docker-activity/src/test/java/org/apache/taverna/activities/docker/test/TestCreateContainer.java b/taverna-docker-activity/src/test/java/org/apache/taverna/activities/docker/test/TestCreateContainer.java
index bd68abb..b54fd13 100644
--- a/taverna-docker-activity/src/test/java/org/apache/taverna/activities/docker/test/TestCreateContainer.java
+++ b/taverna-docker-activity/src/test/java/org/apache/taverna/activities/docker/test/TestCreateContainer.java
@@ -20,7 +20,8 @@
 package org.apache.taverna.activities.docker.test;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.taverna.activities.docker.DockerConfig;
+import org.apache.taverna.activities.docker.DockerContainerConfiguration;
+import org.apache.taverna.activities.docker.DockerHttpResponse;
 import org.apache.taverna.activities.docker.RESTUtil;
 import org.junit.Test;
 
@@ -28,16 +29,15 @@ import java.io.IOException;
 
 public class TestCreateContainer{
 
-//    @Test
-//    public void testCreateContainer(){
-//        try {
-//            String payload = "{\"Hostname\":\"foo.com\", \"User\":\"foo\", \"Memory\":0, \"MemorySwap\":0,\"AttachStdin\":false, \"AttachStdout\":true,\"Attachstderr\":true,\"PortSpecs\":null,\"Tty\":false,\"OpenStdin\":false,\"StdinOnce\":false,\"Env\":null, \"Cmd\":[\"date\"], \"Image\":\"ubuntu\",\"Tag\":\"latest\",\"Volumes\":{\"/tmp\":{} },\"WorkingDir\":\"\",\"DisableNetwork\":false, \"ExposedPorts\":{\"22/tcp\": {} }}";
-//            DockerConfig config = new DockerConfig("192.168.99.100",2376, new ObjectMapper().readTree(payload));
-//            boolean res = RESTUtil.createContainer(config);
-//            System.out.println(">>>" + res);
-//        } catch (IOException e) {
-//            e.printStackTrace();
-//        }
-//
-//    }
+    @Test
+    public void testCreateContainer(){
+        try {
+            String payload = "{\"Hostname\":\"192.168.99.100\", \"User\":\"foo\", \"Memory\":0, \"MemorySwap\":0,\"AttachStdin\":false, \"AttachStdout\":true,\"Attachstderr\":true,\"PortSpecs\":null,\"Tty\":false,\"OpenStdin\":false,\"StdinOnce\":false,\"Env\":null, \"Cmd\":[\"date\"], \"Image\":\"ubuntu\",\"Tag\":\"latest\",\"Volumes\":{\"/tmp\":{} },\"WorkingDir\":\"\",\"DisableNetwork\":false, \"ExposedPorts\":{\"22/tcp\": {} }}";
+            DockerContainerConfiguration config = new DockerContainerConfiguration("192.168.99.100",2376,"https",new ObjectMapper().readTree(payload));
+            DockerHttpResponse res = RESTUtil.createContainer(config);
+            System.out.println(">>>" + res.toString());
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
 }