This is an automated email from the ASF dual-hosted git repository. billblough pushed a commit to branch AXIS2-4318 in repository https://gitbox.apache.org/repos/asf/axis-axis2-java-core.git
commit 9b7b802eb304069e26c288636398166f131d32ff Author: Sagara Gunathunga <sag...@apache.org> AuthorDate: Tue Apr 24 07:06:32 2012 +0000 AXIS2-4318 - Applied patch AXIS2-4318_02.patch. --- modules/parent/pom.xml | 6 +++ modules/transport/http/pom.xml | 8 ++++ .../httpclient4/HTTPClient4TransportSender.java | 55 ++++++++++++++++++++++ .../httpclient4/HttpTransportPropertiesImpl.java | 3 -- .../http/HTTPClient4TransportSenderTest.java | 47 ++++++++++++++++++ 5 files changed, 116 insertions(+), 3 deletions(-) diff --git a/modules/parent/pom.xml b/modules/parent/pom.xml index c523281..d49913c 100644 --- a/modules/parent/pom.xml +++ b/modules/parent/pom.xml @@ -90,6 +90,7 @@ <geronimo.spec.saaj.version>1.0.1</geronimo.spec.saaj.version> <geronimo.spec.jaxws.version>1.0</geronimo.spec.jaxws.version> <httpcore.version>4.0</httpcore.version> + <httpclient.version>4.0</httpclient.version> <intellij.version>5.0</intellij.version> <jalopy.version>1.5rc3</jalopy.version> <jaxb.api.version>2.2.4</jaxb.api.version> @@ -724,6 +725,11 @@ <version>${httpcore.version}</version> </dependency> <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + <version>${httpclient.version}</version> + </dependency> + <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>${commons.fileupload.version}</version> diff --git a/modules/transport/http/pom.xml b/modules/transport/http/pom.xml index 6d1cfde..1c8971f 100644 --- a/modules/transport/http/pom.xml +++ b/modules/transport/http/pom.xml @@ -106,8 +106,16 @@ <artifactId>httpcore</artifactId> </dependency> <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + </dependency> + <dependency> <groupId>commons-httpclient</groupId> <artifactId>commons-httpclient</artifactId> </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + </dependency> </dependencies> </project> diff --git a/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPClient4TransportSender.java b/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPClient4TransportSender.java new file mode 100644 index 0000000..c394437 --- /dev/null +++ b/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPClient4TransportSender.java @@ -0,0 +1,55 @@ +/* + * 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.axis2.transport.http.impl.httpclient4; + +import org.apache.axis2.AxisFault; +import org.apache.axis2.context.ConfigurationContext; +import org.apache.axis2.context.MessageContext; +import org.apache.axis2.transport.http.CommonsHTTPTransportSender; +import org.apache.axis2.transport.http.HTTPConstants; +import org.apache.axis2.transport.http.HTTPTransportConstants; +import org.apache.axis2.transport.http.HTTPTransportSender; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + + +public class HTTPClient4TransportSender extends CommonsHTTPTransportSender implements + HTTPTransportSender { + + private static final Log log = LogFactory.getLog(HTTPClient4TransportSender.class); + + @Override + public void cleanup(MessageContext msgContext) throws AxisFault { + // We don't need to call cleanup here because httpclient4 releases + // the connection and cleanup automatically + // TODO : Don't do this if we're not on the right thread! Can we confirm? + log.trace("cleanup() releasing connection"); + // guard against multiple calls + msgContext.removeProperty(HTTPConstants.HTTP_METHOD); + + } + + public void setHTTPClientVersion(ConfigurationContext configurationContext) { + configurationContext.setProperty(HTTPTransportConstants.HTTP_CLIENT_VERSION, + HTTPTransportConstants.HTTP_CLIENT_4_X_VERSION); + } + + +} diff --git a/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HttpTransportPropertiesImpl.java b/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HttpTransportPropertiesImpl.java index dd34240..3b8fcf4 100644 --- a/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HttpTransportPropertiesImpl.java +++ b/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HttpTransportPropertiesImpl.java @@ -56,7 +56,6 @@ public class HttpTransportPropertiesImpl extends HttpTransportProperties { public static final String NTLM = AuthPolicy.NTLM; public static final String DIGEST = AuthPolicy.DIGEST; public static final String BASIC = AuthPolicy.BASIC; - public static final String SPNEGO = AuthPolicy.SPNEGO; public int getPort() { return port; @@ -82,8 +81,6 @@ public class HttpTransportPropertiesImpl extends HttpTransportProperties { return AuthPolicy.NTLM; } else if (DIGEST.equals(scheme)) { return AuthPolicy.DIGEST; - } else if (SPNEGO.equals(scheme)) { - return AuthPolicy.SPNEGO; } return null; } diff --git a/modules/transport/http/test/org/apache/axis2/transport/http/HTTPClient4TransportSenderTest.java b/modules/transport/http/test/org/apache/axis2/transport/http/HTTPClient4TransportSenderTest.java new file mode 100644 index 0000000..d3170e6 --- /dev/null +++ b/modules/transport/http/test/org/apache/axis2/transport/http/HTTPClient4TransportSenderTest.java @@ -0,0 +1,47 @@ +/* + * 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.axis2.transport.http; + +import org.apache.axis2.AxisFault; +import org.apache.axis2.context.MessageContext; +import org.apache.axis2.transport.TransportSender; +import org.apache.axis2.transport.http.impl.httpclient4.HTTPClient4TransportSender; +import org.apache.http.client.methods.HttpGet; + + +public class HTTPClient4TransportSenderTest extends CommonsHTTPTransportSenderTest{ + + @Override + protected TransportSender getTransportSender() { + return new HTTPClient4TransportSender(); + } + + @Override + public void testCleanup() throws AxisFault { + TransportSender sender = getTransportSender(); + MessageContext msgContext = new MessageContext(); + HttpGet httpMethod = new HttpGet(); + msgContext.setProperty(HTTPConstants.HTTP_METHOD, httpMethod); + assertNotNull("HttpMethod can not be null", + msgContext.getProperty(HTTPConstants.HTTP_METHOD)); + sender.cleanup(msgContext); + assertNull("HttpMethod should be null", msgContext.getProperty(HTTPConstants.HTTP_METHOD)); + } +}