You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@xml.apache.org by ne...@locus.apache.org on 2000/11/15 14:21:27 UTC
cvs commit: xml-soap/java/src/org/apache/soap/transport EnvelopeEditorAdapter.java EnvelopeEditorFactory.java EnvelopeEditor.java FilterTransport.java
neyama 00/11/15 05:21:27
Modified: java/src/org/apache/soap/transport
EnvelopeEditorAdapter.java
EnvelopeEditorFactory.java EnvelopeEditor.java
FilterTransport.java
Log:
Fix to follow the coding convention Sanjiva submitted.
Revision Changes Path
1.2 +40 -35 xml-soap/java/src/org/apache/soap/transport/EnvelopeEditorAdapter.java
Index: EnvelopeEditorAdapter.java
===================================================================
RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/transport/EnvelopeEditorAdapter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- EnvelopeEditorAdapter.java 2000/11/07 02:05:18 1.1
+++ EnvelopeEditorAdapter.java 2000/11/15 13:21:26 1.2
@@ -58,50 +58,55 @@
/*
* Begin Transport-Hook-Extension
*/
-package org.apache.soap.transport ;
+package org.apache.soap.transport;
-import java.io.Reader ;
-import java.io.Writer ;
-import java.io.IOException ;
-import org.apache.soap.SOAPException ;
-import org.apache.soap.Constants ;
+import java.io.Reader;
+import java.io.Writer;
+import java.io.IOException;
+import org.apache.soap.SOAPException;
+import org.apache.soap.Constants;
/**
* @author Ryo Neyama (neyama@jp.ibm.com)
*/
public class EnvelopeEditorAdapter implements EnvelopeEditor {
- private static final int BUF_SIZE = 4096 ;
- public void editIncoming(Reader in, Writer out) throws SOAPException {
- passThrough(in, out) ;
- }
+ private static final int BUF_SIZE = 4096;
- public void editOutgoing(Reader in, Writer out) throws SOAPException {
- passThrough(in, out) ;
- }
+ public void editIncoming(Reader in, Writer out) throws SOAPException {
+ passThrough(in, out);
+ }
+
+ public void editOutgoing(Reader in, Writer out) throws SOAPException {
+ passThrough(in, out);
+ }
- protected void passThrough(Reader in, Writer out) throws SOAPException {
- try {
- char[] data = new char[BUF_SIZE] ;
- int len ;
- READ_LOOP:
- while (true) {
- int off = 0;
- do {
- if ((len = in.read(data, off, data.length-off)) == -1) {
- out.write(data, 0, off) ;
- break READ_LOOP ;
- }
- } while ((off += len) < data.length) ;
- out.write(data) ;
- }
- } catch (IOException e) {
- throw new SOAPException(Constants.FAULT_CODE_SERVER, e.getMessage(), e) ;
- } finally {
- try { out.flush() ; } catch (IOException e) {
- throw new SOAPException(Constants.FAULT_CODE_SERVER, e.getMessage(), e) ;
- }
- }
+ protected void passThrough(Reader in, Writer out) throws SOAPException {
+ try {
+ char[] data = new char[BUF_SIZE];
+ int len;
+ READ_LOOP:
+ while (true) {
+ int off = 0;
+ do {
+ if ((len = in.read(data, off, data.length - off)) == -1) {
+ out.write(data, 0, off);
+ break READ_LOOP;
+ }
+ } while ((off += len) < data.length);
+ out.write(data);
+ }
+ } catch(IOException e) {
+ throw new SOAPException(Constants.FAULT_CODE_SERVER,
+ e.getMessage(), e);
+ } finally {
+ try {
+ out.flush();
+ } catch (IOException e) {
+ throw new SOAPException(Constants.FAULT_CODE_SERVER,
+ e.getMessage(), e);
+ }
}
+ }
}
/*
* End Transport-Hook-Extension
1.2 +4 -4 xml-soap/java/src/org/apache/soap/transport/EnvelopeEditorFactory.java
Index: EnvelopeEditorFactory.java
===================================================================
RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/transport/EnvelopeEditorFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- EnvelopeEditorFactory.java 2000/11/07 02:05:18 1.1
+++ EnvelopeEditorFactory.java 2000/11/15 13:21:26 1.2
@@ -58,16 +58,16 @@
/*
* Begin Transport-Hook-Extension
*/
-package org.apache.soap.transport ;
+package org.apache.soap.transport;
-import java.util.Properties ;
-import org.apache.soap.SOAPException ;
+import java.util.Properties;
+import org.apache.soap.SOAPException;
/**
* @author Ryo Neyama (neyama@jp.ibm.com)
*/
public interface EnvelopeEditorFactory {
- public EnvelopeEditor create(Properties props) throws SOAPException ;
+ public EnvelopeEditor create(Properties props) throws SOAPException;
}
/*
* End Transport-Hook-Extension
1.2 +8 -8 xml-soap/java/src/org/apache/soap/transport/EnvelopeEditor.java
Index: EnvelopeEditor.java
===================================================================
RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/transport/EnvelopeEditor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- EnvelopeEditor.java 2000/11/07 02:05:18 1.1
+++ EnvelopeEditor.java 2000/11/15 13:21:26 1.2
@@ -58,20 +58,20 @@
/*
* Begin Transport-Hook-Extension
*/
-package org.apache.soap.transport ;
+package org.apache.soap.transport;
-import java.io.Reader ;
-import java.io.Writer ;
-import org.apache.soap.SOAPException ;
+import java.io.Reader;
+import java.io.Writer;
+import org.apache.soap.SOAPException;
/**
* @author Ryo Neyama (neyama@jp.ibm.com)
*/
public interface EnvelopeEditor {
- // Callback mehtod to translate incoming messages
- public void editIncoming(Reader in, Writer out) throws SOAPException ;
- // Callback mehtod to translate outgoing messages
- public void editOutgoing(Reader in, Writer out) throws SOAPException ;
+ // Callback mehtod to translate incoming messages
+ public void editIncoming(Reader in, Writer out) throws SOAPException;
+ // Callback mehtod to translate outgoing messages
+ public void editOutgoing(Reader in, Writer out) throws SOAPException;
}
/*
* End Transport-Hook-Extension
1.2 +89 -84 xml-soap/java/src/org/apache/soap/transport/FilterTransport.java
Index: FilterTransport.java
===================================================================
RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/transport/FilterTransport.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FilterTransport.java 2000/11/07 02:05:18 1.1
+++ FilterTransport.java 2000/11/15 13:21:26 1.2
@@ -58,7 +58,7 @@
/*
* Begin Transport-Hook-Extension
*/
-package org.apache.soap.transport ;
+package org.apache.soap.transport;
import java.io.*;
import java.net.*;
@@ -74,95 +74,100 @@
* <code>SOAPHTTPConnection</code> is an implementation of the
* <code>SOAPTransport</code> interface for <em>HTTP</em>.
*
- * @author Matthew J. Duftler (duftler@us.ibm.com)
- * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
* @author Ryo Neyama (neyama@jp.ibm.com)
*/
-public class FilterTransport implements SOAPTransport
-{
- private EnvelopeEditor editor ;
- private SOAPTransport transport ;
-
- public FilterTransport(EnvelopeEditor editor, SOAPTransport transport) {
- this.editor = editor ;
- this.transport = transport ;
+public class FilterTransport implements SOAPTransport {
+ private EnvelopeEditor editor;
+ private SOAPTransport transport;
+
+ public FilterTransport(EnvelopeEditor editor, SOAPTransport transport) {
+ this.editor = editor;
+ this.transport = transport;
+ }
+
+ /**
+ * This method is used to request that an envelope be posted to the
+ * given URL. The response (if any) must be gotten by calling the
+ * receive() function.
+ *
+ * @param sendTo the URL to send the envelope to
+ * @param action the SOAPAction header field value
+ * @param headers any other header fields to go to as protocol headers
+ * @param env the envelope to send
+ * @param smr the XML<->Java type mapping registry (passed on)
+ *
+ * @exception SOAPException with appropriate reason code if problem
+ */
+ public void send(URL sendTo,
+ String action,
+ Hashtable headers,
+ Envelope env,
+ SOAPMappingRegistry
+ smr,
+ int timeout) throws SOAPException
+ {
+ try {
+ StringWriter sout = new StringWriter();
+ env.marshall (sout, smr);
+
+ StringReader sin = new StringReader(sout.getBuffer().toString());
+ if (editor != null) {
+ sout = new StringWriter();
+ editor.editOutgoing(sin, sout);
+ sout.flush();
+ sin = new StringReader(sout.getBuffer().toString());
+ }
+
+ XMLParserLiaison xpl = new XercesParserLiaison();
+ Element docElem =
+ xpl.read("On-the-fly SOAP Envelope", sin).getDocumentElement() ;
+ Envelope env2 = Envelope.unmarshall(docElem);
+ transport.send(sendTo, action, headers, env2, smr, timeout);
+ } catch (IllegalArgumentException e) {
+ throw new SOAPException (Constants.FAULT_CODE_CLIENT,
+ e.getMessage(),
+ e);
+ } catch (IOException e) {
+ throw new SOAPException (Constants.FAULT_CODE_CLIENT,
+ e.getMessage(),
+ e);
}
+ }
- //private BufferedReader responseReader;
- //private Hashtable responseHeaders;
-
- /**
- * This method is used to request that an envelope be posted to the
- * given URL. The response (if any) must be gotten by calling the
- * receive() function.
- *
- * @param sendTo the URL to send the envelope to
- * @param action the SOAPAction header field value
- * @param headers any other header fields to go to as protocol headers
- * @param env the envelope to send
- * @param smr the XML<->Java type mapping registry (passed on)
- *
- * @exception SOAPException with appropriate reason code if problem
- */
- public void send (URL sendTo, String action, Hashtable headers,
- Envelope env,
- SOAPMappingRegistry smr, int timeout) throws SOAPException {
- try {
- StringWriter sout = new StringWriter() ;
- env.marshall (sout, smr);
-
- StringReader sin = new StringReader(sout.getBuffer().toString()) ;
- if (editor != null) {
- sout = new StringWriter() ;
- editor.editOutgoing(sin, sout) ;
- sout.flush() ;
- sin = new StringReader(sout.getBuffer().toString()) ;
- }
-
- XMLParserLiaison xpl = new XercesParserLiaison() ;
- Envelope env2 = Envelope.unmarshall(xpl.read("On-the-fly SOAP Envelope", sin).getDocumentElement()) ;
- transport.send(sendTo, action, headers, env2, smr, timeout) ;
- } catch (IllegalArgumentException e) {
- throw new SOAPException (Constants.FAULT_CODE_CLIENT, e.getMessage(), e);
- } catch (IOException e) {
- throw new SOAPException (Constants.FAULT_CODE_CLIENT, e.getMessage(), e);
- }
- }
-
- /**
- * Return a buffered reader to receive back the response to whatever
- * was sent to whatever.
- *
- * @return a reader to read the results from or null if that's not
- * possible.
- */
- public BufferedReader receive () {
- try {
- BufferedReader in = transport.receive() ;
- if (editor == null)
- return in ;
- else {
- StringWriter sout = new StringWriter() ;
- editor.editIncoming(in, sout) ;
- sout.flush() ;
- StringReader sin = new StringReader(sout.getBuffer().toString()) ;
- return new BufferedReader(sin) ;
- }
- } catch (SOAPException e) {
- e.printStackTrace() ;
- // This exception should be thrown to the application.
- return null ;
- }
+ /**
+ * Return a buffered reader to receive back the response to whatever
+ * was sent to whatever.
+ *
+ * @return a reader to read the results from or null if that's not
+ * possible.
+ */
+ public BufferedReader receive () {
+ try {
+ BufferedReader in = transport.receive();
+ if (editor == null)
+ return in;
+ else {
+ StringWriter sout = new StringWriter();
+ editor.editIncoming(in, sout);
+ sout.flush();
+ StringReader sin = new StringReader(sout.getBuffer().toString());
+ return new BufferedReader(sin);
+ }
+ } catch (SOAPException e) {
+ e.printStackTrace();
+ // This exception should be thrown to the application.
+ return null;
}
+ }
- /**
- * Return access to headers generated by the protocol.
- *
- * @return a hashtable containing all the headers
- */
- public Hashtable getHeaders () {
- return transport.getHeaders() ;
- }
+ /**
+ * Return access to headers generated by the protocol.
+ *
+ * @return a hashtable containing all the headers
+ */
+ public Hashtable getHeaders () {
+ return transport.getHeaders();
+ }
}
/*
* End Transport-Hook-Extension