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 ve...@apache.org on 2017/01/16 08:56:07 UTC
svn commit: r1778991 - in /axis/axis2/java/core/trunk/modules/transport:
http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/
http/src/org/apache/axis2/transport/http/
http/src/org/apache/axis2/transport/http/impl/httpclient4/
Author: veithen
Date: Mon Jan 16 08:56:06 2017
New Revision: 1778991
URL: http://svn.apache.org/viewvc?rev=1778991&view=rev
Log:
Implement the HTTPClient entities as adapters instead of subclasses of AxisRequestEntity. This will allow us to construct the AxisRequestEntity in the shared code.
Modified:
axis/axis2/java/core/trunk/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/AxisRequestEntityImpl.java
axis/axis2/java/core/trunk/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/PostRequest.java
axis/axis2/java/core/trunk/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/PutRequest.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/AxisRequestEntity.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/AxisRequestEntityImpl.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/PostRequest.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/PutRequest.java
Modified: axis/axis2/java/core/trunk/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/AxisRequestEntityImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/AxisRequestEntityImpl.java?rev=1778991&r1=1778990&r2=1778991&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/AxisRequestEntityImpl.java (original)
+++ axis/axis2/java/core/trunk/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/AxisRequestEntityImpl.java Mon Jan 16 08:56:06 2017
@@ -19,9 +19,9 @@
package org.apache.axis2.transport.http.impl.httpclient3;
-import org.apache.axiom.om.OMOutputFormat;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.transport.MessageFormatter;
+import java.io.IOException;
+import java.io.OutputStream;
+
import org.apache.axis2.transport.http.AxisRequestEntity;
import org.apache.commons.httpclient.methods.RequestEntity;
@@ -30,21 +30,30 @@ import org.apache.commons.httpclient.met
* This Request Entity is used by the HTTPCommonsTransportSender. This wraps the
* Axis2 message formatter object.
*/
-public class AxisRequestEntityImpl extends AxisRequestEntity implements RequestEntity {
+public class AxisRequestEntityImpl implements RequestEntity {
+ private final AxisRequestEntity entity;
+
+ public AxisRequestEntityImpl(AxisRequestEntity entity) {
+ this.entity = entity;
+ }
- /**
- * Method calls to this request entity are delegated to the following Axis2
- * message formatter object.
- *
- * @param messageFormatter
- */
- public AxisRequestEntityImpl(MessageFormatter messageFormatter, MessageContext msgContext,
- OMOutputFormat format, String soapAction, boolean chunked, boolean isAllowedRetry) {
- super(messageFormatter, msgContext, format, soapAction, chunked, isAllowedRetry);
+ @Override
+ public boolean isRepeatable() {
+ return entity.isRepeatable();
}
- public String getContentType() {
- return getContentTypeAsString();
+ @Override
+ public void writeRequest(OutputStream outStream) throws IOException {
+ entity.writeRequest(outStream);
}
+ @Override
+ public long getContentLength() {
+ return entity.getContentLength();
+ }
+
+ @Override
+ public String getContentType() {
+ return entity.getContentTypeAsString();
+ }
}
Modified: axis/axis2/java/core/trunk/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/PostRequest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/PostRequest.java?rev=1778991&r1=1778990&r2=1778991&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/PostRequest.java (original)
+++ axis/axis2/java/core/trunk/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/PostRequest.java Mon Jan 16 08:56:06 2017
@@ -23,6 +23,7 @@ import java.net.URL;
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.transport.http.AxisRequestEntity;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.logging.Log;
@@ -41,8 +42,8 @@ class PostRequest extends RequestBase<Po
log.trace(Thread.currentThread() + " PostMethod " + method + " / " + httpClient);
}
- method.setRequestEntity(new AxisRequestEntityImpl(messageFormatter, msgContext, sender.getFormat(),
- soapActionString, sender.isChunked(), sender.isAllowedRetry()));
+ method.setRequestEntity(new AxisRequestEntityImpl(new AxisRequestEntity(messageFormatter, msgContext, sender.getFormat(),
+ soapActionString, sender.isChunked(), sender.isAllowedRetry())));
if (!sender.getHttpVersion().equals(HTTPConstants.HEADER_PROTOCOL_10) && sender.isChunked()) {
method.setContentChunked(true);
Modified: axis/axis2/java/core/trunk/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/PutRequest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/PutRequest.java?rev=1778991&r1=1778990&r2=1778991&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/PutRequest.java (original)
+++ axis/axis2/java/core/trunk/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/PutRequest.java Mon Jan 16 08:56:06 2017
@@ -23,6 +23,7 @@ import java.net.URL;
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.transport.http.AxisRequestEntity;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.commons.httpclient.methods.PutMethod;
import org.apache.commons.logging.Log;
@@ -37,8 +38,8 @@ class PutRequest extends RequestBase<Put
@Override
public void execute() throws AxisFault {
- method.setRequestEntity(new AxisRequestEntityImpl(messageFormatter, msgContext, sender.getFormat(),
- soapActionString, sender.isChunked(), sender.isAllowedRetry()));
+ method.setRequestEntity(new AxisRequestEntityImpl(new AxisRequestEntity(messageFormatter, msgContext, sender.getFormat(),
+ soapActionString, sender.isChunked(), sender.isAllowedRetry())));
if (!sender.getHttpVersion().equals(HTTPConstants.HEADER_PROTOCOL_10) && sender.isChunked()) {
method.setContentChunked(true);
Modified: axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/AxisRequestEntity.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/AxisRequestEntity.java?rev=1778991&r1=1778990&r2=1778991&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/AxisRequestEntity.java (original)
+++ axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/AxisRequestEntity.java Mon Jan 16 08:56:06 2017
@@ -36,7 +36,7 @@ import java.util.zip.GZIPOutputStream;
* This Request Entity is used by the HTTPCommonsTransportSender. This wraps the
* Axis2 message formatter object.
*/
-public abstract class AxisRequestEntity {
+public final class AxisRequestEntity {
private MessageFormatter messageFormatter;
Modified: axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/AxisRequestEntityImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/AxisRequestEntityImpl.java?rev=1778991&r1=1778990&r2=1778991&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/AxisRequestEntityImpl.java (original)
+++ axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/AxisRequestEntityImpl.java Mon Jan 16 08:56:06 2017
@@ -19,9 +19,6 @@
package org.apache.axis2.transport.http.impl.httpclient4;
-import org.apache.axiom.om.OMOutputFormat;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.transport.MessageFormatter;
import org.apache.axis2.transport.http.AxisRequestEntity;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.http.Header;
@@ -36,46 +33,60 @@ import java.io.OutputStream;
* This Request Entity is used by the HttpComponentsTransportSender. This wraps the
* Axis2 message formatter object.
*/
-public class AxisRequestEntityImpl extends AxisRequestEntity implements HttpEntity {
+public class AxisRequestEntityImpl implements HttpEntity {
+ private final AxisRequestEntity entity;
- /**
- * Method calls to this request entity are delegated to the following Axis2
- * message formatter object.
- *
- * @param messageFormatter
- * @param msgContext
- * @param format
- * @param soapAction
- * @param chunked
- * @param isAllowedRetry
- */
- public AxisRequestEntityImpl(MessageFormatter messageFormatter, MessageContext msgContext,
- OMOutputFormat format, String soapAction, boolean chunked, boolean isAllowedRetry) {
- super(messageFormatter, msgContext, format, soapAction, chunked, isAllowedRetry);
+ public AxisRequestEntityImpl(AxisRequestEntity entity) {
+ this.entity = entity;
}
+ @Override
public Header getContentType() {
- return new BasicHeader(HTTPConstants.HEADER_CONTENT_TYPE, getContentTypeAsString());
+ return new BasicHeader(HTTPConstants.HEADER_CONTENT_TYPE, entity.getContentTypeAsString());
}
+ @Override
public Header getContentEncoding() {
return null;
}
+ @Override
public InputStream getContent() throws IOException {
- return getRequestEntityContent();
+ return entity.getRequestEntityContent();
}
+ @Override
public void writeTo(OutputStream outputStream) throws IOException {
- writeRequest(outputStream);
+ entity.writeRequest(outputStream);
}
+ @Override
public boolean isStreaming() {
return false;
}
+ @Override
public void consumeContent() {
// TODO: Handle this correctly
}
+ @Override
+ public long getContentLength() {
+ return entity.getContentLength();
+ }
+
+ @Override
+ public boolean isChunked() {
+ return entity.isChunked();
+ }
+
+ @Override
+ public boolean isRepeatable() {
+ return entity.isRepeatable();
+ }
+
+ // TODO: this should eventually disappear
+ public void setChunked(boolean chunked) {
+ entity.setChunked(chunked);
+ }
}
Modified: axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/PostRequest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/PostRequest.java?rev=1778991&r1=1778990&r2=1778991&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/PostRequest.java (original)
+++ axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/PostRequest.java Mon Jan 16 08:56:06 2017
@@ -23,6 +23,7 @@ import java.net.URL;
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.transport.http.AxisRequestEntity;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -42,8 +43,8 @@ class PostRequest extends RequestBase<Ht
log.trace(Thread.currentThread() + " PostMethod " + method + " / " + httpClient);
}
AxisRequestEntityImpl requestEntity =
- new AxisRequestEntityImpl(messageFormatter, msgContext, sender.getFormat(),
- soapActionString, sender.isChunked(), sender.isAllowedRetry());
+ new AxisRequestEntityImpl(new AxisRequestEntity(messageFormatter, msgContext, sender.getFormat(),
+ soapActionString, sender.isChunked(), sender.isAllowedRetry()));
method.setEntity(requestEntity);
if (!sender.getHttpVersion().equals(HTTPConstants.HEADER_PROTOCOL_10) && sender.isChunked()) {
Modified: axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/PutRequest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/PutRequest.java?rev=1778991&r1=1778990&r2=1778991&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/PutRequest.java (original)
+++ axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/PutRequest.java Mon Jan 16 08:56:06 2017
@@ -23,6 +23,7 @@ import java.net.URL;
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.transport.http.AxisRequestEntity;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -39,8 +40,8 @@ class PutRequest extends RequestBase<Htt
@Override
public void execute() throws AxisFault {
AxisRequestEntityImpl requestEntity =
- new AxisRequestEntityImpl(messageFormatter, msgContext, sender.getFormat(),
- soapActionString, sender.isChunked(), sender.isAllowedRetry());
+ new AxisRequestEntityImpl(new AxisRequestEntity(messageFormatter, msgContext, sender.getFormat(),
+ soapActionString, sender.isChunked(), sender.isAllowedRetry()));
method.setEntity(requestEntity);
if (!sender.getHttpVersion().equals(HTTPConstants.HEADER_PROTOCOL_10) && sender.isChunked()) {