summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-2.x/trunk/modules')
-rw-r--r--sca-java-2.x/trunk/modules/binding-atom-runtime/META-INF/MANIFEST.MF15
-rw-r--r--sca-java-2.x/trunk/modules/binding-atom-runtime/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory19
-rw-r--r--sca-java-2.x/trunk/modules/binding-atom-runtime/pom.xml20
-rw-r--r--sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java319
-rw-r--r--sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingListenerServlet.java4
-rw-r--r--sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingUtil.java4
-rw-r--r--sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomReferenceBindingProvider.java18
-rw-r--r--sca-java-2.x/trunk/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/MediaCollectionTestCase.java156
-rw-r--r--sca-java-2.x/trunk/modules/binding-jsonp-runtime/META-INF/MANIFEST.MF12
-rw-r--r--sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/pom.xml2
-rw-r--r--sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/META-INF/MANIFEST.MF1
-rw-r--r--sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/pom.xml24
-rw-r--r--sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationServicePolicyInterceptor.java4
-rw-r--r--sca-java-2.x/trunk/modules/common-http/META-INF/MANIFEST.MF15
-rw-r--r--sca-java-2.x/trunk/modules/common-http/pom.xml6
-rw-r--r--sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/client/HttpClientFactory.java58
-rw-r--r--sca-java-2.x/trunk/modules/databinding-axiom/pom.xml4
-rw-r--r--sca-java-2.x/trunk/modules/databinding-jaxb-axiom/pom.xml4
-rw-r--r--sca-java-2.x/trunk/modules/databinding-sdo-axiom/pom.xml4
-rw-r--r--sca-java-2.x/trunk/modules/implementation-python-runtime/pom.xml2
-rw-r--r--sca-java-2.x/trunk/modules/implementation-script-runtime/pom.xml6
-rw-r--r--sca-java-2.x/trunk/modules/implementation-script/pom.xml2
-rw-r--r--sca-java-2.x/trunk/modules/policy-wspolicy/pom.xml4
23 files changed, 416 insertions, 287 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-atom-runtime/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/binding-atom-runtime/META-INF/MANIFEST.MF
index 4ae5784c2a..62bc96dd98 100644
--- a/sca-java-2.x/trunk/modules/binding-atom-runtime/META-INF/MANIFEST.MF
+++ b/sca-java-2.x/trunk/modules/binding-atom-runtime/META-INF/MANIFEST.MF
@@ -21,22 +21,23 @@ Import-Package: javax.servlet,
org.apache.abdera.protocol.client.util,
org.apache.abdera.writer,
org.apache.commons.codec.binary,
- org.apache.commons.httpclient,
- org.apache.commons.httpclient.auth,
- org.apache.commons.httpclient.methods,
- org.apache.commons.httpclient.params,
+ org.apache.http,
+ org.apache.http.client,
+ org.apache.http.client.entity,
+ org.apache.http.client.methods,
+ org.apache.http.entity,
+ org.apache.http.message,
org.apache.tuscany.sca.assembly;version="2.0.0",
org.apache.tuscany.sca.binding.atom;version="2.0.0",
- org.apache.tuscany.sca.binding.http;version="2.0.0",
org.apache.tuscany.sca.common.http;version="2.0.0",
+ org.apache.tuscany.sca.common.http.client;version="2.0.0",
org.apache.tuscany.sca.core;version="2.0.0",
org.apache.tuscany.sca.data.collection;version="2.0.0",
org.apache.tuscany.sca.databinding;version="2.0.0",
org.apache.tuscany.sca.host.http;version="2.0.0",
org.apache.tuscany.sca.interfacedef;version="2.0.0",
org.apache.tuscany.sca.interfacedef.impl;version="2.0.0";resolution:=optional,
- org.apache.tuscany.sca.interfacedef.util,
- org.apache.tuscany.sca.interfacedef.wsdl;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
org.apache.tuscany.sca.invocation;version="2.0.0",
org.apache.tuscany.sca.provider;version="2.0.0",
org.apache.tuscany.sca.runtime;version="2.0.0",
diff --git a/sca-java-2.x/trunk/modules/binding-atom-runtime/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/sca-java-2.x/trunk/modules/binding-atom-runtime/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
deleted file mode 100644
index 1b9052299c..0000000000
--- a/sca-java-2.x/trunk/modules/binding-atom-runtime/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
+++ /dev/null
@@ -1,19 +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.
-
-# Implementation class for the binding extension
-org.apache.tuscany.sca.binding.atom.provider.AtomBindingProviderFactory;model=org.apache.tuscany.sca.binding.atom.AtomBinding
diff --git a/sca-java-2.x/trunk/modules/binding-atom-runtime/pom.xml b/sca-java-2.x/trunk/modules/binding-atom-runtime/pom.xml
index ce7fb47ccc..d353f1074b 100644
--- a/sca-java-2.x/trunk/modules/binding-atom-runtime/pom.xml
+++ b/sca-java-2.x/trunk/modules/binding-atom-runtime/pom.xml
@@ -92,22 +92,16 @@
</dependency>
<dependency>
- <groupId>commons-httpclient</groupId>
- <artifactId>commons-httpclient</artifactId>
- <version>3.1</version>
- </dependency>
-
- <dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-impl</artifactId>
- <version>1.2.8</version>
+ <version>1.2.10</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.abdera</groupId>
<artifactId>abdera-core</artifactId>
- <version>1.0</version>
+ <version>1.1.1</version>
<exclusions>
<exclusion>
<groupId>org.apache.geronimo.specs</groupId>
@@ -119,7 +113,7 @@
<dependency>
<groupId>org.apache.abdera</groupId>
<artifactId>abdera-parser</artifactId>
- <version>1.0</version>
+ <version>1.1.1</version>
<exclusions>
<exclusion>
<groupId>stax</groupId>
@@ -139,19 +133,19 @@
<dependency>
<groupId>org.apache.abdera</groupId>
<artifactId>abdera-client</artifactId>
- <version>1.0</version>
+ <version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.abdera</groupId>
<artifactId>abdera-extensions-main</artifactId>
- <version>1.0</version>
+ <version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.abdera</groupId>
<artifactId>abdera-extensions-json</artifactId>
- <version>1.0</version>
+ <version>1.1.1</version>
</dependency>
<dependency>
@@ -218,7 +212,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
- <skip>true</skip>
+ <skip>false</skip>
</configuration>
</plugin>
</plugins>
diff --git a/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java b/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java
index e92bfa07e4..9ad69d58a3 100644
--- a/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java
+++ b/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java
@@ -21,6 +21,7 @@ package org.apache.tuscany.sca.binding.atom.provider;
import static org.apache.tuscany.sca.binding.atom.provider.AtomBindingUtil.entry;
import static org.apache.tuscany.sca.binding.atom.provider.AtomBindingUtil.feedEntry;
+import java.io.IOException;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
@@ -30,12 +31,15 @@ import org.apache.abdera.factory.Factory;
import org.apache.abdera.model.Document;
import org.apache.abdera.model.Feed;
import org.apache.abdera.parser.Parser;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.methods.DeleteMethod;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.PutMethod;
-import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.client.methods.HttpRequestBase;
+import org.apache.http.entity.StringEntity;
import org.apache.tuscany.sca.binding.atom.collection.NotFoundException;
import org.apache.tuscany.sca.data.collection.Entry;
import org.apache.tuscany.sca.interfacedef.Operation;
@@ -49,7 +53,7 @@ import org.oasisopen.sca.ServiceRuntimeException;
* @version $Rev$ $Date$
*/
class AtomBindingInvoker implements Invoker {
-
+
private static final Factory abderaFactory = Abdera.getNewFactory();
private static final Parser abderaParser = Abdera.getNewParser();
@@ -58,15 +62,19 @@ class AtomBindingInvoker implements Invoker {
HttpClient httpClient;
String authorizationHeader;
AtomReferenceBindingProvider provider;
-
- AtomBindingInvoker(Operation operation, String uri, HttpClient httpClient, String authorizationHeader, AtomReferenceBindingProvider bindingProvider) {
+
+ AtomBindingInvoker(Operation operation,
+ String uri,
+ org.apache.http.client.HttpClient httpClient,
+ String authorizationHeader,
+ AtomReferenceBindingProvider bindingProvider) {
this.operation = operation;
this.uri = uri;
this.httpClient = httpClient;
this.authorizationHeader = authorizationHeader;
this.provider = bindingProvider;
}
-
+
public Message invoke(Message msg) {
// Shouldn't get here, as the only supported methods are
// defined in the ResourceCollection interface, and implemented
@@ -79,7 +87,11 @@ class AtomBindingInvoker implements Invoker {
*/
public static class GetInvoker extends AtomBindingInvoker {
- public GetInvoker(Operation operation, String uri, HttpClient httpClient, String authorizationHeader, AtomReferenceBindingProvider bindingProvider) {
+ public GetInvoker(Operation operation,
+ String uri,
+ org.apache.http.client.HttpClient httpClient,
+ String authorizationHeader,
+ AtomReferenceBindingProvider bindingProvider) {
super(operation, uri, httpClient, authorizationHeader, bindingProvider);
}
@@ -89,40 +101,43 @@ class AtomBindingInvoker implements Invoker {
String id = (String)((Object[])msg.getBody())[0];
// Send an HTTP GET
- GetMethod getMethod = new GetMethod(uri + "/" + id);
+ HttpGet getMethod = new HttpGet(uri + "/" + id);
if (authorizationHeader != null) {
- getMethod.setRequestHeader("Authorization", authorizationHeader);
+ getMethod.setHeader("Authorization", authorizationHeader);
}
boolean parsing = false;
+ HttpResponse response = null;
try {
- httpClient.executeMethod(getMethod);
- int status = getMethod.getStatusCode();
+ response = httpClient.execute(getMethod);
+ int status = response.getStatusLine().getStatusCode();
// Read the Atom entry
if (status == 200) {
- Document<org.apache.abdera.model.Entry> doc =
- abderaParser.parse(getMethod.getResponseBodyAsStream());
+ Document<org.apache.abdera.model.Entry> doc = abderaParser.parse(response.getEntity().getContent());
parsing = true;
org.apache.abdera.model.Entry feedEntry = doc.getRoot();
-
+
if (provider.supportsFeedEntries()) {
-
+
// Return the Atom entry
msg.setBody(feedEntry);
-
+
} else {
-
+
// Convert the feed entry to a data entry and return the data item
- Entry<Object, Object> entry = entry(feedEntry, provider.getItemClassType(),
- provider.getItemXMLType(), provider.getMediator());
+ Entry<Object, Object> entry =
+ entry(feedEntry,
+ provider.getItemClassType(),
+ provider.getItemXMLType(),
+ provider.getMediator());
msg.setBody(entry.getData());
}
} else if (status == 404) {
- if ( provider.supportsFeedEntries())
- msg.setFaultBody(new NotFoundException());
- else
- msg.setFaultBody(new org.apache.tuscany.sca.data.collection.NotFoundException());
+ if (provider.supportsFeedEntries())
+ msg.setFaultBody(new NotFoundException());
+ else
+ msg.setFaultBody(new org.apache.tuscany.sca.data.collection.NotFoundException());
} else {
msg.setFaultBody(new ServiceRuntimeException("HTTP status code: " + status));
}
@@ -133,7 +148,7 @@ class AtomBindingInvoker implements Invoker {
if (!parsing) {
// Release the connection unless the Abdera parser is
// parsing the response, in this case it will release it
- getMethod.releaseConnection();
+ release(getMethod, response);
}
}
@@ -146,7 +161,11 @@ class AtomBindingInvoker implements Invoker {
*/
public static class PostInvoker extends AtomBindingInvoker {
- public PostInvoker(Operation operation, String uri, HttpClient httpClient, String authorizationHeader, AtomReferenceBindingProvider bindingProvider) {
+ public PostInvoker(Operation operation,
+ String uri,
+ HttpClient httpClient,
+ String authorizationHeader,
+ AtomReferenceBindingProvider bindingProvider) {
super(operation, uri, httpClient, authorizationHeader, bindingProvider);
}
@@ -156,58 +175,64 @@ class AtomBindingInvoker implements Invoker {
Object[] args = (Object[])msg.getBody();
org.apache.abdera.model.Entry feedEntry;
if (provider.supportsFeedEntries()) {
-
+
// Expect an Atom entry
feedEntry = (org.apache.abdera.model.Entry)args[0];
} else {
-
+
// Expect a key and data item
Entry<Object, Object> entry = new Entry<Object, Object>(args[0], args[1]);
- feedEntry = feedEntry(entry, provider.getItemClassType(),
- provider.getItemXMLType(), provider.getMediator(), abderaFactory);
+ feedEntry =
+ feedEntry(entry,
+ provider.getItemClassType(),
+ provider.getItemXMLType(),
+ provider.getMediator(),
+ abderaFactory);
}
// Send an HTTP POST
- PostMethod postMethod = new PostMethod(uri);
+ HttpPost postMethod = new HttpPost(uri);
if (authorizationHeader != null) {
- postMethod.setRequestHeader("Authorization", authorizationHeader);
+ postMethod.setHeader("Authorization", authorizationHeader);
}
boolean parsing = false;
+ HttpResponse response = null;
try {
// Write the Atom entry
StringWriter writer = new StringWriter();
feedEntry.writeTo(writer);
- // postMethod.setRequestHeader("Content-type", "application/atom+xml; charset=utf-8");
- postMethod.setRequestHeader("Content-type", "application/atom+xml;type=entry");
- postMethod.setRequestEntity(new StringRequestEntity(writer.toString()));
+ // postMethod.setHeader("Content-type", "application/atom+xml; charset=utf-8");
+ postMethod.setHeader("Content-type", "application/atom+xml;type=entry");
+ postMethod.setEntity(new StringEntity(writer.toString()));
- httpClient.executeMethod(postMethod);
- int status = postMethod.getStatusCode();
+ response = httpClient.execute(postMethod);
+ int status = response.getStatusLine().getStatusCode();
// Read the Atom entry
if (status == 200 || status == 201) {
- Document<org.apache.abdera.model.Entry> doc = abderaParser.parse(postMethod.getResponseBodyAsStream());
+ Document<org.apache.abdera.model.Entry> doc =
+ abderaParser.parse(postMethod.getEntity().getContent());
parsing = true;
org.apache.abdera.model.Entry createdEntry = doc.getRoot();
// Returns the created Atom entry ID
if (provider.supportsFeedEntries()) {
-
+
// Returns the created entry
msg.setBody(createdEntry);
-
+
} else {
-
+
// Returns the id of the created entry
msg.setBody(createdEntry.getId().toString());
}
} else if (status == 404) {
- if ( provider.supportsFeedEntries())
- msg.setFaultBody(new NotFoundException());
- else
- msg.setFaultBody(new org.apache.tuscany.sca.data.collection.NotFoundException());
+ if (provider.supportsFeedEntries())
+ msg.setFaultBody(new NotFoundException());
+ else
+ msg.setFaultBody(new org.apache.tuscany.sca.data.collection.NotFoundException());
} else {
msg.setFaultBody(new ServiceRuntimeException("HTTP status code: " + status));
}
@@ -218,7 +243,7 @@ class AtomBindingInvoker implements Invoker {
if (!parsing) {
// Release the connection unless the Abdera parser is
// parsing the response, in this case it will release it
- postMethod.releaseConnection();
+ release(postMethod, response);
}
}
@@ -231,7 +256,11 @@ class AtomBindingInvoker implements Invoker {
*/
public static class PutInvoker extends AtomBindingInvoker {
- public PutInvoker(Operation operation, String uri, HttpClient httpClient, String authorizationHeader, AtomReferenceBindingProvider bindingProvider) {
+ public PutInvoker(Operation operation,
+ String uri,
+ HttpClient httpClient,
+ String authorizationHeader,
+ AtomReferenceBindingProvider bindingProvider) {
super(operation, uri, httpClient, authorizationHeader, bindingProvider);
}
@@ -242,44 +271,49 @@ class AtomBindingInvoker implements Invoker {
String id;
org.apache.abdera.model.Entry feedEntry;
if (provider.supportsFeedEntries()) {
-
+
// Expect a key and Atom entry
id = (String)args[0];
feedEntry = (org.apache.abdera.model.Entry)args[1];
} else {
-
+
// Expect a key and data item
id = (String)args[0];
Entry<Object, Object> entry = new Entry<Object, Object>(id, args[1]);
- feedEntry = feedEntry(entry, provider.getItemClassType(),
- provider.getItemXMLType(), provider.getMediator(), abderaFactory);
+ feedEntry =
+ feedEntry(entry,
+ provider.getItemClassType(),
+ provider.getItemXMLType(),
+ provider.getMediator(),
+ abderaFactory);
}
// Send an HTTP PUT
- PutMethod putMethod = new PutMethod(uri + "/" + id);
+ HttpPut putMethod = new HttpPut(uri + "/" + id);
if (authorizationHeader != null) {
- putMethod.setRequestHeader("Authorization", authorizationHeader);
+ putMethod.setHeader("Authorization", authorizationHeader);
}
+ HttpResponse response = null;
try {
// Write the Atom entry
StringWriter writer = new StringWriter();
feedEntry.writeTo(writer);
- putMethod.setRequestHeader("Content-type", "application/atom+xml; charset=utf-8");
- putMethod.setRequestEntity(new StringRequestEntity(writer.toString()));
+ putMethod.setHeader("Content-type", "application/atom+xml; charset=utf-8");
+ putMethod.setEntity(new StringEntity(writer.toString()));
- httpClient.executeMethod(putMethod);
- int status = putMethod.getStatusCode();
+ response = httpClient.execute(putMethod);
+ int status = response.getStatusLine().getStatusCode();
if (status == 200 || status == 201 || status == 412) {
msg.setBody(null);
} else if (status == 404) {
- if ( provider.supportsFeedEntries())
- msg.setFaultBody(new NotFoundException());
- else
- msg.setFaultBody(new org.apache.tuscany.sca.data.collection.NotFoundException());
+ if (provider.supportsFeedEntries())
+ msg.setFaultBody(new NotFoundException());
+ else
+ msg.setFaultBody(new org.apache.tuscany.sca.data.collection.NotFoundException());
} else {
msg.setFaultBody(new ServiceRuntimeException("HTTP status code: " + status));
}
@@ -287,7 +321,7 @@ class AtomBindingInvoker implements Invoker {
} catch (Exception e) {
msg.setFaultBody(new ServiceRuntimeException(e));
} finally {
- putMethod.releaseConnection();
+ release(putMethod, response);
}
return msg;
@@ -299,7 +333,11 @@ class AtomBindingInvoker implements Invoker {
*/
public static class DeleteInvoker extends AtomBindingInvoker {
- public DeleteInvoker(Operation operation, String uri, HttpClient httpClient, String authorizationHeader, AtomReferenceBindingProvider bindingProvider) {
+ public DeleteInvoker(Operation operation,
+ String uri,
+ HttpClient httpClient,
+ String authorizationHeader,
+ AtomReferenceBindingProvider bindingProvider) {
super(operation, uri, httpClient, authorizationHeader, bindingProvider);
}
@@ -309,21 +347,22 @@ class AtomBindingInvoker implements Invoker {
String id = (String)((Object[])msg.getBody())[0];
// Send an HTTP DELETE
- DeleteMethod deleteMethod = new DeleteMethod(uri + "/" + id);
+ HttpDelete deleteMethod = new HttpDelete(uri + "/" + id);
if (authorizationHeader != null) {
- deleteMethod.setRequestHeader("Authorization", authorizationHeader);
+ deleteMethod.setHeader("Authorization", authorizationHeader);
}
+ HttpResponse response = null;
try {
- httpClient.executeMethod(deleteMethod);
- int status = deleteMethod.getStatusCode();
+ response = httpClient.execute(deleteMethod);
+ int status = response.getStatusLine().getStatusCode();
if (status == 200) {
msg.setBody(null);
} else if (status == 404) {
- if ( provider.supportsFeedEntries())
- msg.setFaultBody(new NotFoundException());
- else
- msg.setFaultBody(new org.apache.tuscany.sca.data.collection.NotFoundException());
+ if (provider.supportsFeedEntries())
+ msg.setFaultBody(new NotFoundException());
+ else
+ msg.setFaultBody(new org.apache.tuscany.sca.data.collection.NotFoundException());
} else {
msg.setFaultBody(new ServiceRuntimeException("HTTP status code: " + status));
}
@@ -331,7 +370,7 @@ class AtomBindingInvoker implements Invoker {
} catch (Exception e) {
msg.setFaultBody(new ServiceRuntimeException(e));
} finally {
- deleteMethod.releaseConnection();
+ release(deleteMethod, response);
}
return msg;
@@ -343,7 +382,11 @@ class AtomBindingInvoker implements Invoker {
*/
public static class GetAllInvoker extends AtomBindingInvoker {
- public GetAllInvoker(Operation operation, String uri, HttpClient httpClient, String authorizationHeader, AtomReferenceBindingProvider bindingProvider) {
+ public GetAllInvoker(Operation operation,
+ String uri,
+ HttpClient httpClient,
+ String authorizationHeader,
+ AtomReferenceBindingProvider bindingProvider) {
super(operation, uri, httpClient, authorizationHeader, bindingProvider);
}
@@ -352,51 +395,55 @@ class AtomBindingInvoker implements Invoker {
// Get a feed
// Send an HTTP GET
- GetMethod getMethod = new GetMethod(uri);
+ HttpGet getMethod = new HttpGet(uri);
if (authorizationHeader != null) {
- getMethod.setRequestHeader("Authorization", authorizationHeader);
+ getMethod.setHeader("Authorization", authorizationHeader);
}
boolean parsing = false;
+ HttpResponse response = null;
try {
- httpClient.executeMethod(getMethod);
- int status = getMethod.getStatusCode();
+ response = httpClient.execute(getMethod);
+ int status = response.getStatusLine().getStatusCode();
// AtomBindingInvoker.printResponseHeader( getMethod );
// Read the Atom feed
if (status == 200) {
- Document<Feed> doc = abderaParser.parse(getMethod.getResponseBodyAsStream());
+ Document<Feed> doc = abderaParser.parse(response.getEntity().getContent());
parsing = true;
-
+
Feed feed = null;
try {
- feed = doc.getRoot();
- } catch(Exception e) {
+ feed = doc.getRoot();
+ } catch (Exception e) {
throw new IllegalArgumentException("Invalid feed format :" + uri);
}
if (provider.supportsFeedEntries()) {
-
+
// Returns the Atom feed
msg.setBody(feed);
-
+
} else {
-
+
// Returns an array of data entries
- List<Entry<Object, Object>> entries = new ArrayList<Entry<Object,Object>>();
- for (org.apache.abdera.model.Entry feedEntry: feed.getEntries()) {
- Entry<Object, Object> entry = entry(feedEntry, provider.getItemClassType(),
- provider.getItemXMLType(), provider.getMediator());
+ List<Entry<Object, Object>> entries = new ArrayList<Entry<Object, Object>>();
+ for (org.apache.abdera.model.Entry feedEntry : feed.getEntries()) {
+ Entry<Object, Object> entry =
+ entry(feedEntry,
+ provider.getItemClassType(),
+ provider.getItemXMLType(),
+ provider.getMediator());
entries.add(entry);
}
msg.setBody(entries.toArray(new Entry[entries.size()]));
}
} else if (status == 404) {
- if ( provider.supportsFeedEntries()) {
- msg.setFaultBody(new NotFoundException());
- } else {
- msg.setFaultBody(new org.apache.tuscany.sca.data.collection.NotFoundException());
- }
+ if (provider.supportsFeedEntries()) {
+ msg.setFaultBody(new NotFoundException());
+ } else {
+ msg.setFaultBody(new org.apache.tuscany.sca.data.collection.NotFoundException());
+ }
} else {
msg.setFaultBody(new ServiceRuntimeException("HTTP status code: " + status));
}
@@ -407,7 +454,7 @@ class AtomBindingInvoker implements Invoker {
if (!parsing) {
// Release the connection unless the Abdera parser is
// parsing the response, in this case it will release it
- getMethod.releaseConnection();
+ release(getMethod, response);
}
}
@@ -420,7 +467,11 @@ class AtomBindingInvoker implements Invoker {
*/
public static class QueryInvoker extends AtomBindingInvoker {
- public QueryInvoker(Operation operation, String uri, HttpClient httpClient, String authorizationHeader, AtomReferenceBindingProvider bindingProvider) {
+ public QueryInvoker(Operation operation,
+ String uri,
+ HttpClient httpClient,
+ String authorizationHeader,
+ AtomReferenceBindingProvider bindingProvider) {
super(operation, uri, httpClient, authorizationHeader, bindingProvider);
}
@@ -430,44 +481,48 @@ class AtomBindingInvoker implements Invoker {
String queryString = (String)((Object[])msg.getBody())[0];
// Send an HTTP GET
- GetMethod getMethod = new GetMethod(uri);
+ HttpGet getMethod = new HttpGet(uri + "?" + queryString);
if (authorizationHeader != null) {
- getMethod.setRequestHeader("Authorization", authorizationHeader);
+ getMethod.setHeader("Authorization", authorizationHeader);
}
- getMethod.setQueryString(queryString);
+ // getMethod.setQueryString(queryString);
boolean parsing = false;
+ HttpResponse response = null;
try {
- httpClient.executeMethod(getMethod);
- int status = getMethod.getStatusCode();
+ response = httpClient.execute(getMethod);
+ int status = response.getStatusLine().getStatusCode();
// Read the Atom feed
if (status == 200) {
- Document<Feed> doc = abderaParser.parse(getMethod.getResponseBodyAsStream());
+ Document<Feed> doc = abderaParser.parse(response.getEntity().getContent());
parsing = true;
Feed feed = doc.getRoot();
if (provider.supportsFeedEntries()) {
-
+
// Returns the Atom feed
msg.setBody(feed);
-
+
} else {
-
+
// Returns an array of data entries
- List<Entry<Object, Object>> entries = new ArrayList<Entry<Object,Object>>();
- for (org.apache.abdera.model.Entry feedEntry: feed.getEntries()) {
- Entry<Object, Object> entry = entry(feedEntry, provider.getItemClassType(),
- provider.getItemXMLType(), provider.getMediator());
+ List<Entry<Object, Object>> entries = new ArrayList<Entry<Object, Object>>();
+ for (org.apache.abdera.model.Entry feedEntry : feed.getEntries()) {
+ Entry<Object, Object> entry =
+ entry(feedEntry,
+ provider.getItemClassType(),
+ provider.getItemXMLType(),
+ provider.getMediator());
entries.add(entry);
}
msg.setBody(entries.toArray(new Entry[entries.size()]));
}
} else if (status == 404) {
- if ( provider.supportsFeedEntries())
- msg.setFaultBody(new NotFoundException());
- else
- msg.setFaultBody(new org.apache.tuscany.sca.data.collection.NotFoundException());
+ if (provider.supportsFeedEntries())
+ msg.setFaultBody(new NotFoundException());
+ else
+ msg.setFaultBody(new org.apache.tuscany.sca.data.collection.NotFoundException());
} else {
msg.setFaultBody(new ServiceRuntimeException("HTTP status code: " + status));
}
@@ -478,7 +533,7 @@ class AtomBindingInvoker implements Invoker {
if (!parsing) {
// Release the connection unless the Abdera parser is
// parsing the response, in this case it will release it
- getMethod.releaseConnection();
+ release(getMethod, response);
}
}
@@ -486,18 +541,38 @@ class AtomBindingInvoker implements Invoker {
}
}
+ private static void release(HttpRequestBase request, HttpResponse response) {
+
+ if (response != null) {
+ HttpEntity entity = response.getEntity();
+ if (entity != null) {
+ try {
+ entity.consumeContent();
+ } catch (IOException e) {
+ if (request != null) {
+ request.abort();
+ }
+ }
+ }
+ }
+ }
+
/**
* PostMedia operation invoker
*/
public static class PostMediaInvoker extends AtomBindingInvoker {
- public PostMediaInvoker(Operation operation, String uri, HttpClient httpClient, String authorizationHeader, AtomReferenceBindingProvider bindingProvider) {
+ public PostMediaInvoker(Operation operation,
+ String uri,
+ HttpClient httpClient,
+ String authorizationHeader,
+ AtomReferenceBindingProvider bindingProvider) {
super(operation, uri, httpClient, authorizationHeader, bindingProvider);
}
@Override
public Message invoke(Message msg) {
- // PostInvoker can detect media by content type (non-Feed, non-Entry)
+ // PostInvoker can detect media by content type (non-Feed, non-Entry)
return super.invoke(msg);
}
}
@@ -507,13 +582,17 @@ class AtomBindingInvoker implements Invoker {
*/
public static class PutMediaInvoker extends AtomBindingInvoker {
- public PutMediaInvoker(Operation operation, String uri, HttpClient httpClient, String authorizationHeader, AtomReferenceBindingProvider bindingProvider) {
+ public PutMediaInvoker(Operation operation,
+ String uri,
+ HttpClient httpClient,
+ String authorizationHeader,
+ AtomReferenceBindingProvider bindingProvider) {
super(operation, uri, httpClient, authorizationHeader, bindingProvider);
}
@Override
public Message invoke(Message msg) {
- // PutInvoker can detect media by content type (non-Feed, non-Entry)
+ // PutInvoker can detect media by content type (non-Feed, non-Entry)
return super.invoke(msg);
}
}
diff --git a/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingListenerServlet.java b/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingListenerServlet.java
index 6dc9524f92..d5ae26e01b 100644
--- a/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingListenerServlet.java
+++ b/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingListenerServlet.java
@@ -145,13 +145,13 @@ class AtomBindingListenerServlet extends HttpServlet {
// Determine the collection item type
if (getOperation != null) {
itemXMLType = new DataTypeImpl<Class<?>>(String.class.getName(), String.class, String.class);
- Class<?> itemClass = getOperation.getOutputType().getPhysical();
+ Class<?> itemClass = getOperation.getOutputType().getLogical().get(0).getPhysical();
if (itemClass == org.apache.abdera.model.Entry.class) {
supportsFeedEntries = true;
}
//We assume that the item type is the same for both input and
//ouput for all operations on the interface
- itemClassType = ((List<DataType>)getOperation.getOutputType().getLogical()).get(0);
+ itemClassType = getOperation.getOutputType().getLogical().get(0);
}
}
diff --git a/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingUtil.java b/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingUtil.java
index fad06a0c99..ad1c8d2fd0 100644
--- a/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingUtil.java
+++ b/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingUtil.java
@@ -23,8 +23,8 @@ import java.util.Date;
import org.apache.abdera.factory.Factory;
import org.apache.abdera.model.Content;
-import org.apache.abdera.model.Link;
import org.apache.abdera.model.Content.Type;
+import org.apache.abdera.model.Link;
import org.apache.tuscany.sca.data.collection.Entry;
import org.apache.tuscany.sca.data.collection.Item;
import org.apache.tuscany.sca.databinding.Mediator;
@@ -78,9 +78,11 @@ class AtomBindingUtil {
}
// Create the item from XML
+ /*
if (feedEntry.getContentElement().getElements().size() == 0) {
return null;
}
+ */
String value = feedEntry.getContent();
Object data = mediator.mediate(value, itemXMLType, itemClassType, null);
diff --git a/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomReferenceBindingProvider.java b/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomReferenceBindingProvider.java
index 2801690f41..3612442e90 100644
--- a/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomReferenceBindingProvider.java
+++ b/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomReferenceBindingProvider.java
@@ -19,17 +19,10 @@
package org.apache.tuscany.sca.binding.atom.provider;
-import java.net.URI;
-
-import org.apache.commons.codec.binary.Base64;
-import org.apache.commons.httpclient.Credentials;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpConnectionManager;
-import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
-import org.apache.commons.httpclient.UsernamePasswordCredentials;
-import org.apache.commons.httpclient.auth.AuthScope;
+import org.apache.http.client.HttpClient;
import org.apache.tuscany.sca.assembly.EndpointReference;
import org.apache.tuscany.sca.binding.atom.AtomBinding;
+import org.apache.tuscany.sca.common.http.client.HttpClientFactory;
import org.apache.tuscany.sca.databinding.Mediator;
import org.apache.tuscany.sca.interfacedef.DataType;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
@@ -77,10 +70,8 @@ class AtomReferenceBindingProvider implements ReferenceBindingProvider {
//authorizationHeader = "Basic " + new String(Base64.encodeBase64(authorization.getBytes()));
// Create an HTTP client
- HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
- connectionManager.getParams().setDefaultMaxConnectionsPerHost(10);
- connectionManager.getParams().setConnectionTimeout(60000);
- httpClient = new HttpClient(connectionManager);
+ HttpClientFactory clientFactory = new HttpClientFactory();
+ httpClient = clientFactory.createHttpClient();
}
public Invoker createInvoker(Operation operation) {
@@ -90,7 +81,6 @@ class AtomReferenceBindingProvider implements ReferenceBindingProvider {
// Determine the collection item type
itemXMLType = new DataTypeImpl<Class<?>>(String.class.getName(), String.class, String.class);
- Class<?> itemClass = operation.getOutputType().getPhysical();
DataType<XMLType> outputType = operation.getOutputType().getLogical().get(0);
itemClassType = outputType;
if (itemClassType.getPhysical() == org.apache.abdera.model.Entry.class) {
diff --git a/sca-java-2.x/trunk/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/MediaCollectionTestCase.java b/sca-java-2.x/trunk/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/MediaCollectionTestCase.java
index 6d4a173d30..57eacab0e2 100644
--- a/sca-java-2.x/trunk/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/MediaCollectionTestCase.java
+++ b/sca-java-2.x/trunk/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/MediaCollectionTestCase.java
@@ -19,7 +19,6 @@
package org.apache.tuscany.sca.binding.atom;
import java.io.File;
-import java.io.FileInputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -32,11 +31,13 @@ import org.apache.abdera.model.Entry;
import org.apache.abdera.model.Link;
import org.apache.abdera.parser.Parser;
import org.apache.abdera.protocol.client.AbderaClient;
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.PutMethod;
+import org.apache.http.Header;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.entity.FileEntity;
+import org.apache.tuscany.sca.common.http.client.HttpClientFactory;
import org.apache.tuscany.sca.node.Contribution;
import org.apache.tuscany.sca.node.ContributionLocationHelper;
import org.apache.tuscany.sca.node.Node;
@@ -62,11 +63,11 @@ public class MediaCollectionTestCase {
protected static CustomerClient testService;
protected static Abdera abdera;
protected static AbderaClient client;
- protected static Parser abderaParser;
+ protected static Parser abderaParser;
protected static String eTag;
protected static Date lastModified;
protected static String mediaId;
- protected static final SimpleDateFormat dateFormat = new SimpleDateFormat( "EEE, dd MMM yyyy HH:mm:ss Z" ); // RFC 822 date time
+ protected static final SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z"); // RFC 822 date time
@BeforeClass
public static void init() throws Exception {
@@ -74,13 +75,15 @@ public class MediaCollectionTestCase {
//System.out.println(">>>MediaCollectionTestCase.init");
String contribution = ContributionLocationHelper.getContributionLocation(MediaCollectionTestCase.class);
- scaProviderNode = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/atom/ReceiptProvider.composite", new Contribution("provider", contribution));
+ scaProviderNode =
+ NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/atom/ReceiptProvider.composite",
+ new Contribution("provider", contribution));
scaProviderNode.start();
abdera = new Abdera();
client = new AbderaClient(abdera);
abderaParser = Abdera.getNewParser();
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
@@ -96,7 +99,7 @@ public class MediaCollectionTestCase {
@Test
public void testPrelim() throws Exception {
Assert.assertNotNull(scaProviderNode);
- Assert.assertNotNull( client );
+ Assert.assertNotNull(client);
}
@Test
@@ -113,23 +116,25 @@ public class MediaCollectionTestCase {
// Testing of entry creation
String receiptName = "Auto Repair Bill";
String fileName = "target/test-classes/ReceiptToms.gif";
- File input = new File( fileName );
+ File input = new File(fileName);
boolean exists = input.exists();
- Assert.assertTrue( exists );
+ Assert.assertTrue(exists);
// Prepare HTTP post
// PostMethod post = new PostMethod( colUri.toString() );
- PostMethod post = new PostMethod( providerURI );
- post.addRequestHeader( "Content-Type", "image/gif" );
- post.addRequestHeader( "Title", "Title " + receiptName + "" );
- post.addRequestHeader( "Slug", "Slug " + receiptName + "" );
- post.setRequestEntity( new InputStreamRequestEntity( new FileInputStream( input ), "image/gif" ) );
+ HttpPost post = new HttpPost(providerURI);
+ post.addHeader("Content-Type", "image/gif");
+ post.addHeader("Title", "Title " + receiptName + "");
+ post.addHeader("Slug", "Slug " + receiptName + "");
+
+ post.setEntity(new FileEntity(input, "image/gif"));
// Get HTTP client
- HttpClient httpclient = new HttpClient();
+ org.apache.http.client.HttpClient httpclient = new HttpClientFactory().createHttpClient();
try {
// Execute request
- int result = httpclient.executeMethod(post);
+ HttpResponse response = httpclient.execute(post);
+ int result = response.getStatusLine().getStatusCode();
// Pseudo Code (see APP (http://tools.ietf.org/html/rfc5023#section-9.6)
// Post response
// Tuscany responds with proper media links. Note that the media is
@@ -138,31 +143,31 @@ public class MediaCollectionTestCase {
// HTTP/1.1 201 Created
// Display status code
// System.out.println("Response status code: " + result + ", status text=" + post.getStatusText() );
- Assert.assertEquals(201, result );
+ Assert.assertEquals(201, result);
// Display response
// System.out.println("Response body: ");
// System.out.println(post.getResponseBodyAsString()); // Warning: BodyAsString recommends BodyAsStream
// Location: http://example.org/media/edit/the_beach.atom (REQUIRED)
- // System.out.println( "Response Location=" + post.getResponseHeader( "Location" ).getValue() + "." );
- Header header = post.getResponseHeader( "Location" );
- Assert.assertNotNull( header );
- Assert.assertNotNull( header.getValue() );
+ // System.out.println( "Response Location=" + response.getFirstHeader( "Location" ).getValue() + "." );
+ Header header = response.getFirstHeader("Location");
+ Assert.assertNotNull(header);
+ Assert.assertNotNull(header.getValue());
// ContentLocation: http://example.org/media/edit/the_beach.jpg (REQUIRED)
- // System.out.println( "Response Content-Location=" + post.getResponseHeader( "Content-Location" ).getValue() );
- header = post.getResponseHeader( "Content-Location" );
- Assert.assertNotNull( header );
- Assert.assertNotNull( header.getValue() );
+ // System.out.println( "Response Content-Location=" + response.getFirstHeader( "Content-Location" ).getValue() );
+ header = response.getFirstHeader("Content-Location");
+ Assert.assertNotNull(header);
+ Assert.assertNotNull(header.getValue());
// Content-Type: application/atom+xml;type=entry;charset="utf-8"
- // System.out.println( "Response Content-Type=" + post.getResponseHeader( "Content-Type" ).getValue());
- header = post.getResponseHeader( "Content-Type" );
- Assert.assertNotNull( header );
- Assert.assertNotNull( header.getValue() );
+ // System.out.println( "Response Content-Type=" + response.getFirstHeader( "Content-Type" ).getValue());
+ header = response.getFirstHeader("Content-Type");
+ Assert.assertNotNull(header);
+ Assert.assertNotNull(header.getValue());
// Content-Length: nnn (OPTIONAL)
- // System.out.println( "Response Content-Length=" + post.getResponseHeader( "Content-Length" ).getValue() );
- header = post.getResponseHeader( "Content-Length" );
- Assert.assertNotNull( header );
- Assert.assertNotNull( header.getValue() );
+ // System.out.println( "Response Content-Length=" + response.getFirstHeader( "Content-Length" ).getValue() );
+ header = response.getFirstHeader("Content-Length");
+ Assert.assertNotNull(header);
+ Assert.assertNotNull(header.getValue());
// <?xml version="1.0"?>
// <entry xmlns="http://www.w3.org/2005/Atom">
// <title>The Beach</title> (REQUIRED)
@@ -174,39 +179,39 @@ public class MediaCollectionTestCase {
// <link rel="edit-media" href="http://media.example.org/edit/the_beach.png" />
// <link rel="edit" href="http://example.org/media/edit/the_beach.atom" />
// </entry>
- Document<Entry> document = abderaParser.parse( post.getResponseBodyAsStream() );
+ Document<Entry> document = abderaParser.parse(response.getEntity().getContent());
Entry entry = document.getRoot();
String title = entry.getTitle();
// System.out.println( "mediaPost entry.title=" + title );
- Assert.assertNotNull( title );
+ Assert.assertNotNull(title);
IRI id = entry.getId();
// System.out.println( "mediaPost entry.id=" + id );
- Assert.assertNotNull( id );
+ Assert.assertNotNull(id);
mediaId = id.toString();
- Assert.assertNotNull( mediaId ); // Save for put/update request
+ Assert.assertNotNull(mediaId); // Save for put/update request
Date updated = entry.getUpdated();
// System.out.println( "mediaPost entry.updated=" + updated);
- Assert.assertNotNull( updated );
+ Assert.assertNotNull(updated);
String summary = entry.getSummary();
// System.out.println( "mediaPost entry.summary=" + summary);
- Assert.assertNotNull( summary );
+ Assert.assertNotNull(summary);
IRI contentSrc = entry.getContentSrc();
// System.out.println( "mediaPost entry.content.src=" + contentSrc + ", type=" + entry.getContentType());
- Assert.assertNotNull( contentSrc );
+ Assert.assertNotNull(contentSrc);
Link editLink = entry.getEditLink();
// System.out.println( "mediaPost entry.editLink" + " rel=" + editLink.getRel() + ", href=" + editLink.getHref() );
- Assert.assertNotNull( editLink );
- Assert.assertNotNull( editLink.getRel() );
- Assert.assertNotNull( editLink.getHref() );
+ Assert.assertNotNull(editLink);
+ Assert.assertNotNull(editLink.getRel());
+ Assert.assertNotNull(editLink.getHref());
Link editMediaLink = entry.getEditMediaLink();
// System.out.println( "mediaPost entry.editMediaLink" + " rel=" + editMediaLink.getRel() + ", href=" + editMediaLink.getHref() );
- Assert.assertNotNull( editMediaLink );
- Assert.assertNotNull( editMediaLink.getRel() );
- Assert.assertNotNull( editMediaLink.getHref() );
+ Assert.assertNotNull(editMediaLink);
+ Assert.assertNotNull(editMediaLink.getRel());
+ Assert.assertNotNull(editMediaLink.getHref());
} finally {
// Release current connection to the connection pool once you are done
- post.releaseConnection();
+ // post.releaseConnection();
}
}
@@ -216,9 +221,9 @@ public class MediaCollectionTestCase {
// Testing of entry update
String receiptName = "Value Autoglass Bill";
String fileName = "target/test-classes/ReceiptValue.jpg";
- File input = new File( fileName );
+ File input = new File(fileName);
boolean exists = input.exists();
- Assert.assertTrue( exists );
+ Assert.assertTrue(exists);
// Prepare HTTP put request
// PUT /edit/the_beach.png HTTP/1.1
@@ -226,28 +231,29 @@ public class MediaCollectionTestCase {
// Content-Type: image/png
// Content-Length: nnn
// ...binary data...
- PutMethod put = new PutMethod( providerURI + "/" + mediaId );
- put.addRequestHeader( "Content-Type", "image/jpg" );
- put.addRequestHeader( "Title", "Title " + receiptName + "" );
- put.addRequestHeader( "Slug", "Slug " + receiptName + "" );
- put.setRequestEntity(
- new InputStreamRequestEntity( new FileInputStream( input ), "image/jpg" ) );
+ HttpPut put = new HttpPut(providerURI + "/" + mediaId);
+ put.addHeader("Content-Type", "image/jpg");
+ put.addHeader("Title", "Title " + receiptName + "");
+ put.addHeader("Slug", "Slug " + receiptName + "");
+ put.setEntity(new FileEntity(input, "image/jpg"));
// Get HTTP client
- HttpClient httpclient = new HttpClient();
+ HttpClient httpclient = new HttpClientFactory().createHttpClient();
try {
// Execute request
- int result = httpclient.executeMethod(put);
+ HttpResponse response = httpclient.execute(put);
+ response.getEntity().consumeContent();
+ int result = response.getStatusLine().getStatusCode();
// Pseudo Code (see APP (http://tools.ietf.org/html/rfc5023#section-9.6)
// Display status code
// System.out.println("Response status code: " + result + ", status text=" + put.getStatusText() );
- Assert.assertEquals(200, result );
+ Assert.assertEquals(200, result);
// Display response. Should be empty for put.
// System.out.println("Response body: ");
// System.out.println(put.getResponseBodyAsString()); // Warning: BodyAsString recommends BodyAsStream
} finally {
// Release current connection to the connection pool once you are done
- put.releaseConnection();
+ // put.releaseConnection();
}
}
@@ -257,9 +263,9 @@ public class MediaCollectionTestCase {
// Testing of entry update
String receiptName = "Value Autoglass Bill";
String fileName = "target/test-classes/ReceiptValue.jpg";
- File input = new File( fileName );
+ File input = new File(fileName);
boolean exists = input.exists();
- Assert.assertTrue( exists );
+ Assert.assertTrue(exists);
// Prepare HTTP put request
// PUT /edit/the_beach.png HTTP/1.1
@@ -267,28 +273,28 @@ public class MediaCollectionTestCase {
// Content-Type: image/png
// Content-Length: nnn
// ...binary data...
- PutMethod put = new PutMethod( providerURI + "/" + mediaId + "-bogus" ); // Does not exist.
- put.addRequestHeader( "Content-Type", "image/jpg" );
- put.addRequestHeader( "Title", "Title " + receiptName + "" );
- put.addRequestHeader( "Slug", "Slug " + receiptName + "" );
- put.setRequestEntity(
- new InputStreamRequestEntity( new FileInputStream( input ), "image/jpg" ) );
+ HttpPut put = new HttpPut(providerURI + "/" + mediaId + "-bogus"); // Does not exist.
+ put.addHeader("Content-Type", "image/jpg");
+ put.addHeader("Title", "Title " + receiptName + "");
+ put.addHeader("Slug", "Slug " + receiptName + "");
+ put.setEntity(new FileEntity(input, "image/jpg"));
// Get HTTP client
- HttpClient httpclient = new HttpClient();
+ HttpClient httpclient = new HttpClientFactory().createHttpClient();
try {
// Execute request
- int result = httpclient.executeMethod(put);
+ HttpResponse response = httpclient.execute(put);
+ int result = response.getStatusLine().getStatusCode();
// Pseudo Code (see APP (http://tools.ietf.org/html/rfc5023#section-9.6)
// Display status code
// System.out.println("Response status code: " + result + ", status text=" + put.getStatusText() );
- Assert.assertEquals(404, result );
+ Assert.assertEquals(404, result);
// Display response. Should be empty for put.
// System.out.println("Response body: ");
// System.out.println(put.getResponseBodyAsString()); // Warning: BodyAsString recommends BodyAsStream
} finally {
// Release current connection to the connection pool once you are done
- put.releaseConnection();
+ // put.releaseConnection();
}
}
}
diff --git a/sca-java-2.x/trunk/modules/binding-jsonp-runtime/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/binding-jsonp-runtime/META-INF/MANIFEST.MF
index 9c5633ae1b..f5ab3c2d9d 100644
--- a/sca-java-2.x/trunk/modules/binding-jsonp-runtime/META-INF/MANIFEST.MF
+++ b/sca-java-2.x/trunk/modules/binding-jsonp-runtime/META-INF/MANIFEST.MF
@@ -10,12 +10,12 @@ Import-Package: javax.servlet;version="2.5.0",
javax.servlet.http;version="2.5.0",
org.apache.commons.codec,
org.apache.commons.codec.net,
- org.apache.http;version="4.0.1",
- org.apache.http.client;version="4.0.0",
- org.apache.http.client.methods;version="4.0.0",
- org.apache.http.client.utils;version="4.0.0",
- org.apache.http.conn;version="4.0.0",
- org.apache.http.impl.client;version="4.0.0",
+ org.apache.http,
+ org.apache.http.client,
+ org.apache.http.client.methods,
+ org.apache.http.client.utils,
+ org.apache.http.conn,
+ org.apache.http.impl.client,
org.apache.tuscany.sca.assembly;version="2.0.0",
org.apache.tuscany.sca.binding.jsonp;version="2.0.0",
org.apache.tuscany.sca.core;version="2.0.0",
diff --git a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/pom.xml b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/pom.xml
index ecb0db3320..00c0e0d37b 100644
--- a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/pom.xml
+++ b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/pom.xml
@@ -69,7 +69,7 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
- <version>4.0</version>
+ <version>4.0.3</version>
</dependency>
<dependency>
diff --git a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/META-INF/MANIFEST.MF
index 2ad383d9f7..a2c1fe03ea 100644
--- a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/META-INF/MANIFEST.MF
+++ b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/META-INF/MANIFEST.MF
@@ -87,6 +87,7 @@ Import-Package: javax.activation;resolution:=optional,
org.apache.axiom.om,
org.apache.axiom.om.impl.builder,
org.apache.axiom.om.util,
+ org.apache.axiom.util.base64,
org.apache.axiom.soap,
org.apache.axis2,
org.apache.axis2.addressing,
diff --git a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/pom.xml b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/pom.xml
index d09fa8a124..25bbea3a77 100644
--- a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/pom.xml
+++ b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/pom.xml
@@ -51,7 +51,7 @@
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-kernel</artifactId>
- <version>1.5.1</version>
+ <version>1.5.3</version>
<exclusions>
<exclusion>
<groupId>xerces</groupId>
@@ -75,7 +75,7 @@
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-java2wsdl</artifactId>
- <version>1.5.1</version>
+ <version>1.5.3</version>
<exclusions>
<exclusion>
<groupId>org.apache.ant</groupId>
@@ -95,7 +95,7 @@
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-codegen</artifactId>
- <version>1.5.1</version>
+ <version>1.5.3</version>
<scope>runtime</scope>
<exclusions>
<exclusion>
@@ -112,26 +112,26 @@
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-mtompolicy</artifactId>
- <version>1.5.1</version>
+ <version>1.5.3</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>mex</artifactId>
- <version>1.5.1</version>
+ <version>1.5.3</version>
<classifier>impl</classifier>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-http</artifactId>
- <version>1.5.1</version>
+ <version>1.5.3</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-local</artifactId>
- <version>1.5.1</version>
+ <version>1.5.3</version>
</dependency>
<dependency>
@@ -143,19 +143,19 @@
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-api</artifactId>
- <version>1.2.8</version>
+ <version>1.2.10</version>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-impl</artifactId>
- <version>1.2.8</version>
+ <version>1.2.10</version>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-dom</artifactId>
- <version>1.2.8</version>
+ <version>1.2.10</version>
</dependency>
<dependency>
@@ -179,13 +179,13 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
- <version>4.0.1</version>
+ <version>4.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore-nio</artifactId>
- <version>4.0.1</version>
+ <version>4.1</version>
</dependency>
<dependency>
diff --git a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationServicePolicyInterceptor.java b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationServicePolicyInterceptor.java
index 3d73410ae9..5365754fb3 100644
--- a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationServicePolicyInterceptor.java
+++ b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationServicePolicyInterceptor.java
@@ -24,8 +24,8 @@ import java.util.Map;
import javax.security.auth.Subject;
import javax.xml.namespace.QName;
+import org.apache.axiom.util.base64.Base64Utils;
import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.util.Base64;
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.Message;
import org.apache.tuscany.sca.invocation.Phase;
@@ -86,7 +86,7 @@ public class BasicAuthenticationServicePolicyInterceptor implements PhasedInterc
basicAuthString = basicAuthString.trim();
if (basicAuthString.startsWith("Basic ")) {
- decodedBasicAuthString = new String(Base64.decode(basicAuthString.substring(6)));
+ decodedBasicAuthString = new String(Base64Utils.decode(basicAuthString.substring(6)));
}
int collonIndex = decodedBasicAuthString.indexOf(':');
diff --git a/sca-java-2.x/trunk/modules/common-http/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/common-http/META-INF/MANIFEST.MF
index 942e695a71..ccb1db35c5 100644
--- a/sca-java-2.x/trunk/modules/common-http/META-INF/MANIFEST.MF
+++ b/sca-java-2.x/trunk/modules/common-http/META-INF/MANIFEST.MF
@@ -8,7 +8,18 @@ Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
Bundle-Description: Apache Tuscany SCA Common HTTP
Bundle-SymbolicName: org.apache.tuscany.sca.common.http
Bundle-DocURL: http://www.apache.org/
-Export-Package: org.apache.tuscany.sca.common.http;version="2.0.0"
-Import-Package: javax.servlet.http
+Export-Package: org.apache.tuscany.sca.common.http;version="2.0.0";uses:="javax.servlet.http",
+ org.apache.tuscany.sca.common.http.client;version="2.0.0";uses:="org.apache.http.client"
+Import-Package: javax.servlet.http,
+ org.apache.http,
+ org.apache.http.client,
+ org.apache.http.conn,
+ org.apache.http.conn.scheme,
+ org.apache.http.conn.ssl,
+ org.apache.http.impl.client,
+ org.apache.http.impl.conn.tsccm,
+ org.apache.http.params,
+ org.apache.http.protocol
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sca-java-2.x/trunk/modules/common-http/pom.xml b/sca-java-2.x/trunk/modules/common-http/pom.xml
index 2fa94a708c..4cdd7fc98d 100644
--- a/sca-java-2.x/trunk/modules/common-http/pom.xml
+++ b/sca-java-2.x/trunk/modules/common-http/pom.xml
@@ -35,6 +35,12 @@
<version>2.5</version> <!-- to keep compatible with older servlet containers -->
<scope>provided</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.0.3</version>
+ </dependency>
<dependency>
<groupId>junit</groupId>
diff --git a/sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/client/HttpClientFactory.java b/sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/client/HttpClientFactory.java
new file mode 100644
index 0000000000..225bc952fb
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/client/HttpClientFactory.java
@@ -0,0 +1,58 @@
+/*
+ * 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.tuscany.sca.common.http.client;
+
+import org.apache.http.HttpHost;
+import org.apache.http.client.HttpClient;
+import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.conn.scheme.PlainSocketFactory;
+import org.apache.http.conn.scheme.Scheme;
+import org.apache.http.conn.scheme.SchemeRegistry;
+import org.apache.http.conn.ssl.SSLSocketFactory;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
+import org.apache.http.params.BasicHttpParams;
+import org.apache.http.params.HttpConnectionParams;
+import org.apache.http.params.HttpParams;
+import org.apache.http.params.HttpProtocolParams;
+import org.apache.http.protocol.HTTP;
+
+/**
+ *
+ */
+public class HttpClientFactory {
+
+ public HttpClient createHttpClient() {
+ HttpParams defaultParameters = new BasicHttpParams();
+ //defaultParameters.setIntParameter(HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS, 10);
+ HttpProtocolParams.setContentCharset(defaultParameters, HTTP.UTF_8);
+ HttpConnectionParams.setConnectionTimeout(defaultParameters, 60000);
+ HttpConnectionParams.setSoTimeout(defaultParameters, 60000);
+
+ SchemeRegistry supportedSchemes = new SchemeRegistry();
+ supportedSchemes.register(new Scheme(HttpHost.DEFAULT_SCHEME_NAME, PlainSocketFactory.getSocketFactory(), 80));
+ supportedSchemes.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
+
+ ClientConnectionManager connectionManager =
+ new ThreadSafeClientConnManager(defaultParameters, supportedSchemes);
+
+ return new DefaultHttpClient(connectionManager, defaultParameters);
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/databinding-axiom/pom.xml b/sca-java-2.x/trunk/modules/databinding-axiom/pom.xml
index b2e08bb1b8..c783cdc7ab 100644
--- a/sca-java-2.x/trunk/modules/databinding-axiom/pom.xml
+++ b/sca-java-2.x/trunk/modules/databinding-axiom/pom.xml
@@ -40,7 +40,7 @@
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-api</artifactId>
- <version>1.2.8</version>
+ <version>1.2.10</version>
<exclusions>
<exclusion>
<groupId>xerces</groupId>
@@ -60,7 +60,7 @@
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-impl</artifactId>
- <version>1.2.8</version>
+ <version>1.2.10</version>
<scope>runtime</scope>
<exclusions>
<exclusion>
diff --git a/sca-java-2.x/trunk/modules/databinding-jaxb-axiom/pom.xml b/sca-java-2.x/trunk/modules/databinding-jaxb-axiom/pom.xml
index 23a5ef1ee3..7f74a09a9c 100644
--- a/sca-java-2.x/trunk/modules/databinding-jaxb-axiom/pom.xml
+++ b/sca-java-2.x/trunk/modules/databinding-jaxb-axiom/pom.xml
@@ -40,7 +40,7 @@
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-api</artifactId>
- <version>1.2.8</version>
+ <version>1.2.10</version>
<exclusions>
<exclusion>
<groupId>xerces</groupId>
@@ -64,7 +64,7 @@
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-impl</artifactId>
- <version>1.2.8</version>
+ <version>1.2.10</version>
<scope>runtime</scope>
</dependency>
</dependencies>
diff --git a/sca-java-2.x/trunk/modules/databinding-sdo-axiom/pom.xml b/sca-java-2.x/trunk/modules/databinding-sdo-axiom/pom.xml
index b438818c9d..c142b24500 100644
--- a/sca-java-2.x/trunk/modules/databinding-sdo-axiom/pom.xml
+++ b/sca-java-2.x/trunk/modules/databinding-sdo-axiom/pom.xml
@@ -38,7 +38,7 @@
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-api</artifactId>
- <version>1.2.8</version>
+ <version>1.2.10</version>
<exclusions>
<exclusion>
<groupId>xerces</groupId>
@@ -62,7 +62,7 @@
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-impl</artifactId>
- <version>1.2.8</version>
+ <version>1.2.10</version>
<scope>runtime</scope>
</dependency>
diff --git a/sca-java-2.x/trunk/modules/implementation-python-runtime/pom.xml b/sca-java-2.x/trunk/modules/implementation-python-runtime/pom.xml
index c8ca9106de..448166350c 100644
--- a/sca-java-2.x/trunk/modules/implementation-python-runtime/pom.xml
+++ b/sca-java-2.x/trunk/modules/implementation-python-runtime/pom.xml
@@ -53,7 +53,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.5</version>
+ <version>4.8.1</version>
<scope>test</scope>
</dependency>
diff --git a/sca-java-2.x/trunk/modules/implementation-script-runtime/pom.xml b/sca-java-2.x/trunk/modules/implementation-script-runtime/pom.xml
index 1fda2ec5c2..7e039ff372 100644
--- a/sca-java-2.x/trunk/modules/implementation-script-runtime/pom.xml
+++ b/sca-java-2.x/trunk/modules/implementation-script-runtime/pom.xml
@@ -122,20 +122,20 @@
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
- <version>1.2.8</version>
+ <version>1.2.10</version>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-impl</artifactId>
- <version>1.2.8</version>
+ <version>1.2.10</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.5</version>
+ <version>4.8.1</version>
<scope>test</scope>
</dependency>
diff --git a/sca-java-2.x/trunk/modules/implementation-script/pom.xml b/sca-java-2.x/trunk/modules/implementation-script/pom.xml
index 0aad4c121d..f6b295814e 100644
--- a/sca-java-2.x/trunk/modules/implementation-script/pom.xml
+++ b/sca-java-2.x/trunk/modules/implementation-script/pom.xml
@@ -40,7 +40,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.5</version>
+ <version>4.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/sca-java-2.x/trunk/modules/policy-wspolicy/pom.xml b/sca-java-2.x/trunk/modules/policy-wspolicy/pom.xml
index 7729af9556..71cafc147c 100644
--- a/sca-java-2.x/trunk/modules/policy-wspolicy/pom.xml
+++ b/sca-java-2.x/trunk/modules/policy-wspolicy/pom.xml
@@ -58,7 +58,7 @@
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-api</artifactId>
- <version>1.2.8</version>
+ <version>1.2.10</version>
<exclusions>
<exclusion>
<groupId>xerces</groupId>
@@ -98,7 +98,7 @@
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-impl</artifactId>
- <version>1.2.8</version>
+ <version>1.2.10</version>
<scope>runtime</scope>
<exclusions>
<exclusion>