diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2010-12-08 23:45:07 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2010-12-08 23:45:07 +0000 |
commit | 9f766005792dbd31f8c6d0306ddbbf5c68173104 (patch) | |
tree | 714e20e35653d89406a404f0af4590f1f9c1b2d7 /sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache | |
parent | da9db01ad297c43e4c2f05245bb9a3c712aaca29 (diff) |
Upgrade to Axis2 1.5.3, Axiom 1.2.10 and Abdera 1.1.1
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1043771 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache')
4 files changed, 208 insertions, 137 deletions
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) { |