You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by sa...@apache.org on 2011/10/18 15:34:08 UTC
svn commit: r1185647 - in /axis/axis2/java/core/trunk/modules:
kernel/src/org/apache/axis2/client/ kernel/src/org/apache/axis2/context/
transport/http/src/org/apache/axis2/transport/http/
transport/http/test/org/apache/axis2/transport/http/
Author: sagara
Date: Tue Oct 18 13:34:07 2011
New Revision: 1185647
URL: http://svn.apache.org/viewvc?rev=1185647&view=rev
Log:
AXIS2-3933 :
Removed direct reference to org.apache.commons.httpclient.Header in Stub class based on provided patches.
Added:
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/context/NamedValue.java (with props)
Modified:
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/client/Stub.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/AbstractHTTPSender.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderTest.java
Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/client/Stub.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/client/Stub.java?rev=1185647&r1=1185646&r2=1185647&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/client/Stub.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/client/Stub.java Tue Oct 18 13:34:07 2011
@@ -35,13 +35,13 @@ import org.apache.axiom.soap.SOAPProcess
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.NamedValue;
import org.apache.axis2.description.AxisService;
import org.apache.axis2.description.OutInAxisOperation;
import org.apache.axis2.description.OutOnlyAxisOperation;
import org.apache.axis2.description.RobustOutOnlyAxisOperation;
import org.apache.axis2.i18n.Messages;
import org.apache.axis2.transport.http.HTTPConstants;
-import org.apache.commons.httpclient.Header;
import java.util.ArrayList;
import java.util.Iterator;
@@ -160,10 +160,8 @@ public abstract class Stub {
headersObj = new java.util.ArrayList();
}
java.util.List headers = (java.util.List) headersObj;
- Header header = new Header();
- header.setName(name);
- header.setValue(value);
- headers.add(header);
+ NamedValue nameValue = new NamedValue(name , value);
+ headers.add(nameValue);
messageContext.setProperty(HTTPConstants.HTTP_HEADERS, headers);
}
Added: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/context/NamedValue.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/context/NamedValue.java?rev=1185647&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/context/NamedValue.java (added)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/context/NamedValue.java Tue Oct 18 13:34:07 2011
@@ -0,0 +1,54 @@
+/*
+ * 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.context;
+
+public class NamedValue {
+ private final String name;
+ private final String value;
+
+ public NamedValue(final String name ,final String value){
+ if(name==null){
+ throw new IllegalArgumentException("Name must not be null");
+ }else if(name.equals("")) {
+ throw new IllegalArgumentException("Name must not be empty");
+ }
+ this.name = name;
+ this.value = value;
+ }
+
+ /* get the name*/
+ public String getName() {
+ return name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("Name =");
+ sb.append(this.name);
+ sb.append(" Value =");
+ sb.append(this.value);
+ return sb.toString();
+ }
+}
Propchange: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/context/NamedValue.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/AbstractHTTPSender.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/AbstractHTTPSender.java?rev=1185647&r1=1185646&r2=1185647&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/AbstractHTTPSender.java (original)
+++ axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/AbstractHTTPSender.java Tue Oct 18 13:34:07 2011
@@ -25,6 +25,7 @@ import org.apache.axiom.om.OMOutputForma
import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.NamedValue;
import org.apache.axis2.context.OperationContext;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.description.TransportOutDescription;
@@ -627,15 +628,17 @@ public abstract class AbstractHTTPSender
// set the custom headers, if available
Object httpHeadersObj = msgContext.getProperty(HTTPConstants.HTTP_HEADERS);
if (httpHeadersObj != null) {
- if (httpHeadersObj instanceof ArrayList) {
- ArrayList httpHeaders = (ArrayList) httpHeadersObj;
- Header header;
+ if (httpHeadersObj instanceof List) {
+ List httpHeaders = (List) httpHeadersObj;
for (int i = 0; i < httpHeaders.size(); i++) {
- header = (Header) httpHeaders.get(i);
- if (HTTPConstants.HEADER_USER_AGENT.equals(header.getName())) {
- isCustomUserAgentSet = true;
+ NamedValue nv = (NamedValue) httpHeaders.get(i);
+ if (nv != null) {
+ Header header = new Header(nv.getName(), nv.getValue());
+ if (HTTPConstants.HEADER_USER_AGENT.equals(header.getName())) {
+ isCustomUserAgentSet = true;
+ }
+ method.addRequestHeader(header);
}
- method.addRequestHeader(header);
}
}
Modified: axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java?rev=1185647&r1=1185646&r2=1185647&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java (original)
+++ axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java Tue Oct 18 13:34:07 2011
@@ -25,6 +25,7 @@ import org.apache.axis2.Constants;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.NamedValue;
import org.apache.axis2.description.Parameter;
import org.apache.axis2.description.TransportOutDescription;
import org.apache.axis2.handlers.AbstractHandler;
@@ -34,7 +35,6 @@ import org.apache.axis2.transport.Transp
import org.apache.axis2.transport.TransportUtils;
import org.apache.axis2.transport.http.server.AxisHttpResponse;
import org.apache.axis2.util.JavaUtils;
-import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.logging.Log;
@@ -292,10 +292,10 @@ public class CommonsHTTPTransportSender
if (customHeaders instanceof List) {
Iterator iter = ((List) customHeaders).iterator();
while (iter.hasNext()) {
- Header header = (Header) iter.next();
- if (header != null) {
+ NamedValue nv = (NamedValue) iter.next();
+ if (nv != null) {
servletBasedOutTransportInfo
- .addHeader(header.getName(), header.getValue());
+ .addHeader(nv.getName(), nv.getValue());
}
}
} else if (customHeaders instanceof Map) {
@@ -315,10 +315,10 @@ public class CommonsHTTPTransportSender
if (customHeaders instanceof List) {
Iterator iter = ((List) customHeaders).iterator();
while (iter.hasNext()) {
- Header header = (Header) iter.next();
- if (header != null) {
+ NamedValue nv = (NamedValue) iter.next();
+ if (nv != null) {
((AxisHttpResponse) transportInfo)
- .addHeader(header.getName(), header.getValue());
+ .addHeader(nv.getName(), nv.getValue());
}
}
} else if (customHeaders instanceof Map) {
Modified: axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderTest.java?rev=1185647&r1=1185646&r2=1185647&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderTest.java (original)
+++ axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderTest.java Tue Oct 18 13:34:07 2011
@@ -39,6 +39,7 @@ import org.apache.axis2.Constants;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.NamedValue;
import org.apache.axis2.description.Parameter;
import org.apache.axis2.description.TransportOutDescription;
import org.apache.axis2.engine.Handler.InvocationResponse;
@@ -130,9 +131,9 @@ public class CommonsHTTPTransportSenderT
msgContext.setProperty(Constants.Configuration.TRANSPORT_URL, epr);
}
// set two Headers for testing
- List<Header> headerList = new ArrayList<Header>();
- Header header1 = new Header("Content-Type", "application/xml");
- Header header2 = new Header("Custom-header", "custom-value");
+ List<NamedValue> headerList = new ArrayList<NamedValue>();
+ NamedValue header1 = new NamedValue("Content-Type", "application/xml");
+ NamedValue header2 = new NamedValue("Custom-header", "custom-value");
headerList.add(header1);
headerList.add(header2);
msgContext.setProperty(HTTPConstants.HTTP_HEADERS, headerList);