You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by di...@apache.org on 2006/12/27 03:22:51 UTC
svn commit: r490429 - in
/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport:
AbstractTransportSender.java TransportUtils.java local/LocalResponder.java
local/LocalTransportSender.java tcp/TCPTransportSender.java
Author: dims
Date: Tue Dec 26 18:22:50 2006
New Revision: 490429
URL: http://svn.apache.org/viewvc?view=rev&rev=490429
Log:
remove AbstractTransportSender as it was outdated, the resulting code in the local/tcp stuff that did use that class is now much simpler to read/understand
Removed:
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/AbstractTransportSender.java
Modified:
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/local/LocalResponder.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/local/LocalTransportSender.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/tcp/TCPTransportSender.java
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java?view=diff&rev=490429&r1=490428&r2=490429
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java Tue Dec 26 18:22:50 2006
@@ -18,6 +18,7 @@
package org.apache.axis2.transport;
import java.io.InputStream;
+import java.io.OutputStream;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.stream.XMLStreamException;
@@ -25,6 +26,7 @@
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMException;
import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.om.OMOutputFormat;
import org.apache.axiom.om.impl.builder.StAXBuilder;
import org.apache.axiom.soap.SOAP11Constants;
import org.apache.axiom.soap.SOAP12Constants;
@@ -172,4 +174,34 @@
}
return envelope;
}
+
+
+ public static void writeMessage(MessageContext msgContext, OutputStream out) throws AxisFault {
+ SOAPEnvelope envelope = msgContext.getEnvelope();
+ OMElement outputMessage = envelope;
+
+ if ((envelope != null) && msgContext.isDoingREST()) {
+ outputMessage = envelope.getBody().getFirstElement();
+ }
+
+ if (outputMessage != null) {
+ try {
+ OMOutputFormat format = new OMOutputFormat();
+
+ // Pick the char set encoding from the msgContext
+ String charSetEnc =
+ (String) msgContext.getProperty(Constants.Configuration.CHARACTER_SET_ENCODING);
+
+ format.setDoOptimize(false);
+ format.setDoingSWA(false);
+ format.setCharSetEncoding(charSetEnc);
+ outputMessage.serializeAndConsume(out, format);
+ out.flush();
+ } catch (Exception e) {
+ throw new AxisFault(e);
+ }
+ } else {
+ throw new AxisFault(Messages.getMessage("outMessageNull"));
+ }
+ }
}
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/local/LocalResponder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/local/LocalResponder.java?view=diff&rev=490429&r1=490428&r2=490429
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/local/LocalResponder.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/local/LocalResponder.java Tue Dec 26 18:22:50 2006
@@ -18,59 +18,85 @@
package org.apache.axis2.transport.local;
import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.handlers.AbstractHandler;
+import org.apache.axis2.i18n.Messages;
+import org.apache.axis2.description.TransportOutDescription;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.transport.AbstractTransportSender;
+import org.apache.axis2.transport.TransportSender;
+import org.apache.axis2.transport.TransportUtils;
+import org.apache.axis2.transport.http.HTTPTransportUtils;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMOutputFormat;
import java.io.OutputStream;
/**
* LocalResponder
*/
-public class LocalResponder extends AbstractTransportSender {
-
- private static final long serialVersionUID = 4383137590664240383L;
+public class LocalResponder extends AbstractHandler implements TransportSender {
LocalTransportSender sender;
public LocalResponder(LocalTransportSender sender) {
this.sender = sender;
}
- /**
- * Clean up
- *
- * @param msgContext
- * @throws org.apache.axis2.AxisFault
- */
- public void cleanup(MessageContext msgContext) throws AxisFault {
- }
-
- public void finalizeSendWithOutputStreamFromIncomingConnection(MessageContext msgContext,
- OutputStream out)
+ public void init(ConfigurationContext confContext, TransportOutDescription transportOut)
throws AxisFault {
}
- public void finalizeSendWithToAddress(MessageContext msgContext, OutputStream out)
- throws AxisFault {
- }
-
- protected OutputStream openTheConnection(EndpointReference epr, MessageContext msgctx)
- throws AxisFault {
- return sender.getResponse();
+ public void stop() {
}
- public OutputStream startSendWithOutputStreamFromIncomingConnection(MessageContext msgContext,
- OutputStream out)
- throws AxisFault {
- return null;
+ public void cleanup(MessageContext msgContext) throws AxisFault {
}
- public OutputStream startSendWithToAddress(MessageContext msgContext, OutputStream out)
- throws AxisFault {
- return out;
- }
+ /**
+ * Method invoke
+ *
+ * @param msgContext
+ * @throws AxisFault
+ */
+ public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
- public void stop() {
- //To change body of implemented methods use File | Settings | File Templates.
+ // Check for the REST behaviour, if you desire rest beahaviour
+ // put a <parameter name="doREST" value="true"/> at the axis2.xml
+ msgContext.setDoingMTOM(HTTPTransportUtils.doWriteMTOM(msgContext));
+ msgContext.setDoingSwA(HTTPTransportUtils.doWriteSwA(msgContext));
+
+ OutputStream out;
+ EndpointReference epr = null;
+
+ if (msgContext.getTo() != null && !msgContext.getTo().hasAnonymousAddress()) {
+ epr = msgContext.getTo();
+ }
+
+ if (epr != null) {
+ if (!epr.hasNoneAddress()) {
+ out = sender.getResponse();
+ TransportUtils.writeMessage(msgContext, out);
+ }
+ } else {
+ out = (OutputStream) msgContext.getProperty(MessageContext.TRANSPORT_OUT);
+
+ if (out != null) {
+ TransportUtils.writeMessage(msgContext, out);
+ } else {
+ throw new AxisFault(
+ "Both the TO and Property MessageContext.TRANSPORT_OUT is Null, No where to send");
+ }
+ }
+
+ // TODO fix this, we do not set the value if the operation context is
+ // not available
+ if (msgContext.getOperationContext() != null) {
+ msgContext.getOperationContext().setProperty(Constants.RESPONSE_WRITTEN,
+ Constants.VALUE_TRUE);
+ }
+ return InvocationResponse.CONTINUE;
}
}
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/local/LocalTransportSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/local/LocalTransportSender.java?view=diff&rev=490429&r1=490428&r2=490429
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/local/LocalTransportSender.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/local/LocalTransportSender.java Tue Dec 26 18:22:50 2006
@@ -18,9 +18,20 @@
package org.apache.axis2.transport.local;
import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.handlers.AbstractHandler;
+import org.apache.axis2.i18n.Messages;
+import org.apache.axis2.description.TransportOutDescription;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.transport.AbstractTransportSender;
+import org.apache.axis2.transport.TransportSender;
+import org.apache.axis2.transport.TransportUtils;
+import org.apache.axis2.transport.http.HTTPTransportUtils;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMOutputFormat;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -28,33 +39,78 @@
import java.io.InputStream;
import java.io.OutputStream;
-public class LocalTransportSender extends AbstractTransportSender {
+public class LocalTransportSender extends AbstractHandler implements TransportSender {
- private static final long serialVersionUID = -5245866514826025561L;
private ByteArrayOutputStream out;
private ByteArrayOutputStream response;
- public LocalTransportSender() {
+ public void init(ConfigurationContext confContext, TransportOutDescription transportOut)
+ throws AxisFault {
+ }
+
+ public void stop() {
}
public void cleanup(MessageContext msgContext) throws AxisFault {
}
- public void finalizeSendWithOutputStreamFromIncomingConnection(MessageContext msgContext,
- OutputStream out)
- throws AxisFault {
- throw new UnsupportedOperationException();
+ protected OutputStream getResponse() {
+ return response;
+ }
+
+ /**
+ * Method invoke
+ *
+ * @param msgContext
+ * @throws AxisFault
+ */
+ public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
+
+ // Check for the REST behaviour, if you desire rest beahaviour
+ // put a <parameter name="doREST" value="true"/> at the axis2.xml
+ msgContext.setDoingMTOM(HTTPTransportUtils.doWriteMTOM(msgContext));
+ msgContext.setDoingSwA(HTTPTransportUtils.doWriteSwA(msgContext));
+
+ OutputStream out;
+ EndpointReference epr = null;
+
+ if (msgContext.getTo() != null && !msgContext.getTo().hasAnonymousAddress()) {
+ epr = msgContext.getTo();
+ }
+
+ if (epr != null) {
+ if (!epr.hasNoneAddress()) {
+ out = new ByteArrayOutputStream();
+ TransportUtils.writeMessage(msgContext, out);
+ finalizeSendWithToAddress(msgContext, out);
+ }
+ } else {
+ out = (OutputStream) msgContext.getProperty(MessageContext.TRANSPORT_OUT);
+
+ if (out != null) {
+ TransportUtils.writeMessage(msgContext, out);
+ } else {
+ throw new AxisFault(
+ "Both the TO and Property MessageContext.TRANSPORT_OUT is Null, No where to send");
+ }
+ }
+
+ // TODO fix this, we do not set the value if the operation context is
+ // not available
+ if (msgContext.getOperationContext() != null) {
+ msgContext.getOperationContext().setProperty(Constants.RESPONSE_WRITTEN,
+ Constants.VALUE_TRUE);
+ }
+ return InvocationResponse.CONTINUE;
}
public void finalizeSendWithToAddress(MessageContext msgContext, OutputStream out)
throws AxisFault {
try {
InputStream in = new ByteArrayInputStream(this.out.toByteArray());
-
response = new ByteArrayOutputStream();
LocalTransportReceiver localTransportReceiver = new LocalTransportReceiver(this);
-
localTransportReceiver.processMessage(in, msgContext.getTo());
in.close();
out.close();
@@ -63,40 +119,5 @@
} catch (IOException e) {
throw new AxisFault(e);
}
- }
-
- /*
- * (non-Javadoc)
- * @see org.apache.axis2.transport.AbstractTransportSender#openTheConnection(org.apache.axis2.addressing.EndpointReference)
- */
- protected OutputStream openTheConnection(EndpointReference epr, MessageContext msgContext)
- throws AxisFault {
-
- out = new ByteArrayOutputStream();
-
- return out;
- }
-
- /*
- * (non-Javadoc)
- * @see org.apache.axis2.transport.AbstractTransportSender#startSendWithOutputStreamFromIncomingConnection(org.apache.axis2.context.MessageContext, java.io.Writer)
- */
- public OutputStream startSendWithOutputStreamFromIncomingConnection(MessageContext msgContext,
- OutputStream out)
- throws AxisFault {
- throw new UnsupportedOperationException();
- }
-
- public OutputStream startSendWithToAddress(MessageContext msgContext, OutputStream out)
- throws AxisFault {
- return out;
- }
-
- OutputStream getResponse() {
- return response;
- }
-
- public void stop() {
-
}
}
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/tcp/TCPTransportSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/tcp/TCPTransportSender.java?view=diff&rev=490429&r1=490428&r2=490429
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/tcp/TCPTransportSender.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/tcp/TCPTransportSender.java Tue Dec 26 18:22:50 2006
@@ -18,11 +18,21 @@
package org.apache.axis2.transport.tcp;
import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.description.TransportOutDescription;
+import org.apache.axis2.handlers.AbstractHandler;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.i18n.Messages;
import org.apache.axis2.transport.AbstractTransportSender;
+import org.apache.axis2.transport.TransportSender;
+import org.apache.axis2.transport.TransportUtils;
+import org.apache.axis2.transport.http.HTTPTransportUtils;
import org.apache.axis2.util.URL;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMOutputFormat;
import java.io.IOException;
import java.io.OutputStream;
@@ -32,20 +42,17 @@
import java.net.Socket;
import java.net.SocketAddress;
-public class TCPTransportSender extends AbstractTransportSender {
-
- private static final long serialVersionUID = -6780125098288186598L;
-
- /**
- * Field out
- */
+public class TCPTransportSender extends AbstractHandler implements TransportSender {
protected Writer out;
-
- /**
- * Field socket
- */
private Socket socket;
+ public void init(ConfigurationContext confContext, TransportOutDescription transportOut)
+ throws AxisFault {
+ }
+
+ public void stop() {
+ }
+
public void cleanup(MessageContext msgContext) throws AxisFault {
try {
if (socket != null) {
@@ -56,18 +63,55 @@
}
}
- public void finalizeSendWithOutputStreamFromIncomingConnection(MessageContext msgContext,
- OutputStream out) {
- }
+ /**
+ * Method invoke
+ *
+ * @param msgContext
+ * @throws AxisFault
+ */
+ public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
- public void finalizeSendWithToAddress(MessageContext msgContext, OutputStream out)
- throws AxisFault {
- try {
- socket.shutdownOutput();
- msgContext.setProperty(MessageContext.TRANSPORT_IN, socket.getInputStream());
- } catch (IOException e) {
- throw new AxisFault(e);
+ // Check for the REST behaviour, if you desire rest beahaviour
+ // put a <parameter name="doREST" value="true"/> at the axis2.xml
+ msgContext.setDoingMTOM(HTTPTransportUtils.doWriteMTOM(msgContext));
+ msgContext.setDoingSwA(HTTPTransportUtils.doWriteSwA(msgContext));
+
+ OutputStream out;
+ EndpointReference epr = null;
+
+ if (msgContext.getTo() != null && !msgContext.getTo().hasAnonymousAddress()) {
+ epr = msgContext.getTo();
}
+
+ if (epr != null) {
+ if (!epr.hasNoneAddress()) {
+ out = openTheConnection(epr, msgContext);
+ TransportUtils.writeMessage(msgContext, out);
+ try {
+ socket.shutdownOutput();
+ msgContext.setProperty(MessageContext.TRANSPORT_IN, socket.getInputStream());
+ } catch (IOException e) {
+ throw new AxisFault(e);
+ }
+ }
+ } else {
+ out = (OutputStream) msgContext.getProperty(MessageContext.TRANSPORT_OUT);
+
+ if (out != null) {
+ TransportUtils.writeMessage(msgContext, out);
+ } else {
+ throw new AxisFault(
+ "Both the TO and Property MessageContext.TRANSPORT_OUT is Null, No where to send");
+ }
+ }
+
+ // TODO fix this, we do not set the value if the operation context is
+ // not available
+ if (msgContext.getOperationContext() != null) {
+ msgContext.getOperationContext().setProperty(Constants.RESPONSE_WRITTEN,
+ Constants.VALUE_TRUE);
+ }
+ return InvocationResponse.CONTINUE;
}
protected OutputStream openTheConnection(EndpointReference toURL, MessageContext msgContext)
@@ -91,31 +135,5 @@
} else {
throw new AxisFault(Messages.getMessage("canNotBeNull", "Can not Be Null"));
}
- }
-
- public OutputStream startSendWithOutputStreamFromIncomingConnection(MessageContext msgContext,
- OutputStream out)
- throws AxisFault {
- return out;
- }
-
- public OutputStream startSendWithToAddress(MessageContext msgContext, OutputStream out) {
- return out;
- }
-
- /**
- * Method writeTransportHeaders
- *
- * @param out
- * @param url
- * @param msgContext
- * @throws IOException
- */
- protected void writeTransportHeaders(Writer out, URL url, MessageContext msgContext,
- int contentLength)
- throws IOException {
- }
-
- public void stop() {
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org