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:38:33 UTC

cvs commit: xml-soap/java/src/org/apache/soap/server/http MessageRouterServlet.java RPCRouterServlet.java

neyama      00/11/15 05:38:33

  Modified:    java/src/org/apache/soap/server/http
                        MessageRouterServlet.java RPCRouterServlet.java
  Log:
  Fix to follow the coding style Sanjiva suggested.
  No semantic change.
  
  Revision  Changes    Path
  1.5       +139 -112  xml-soap/java/src/org/apache/soap/server/http/MessageRouterServlet.java
  
  Index: MessageRouterServlet.java
  ===================================================================
  RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/server/http/MessageRouterServlet.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MessageRouterServlet.java	2000/11/07 02:05:14	1.4
  +++ MessageRouterServlet.java	2000/11/15 13:38:32	1.5
  @@ -73,8 +73,8 @@
   /*
    * Begin Transport-Hook-Extension
    */
  -import org.apache.soap.transport.EnvelopeEditor ;
  -import org.apache.soap.transport.EnvelopeEditorFactory ;
  +import org.apache.soap.transport.EnvelopeEditor;
  +import org.apache.soap.transport.EnvelopeEditorFactory;
   /*
    * End Transport-Hook-Extension
    */
  @@ -85,74 +85,83 @@
    * @author Sanjiva Weerawarana <sa...@watson.ibm.com>
    */
   public class MessageRouterServlet extends HttpServlet {
  -    /*
  +  /*
        * Begin Transport-Hook-Extension
        */
  -    // Unlike client-side, EnvelopeEditorFactory, which creates an
  -    // EnvelopeEditor, and XMLParser are specified by servlet
  -    // init-parameters at the server-side.  For example, you may add
  -    // the following description to web.xml with Tomcat.
  -    // <servlet>
  -    //  <servlet-name>MessageRouterServlet</servlet-name>
  -    //    <servlet-class>org.apache.soap.server.http.MessageRouterServlet</servlet-class>
  -    //    <init-param>
  -    //      <param-name>EnvelopeEditor</param-name>
  -    //      <param-value>MyEnvelopeEditorFactory</param-value>
  -    //    </init-param>
  -    //    <init-param>
  -    //      <param-name>XMLParser</param-name>
  -    //      <param-value>samples.messaging.SampleXMLParserLiaison</param-value>
  -    //    </init-param>
  -    // </servlet>
  -    private static final String ENVELOPE_EDITOR_FACTORY = "EnvelopeEditorFactory" ;
  -    private static final String XML_PARSER = "XMLParser" ;
  -
  -    private EnvelopeEditor editor = null;
  -    private XMLParserLiaison xpl = new XercesParserLiaison();
  -    public void init() {
  -        if (System.getProperties().getProperty("org.apache.soap.TransportHookExtension") != null) {
  -            EnvelopeEditorFactory factory ;
  -            if ((factory = (EnvelopeEditorFactory)createObject(ENVELOPE_EDITOR_FACTORY)) != null) {
  -                try {
  -                    Properties props = new Properties() ;
  -                    Enumeration enum = getServletConfig().getInitParameterNames() ;
  -                    while(enum.hasMoreElements()) {
  -                        String name = (String)enum.nextElement() ;
  -                        if (!ENVELOPE_EDITOR_FACTORY.equals(name) &&
  -                            !XML_PARSER.equals(name))
  -                            props.setProperty(name, getServletConfig().getInitParameter(name)) ;
  -                    }
  -                    editor = factory.create(props) ;
  -                } catch (SOAPException e) {
  -                    System.err.println("WARNING: Can't create editor: " + e.getMessage());
  -                }
  -            }
  -            if ((xpl = (XMLParserLiaison)createObject(XML_PARSER)) == null)
  -                xpl = new XercesParserLiaison() ;
  +  // Unlike client-side, EnvelopeEditorFactory, which creates an
  +  // EnvelopeEditor, and XMLParser are specified by servlet
  +  // init-parameters at the server-side.  For example, you may add
  +  // the following description to web.xml with Tomcat.
  +  // <servlet>
  +  //  <servlet-name>MessageRouterServlet</servlet-name>
  +  //    <servlet-class>org.apache.soap.server.http.MessageRouterServlet</servlet-class>
  +  //    <init-param>
  +  //      <param-name>EnvelopeEditor</param-name>
  +  //      <param-value>MyEnvelopeEditorFactory</param-value>
  +  //    </init-param>
  +  //    <init-param>
  +  //      <param-name>XMLParser</param-name>
  +  //      <param-value>samples.messaging.SampleXMLParserLiaison</param-value>
  +  //    </init-param>
  +  // </servlet>
  +  private static final String ENVELOPE_EDITOR_FACTORY =
  +    "EnvelopeEditorFactory";
  +  private static final String XML_PARSER = "XMLParser";
  +
  +  private static final String TRANSPORT_HOOK_EXTENSION =
  +    "org.apache.soap.TransportHookExtension" ;
  +
  +  private EnvelopeEditor editor = null;
  +  private XMLParserLiaison xpl = new XercesParserLiaison();
  +  public void init() {
  +    if (System.getProperties().getProperty(TRANSPORT_HOOK_EXTENSION) != null) {
  +      EnvelopeEditorFactory factory =
  +        (EnvelopeEditorFactory)createObject(ENVELOPE_EDITOR_FACTORY);
  +      if (factory != null) {
  +        try {
  +          Properties props = new Properties();
  +          Enumeration enum = getServletConfig().getInitParameterNames();
  +          while(enum.hasMoreElements()) {
  +            String name = (String)enum.nextElement();
  +            if (!ENVELOPE_EDITOR_FACTORY.equals(name) &&
  +                !XML_PARSER.equals(name))
  +              props.setProperty(name,
  +                                getServletConfig().getInitParameter(name));
  +          }
  +          editor = factory.create(props);
  +        } catch (SOAPException e) {
  +          System.err.println("WARNING: Can't create editor: " +
  +                             e.getMessage());
           }
  +      }
  +      if ((xpl = (XMLParserLiaison)createObject(XML_PARSER)) == null)
  +        xpl = new XercesParserLiaison();
       }
  +  }
   
  -    private Object createObject(String name) {
  -            String value ;
  -            if ((value = getServletConfig().getInitParameter(name)) == null) {
  -                System.err.println(getClass().getName() + " cannot get a init parameter '" + name) ;
  -                return null ;
  -            }
  -            System.err.println(getClass().getName() + " god a init parameter '" + name + "'=" + value) ;
  -        try {
  -            return Class.forName(value).newInstance() ;
  -        } catch (ClassNotFoundException e) {
  -            System.err.println("WARNING: Can't find class named '" + value + "'");
  -        } catch (InstantiationException e) {
  -            System.err.println("WARNING: Can't instantiate class '" + value + "'");
  -        } catch (IllegalAccessException e) {
  -            System.err.println("WARNING: Can't access constructor of class '" + value + "'");
  -        }
  -        return null ;
  +  private Object createObject(String name) {
  +    String value;
  +    if ((value = getServletConfig().getInitParameter(name)) == null) {
  +      System.err.println(getClass().getName() +
  +                         " cannot get a init parameter '" + name);
  +      return null;
       }
  -    /*
  -     * End Transport-Hook-Extension
  -     */
  +    System.err.println(getClass().getName() +
  +                       " god a init parameter '" + name + "'=" + value);
  +    try {
  +      return Class.forName(value).newInstance();
  +    } catch (ClassNotFoundException e) {
  +      System.err.println("WARNING: Can't find class named '" + value + "'");
  +    } catch (InstantiationException e) {
  +      System.err.println("WARNING: Can't instantiate class '" + value + "'");
  +    } catch (IllegalAccessException e) {
  +      System.err.println("WARNING: Can't access constructor of class '" + value + "'");
  +    }
  +    return null;
  +  }
  +  /*
  +   * End Transport-Hook-Extension
  +   */
   
     public void doGet (HttpServletRequest req, HttpServletResponse res)
          throws ServletException, IOException {
  @@ -165,29 +174,32 @@
       out.println ("HTTP POST to talk to me.</p></body></html>");
     }
   
  -  public void doPost (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
  +  public void doPost (HttpServletRequest req, HttpServletResponse res)
  +    throws ServletException, IOException
  +  {
       /*
        * Begin Transport-Hook-Extension
        */
  -      // Invokes EnvelopeEditor (editIncoming)
  -      Reader in ;
  -      int contentLength ;
  -      if (System.getProperties().getProperty("org.apache.soap.TransportHookExtension") != null && editor != null) {
  -          try {
  -              StringWriter sout = new StringWriter() ;
  -              editor.editIncoming(req.getReader(), sout) ;
  -              String xml = sout.getBuffer().toString() ;
  -              in = new StringReader(xml) ;
  -              contentLength = xml.length() ;
  -          } catch (SOAPException e) {
  -              e.printStackTrace() ;
  -              // SOAPException must be handled here.
  -              return ;
  -          }
  -      } else {
  -          in = req.getReader() ;
  -          contentLength = req.getContentLength() ;
  +    // Invokes EnvelopeEditor (editIncoming)
  +    Reader in;
  +    int contentLength;
  +    String opt = System.getProperties().getProperty(TRANSPORT_HOOK_EXTENSION);
  +    if (opt != null && editor != null) {
  +      try {
  +        StringWriter sout = new StringWriter();
  +        editor.editIncoming(req.getReader(), sout);
  +        String xml = sout.getBuffer().toString();
  +        in = new StringReader(xml);
  +        contentLength = xml.length();
  +      } catch (SOAPException e) {
  +        e.printStackTrace();
  +        // SOAPException must be handled here.
  +        return;
         }
  +    } else {
  +      in = req.getReader();
  +      contentLength = req.getContentLength();
  +    }
       /*
        * End Transport-Hook-Extension
        */
  @@ -198,13 +210,13 @@
       ServiceManager serviceManager = 
         ServerHTTPUtils.getServiceManagerFromContext (context);
       int status;
  -	DeploymentDescriptor dd = null;
  +    DeploymentDescriptor dd = null;
   
       // create a writer to direct stuff to so that we can set the
       // content length
  -    ByteArrayOutputStream bytes = new ByteArrayOutputStream (4096) ;
  +    ByteArrayOutputStream bytes = new ByteArrayOutputStream (4096);
       PrintWriter out = new PrintWriter (new OutputStreamWriter (bytes, "UTF8"),
  -                                       true) ;
  +                                       true);
   
       try {
         // get the envelope
  @@ -217,9 +229,12 @@
         // EnvelopeEditor
         // Note: XMLParser that is specified by init-param isused in
         // this process.
  -      Envelope msgEnv = ServerHTTPUtils.readEnvelopeFromRequest (xpl, req.getContentType(), contentLength, in, res);
  +      Envelope msgEnv =
  +        ServerHTTPUtils.readEnvelopeFromRequest(xpl,
  +                                                req.getContentType(),
  +                                                contentLength, in, res);
         if (msgEnv == null)
  -          return ;
  +          return;
         /*
          * End Transport-Hook-Extension
          */
  @@ -265,23 +280,32 @@
         // that if the recepient is expecting to read some XML they'll
         // get it. If not, it doesn't hurt.
   
  -	SOAPException e = null;
  -	if (t instanceof SOAPException) e = (SOAPException)	t; else e = new SOAPException(Constants.FAULT_CODE_SERVER + ".Exception:", "", t);
  +      SOAPException e = null;
  +      if (t instanceof SOAPException)
  +        e = (SOAPException)t;
  +      else
  +        e = new SOAPException(Constants.FAULT_CODE_SERVER + ".Exception:",
  +                              "",
  +                              t);
   
         Fault fault = new Fault (e);
         fault.setFaultActorURI (req.getRequestURI ());
         if (dd != null)
  -          dd.buildFaultRouter().notifyListeners(fault, e);
  +        dd.buildFaultRouter().notifyListeners(fault, e);
   
  -	//determine the correct return HTTP status
  -	if (fault.getFaultCode().startsWith (Constants.FAULT_CODE_CLIENT)) {
  -		status = ServerConstants.SC_BAD_REQUEST;
  -	}
  -	else {
  +      //determine the correct return HTTP status
  +      if (fault.getFaultCode().startsWith (Constants.FAULT_CODE_CLIENT)) {
  +        status = ServerConstants.SC_BAD_REQUEST;
  +      } else {
   	      status = res.SC_INTERNAL_SERVER_ERROR;
  -	}
  +      }
   
  -      Response resp = new Response (null, null, fault, null, null, Constants.NS_URI_SOAP_ENC);
  +      Response resp = new Response(null,
  +                                   null,
  +                                   fault,
  +                                   null,
  +                                   null,
  +                                   Constants.NS_URI_SOAP_ENC);
   
         Envelope respEnvelope = resp.buildEnvelope ();
         respEnvelope.marshall (out, new SOAPMappingRegistry ());
  @@ -292,18 +316,21 @@
        * Begin Transport-Hook-Extension
        */
       // Translates response from server application with EnvelopeEditor
  -    if (System.getProperties().getProperty("org.apache.soap.TransportHookExtension") != null && editor != null) {
  -        in = new InputStreamReader(new ByteArrayInputStream(bytes.toByteArray())) ;
  -        Writer tout = new OutputStreamWriter(bytes = new ByteArrayOutputStream()) ;
  -        try {
  -            editor.editOutgoing(in, tout) ;
  -        } catch (SOAPException e) {
  -            e.printStackTrace() ;
  -            // SOAPException must be handled here.
  -            return ;
  -        }
  -        tout.flush() ;
  -        tout.close() ;
  +    opt = System.getProperties().getProperty(TRANSPORT_HOOK_EXTENSION) ;
  +    if (opt != null && editor != null) {
  +      byte[] data = bytes.toByteArray();
  +      in = new InputStreamReader(new ByteArrayInputStream(data));
  +      bytes = new ByteArrayOutputStream();
  +      Writer tout = new OutputStreamWriter(bytes);
  +      try {
  +        editor.editOutgoing(in, tout);
  +      } catch (SOAPException e) {
  +        e.printStackTrace();
  +        // SOAPException must be handled here.
  +        return;
  +      }
  +      tout.flush();
  +      tout.close();
       }
       /*
        * End Transport-Hook-Extension
  @@ -312,7 +339,7 @@
       // ship it out
       res.setStatus (status);
       res.setContentType (Constants.HEADERVAL_CONTENT_TYPE_UTF8);
  -    res.setContentLength (bytes.size ()) ;
  -    bytes.writeTo (res.getOutputStream ()) ;
  +    res.setContentLength (bytes.size ());
  +    bytes.writeTo (res.getOutputStream ());
     }
   }
  
  
  
  1.9       +154 -142  xml-soap/java/src/org/apache/soap/server/http/RPCRouterServlet.java
  
  Index: RPCRouterServlet.java
  ===================================================================
  RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/server/http/RPCRouterServlet.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- RPCRouterServlet.java	2000/11/07 02:05:14	1.8
  +++ RPCRouterServlet.java	2000/11/15 13:38:32	1.9
  @@ -54,7 +54,6 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    */
  -
   package org.apache.soap.server.http;
   
   import java.io.*;
  @@ -90,110 +89,120 @@
    * @author Kevin J. Mitchell (kevin.mitchell@xmls.com)
    */
   public class RPCRouterServlet extends HttpServlet {
  -    /*
  -     * Begin Transport-Hook-Extension
  -     */
  -    // Unlike client-side, EnvelopeEditorFactory, which creates an
  -    // EnvelopeEditor, and XMLParser are specified by servlet
  -    // init-parameters at the server-side.  For example, you may add
  -    // the following description to web.xml with Tomcat.
  -    // <servlet>
  -    //  <servlet-name>MessageRouterServlet</servlet-name>
  -    //    <servlet-class>org.apache.soap.server.http.MessageRouterServlet</servlet-class>
  -    //    <init-param>
  -    //      <param-name>EnvelopeEditor</param-name>
  -    //      <param-value>MyEnvelopeEditorFactory</param-value>
  -    //    </init-param>
  -    //    <init-param>
  -    //      <param-name>XMLParser</param-name>
  -    //      <param-value>samples.messaging.SampleXMLParserLiaison</param-value>
  -    //    </init-param>
  -    // </servlet>
  -    private static final String ENVELOPE_EDITOR_FACTORY = "EnvelopeEditorFactory" ;
  -    private static final String XML_PARSER = "XMLParser" ;
  -
  -    private EnvelopeEditor editor = null;
  -    private XMLParserLiaison xpl = new XercesParserLiaison();
  -    public void init() {
  -        if (System.getProperties().getProperty("org.apache.soap.TransportHookExtension") != null) {
  -            EnvelopeEditorFactory factory ;
  -            if ((factory = (EnvelopeEditorFactory)createObject(ENVELOPE_EDITOR_FACTORY)) != null) {
  -                try {
  -                    Properties props = new Properties() ;
  -                    Enumeration enum = getServletConfig().getInitParameterNames() ;
  -                    while(enum.hasMoreElements()) {
  -                        String name = (String)enum.nextElement() ;
  -                        if (!ENVELOPE_EDITOR_FACTORY.equals(name) &&
  -                            !XML_PARSER.equals(name))
  -                            props.setProperty(name, getServletConfig().getInitParameter(name)) ;
  -                    }
  -                    editor = factory.create(props) ;
  -                } catch (SOAPException e) {
  -                    System.err.println("WARNING: Can't create editor: " + e.getMessage());
  -                }
  -            }
  -            if ((xpl = (XMLParserLiaison)createObject(XML_PARSER)) == null)
  -                xpl = new XercesParserLiaison() ;
  +  /*
  +   * Begin Transport-Hook-Extension
  +   */
  +  // Unlike client-side, EnvelopeEditorFactory, which creates an
  +  // EnvelopeEditor, and XMLParser are specified by servlet
  +  // init-parameters at the server-side.  For example, you may add
  +  // the following description to web.xml with Tomcat.
  +  // <servlet>
  +  //  <servlet-name>MessageRouterServlet</servlet-name>
  +  //    <servlet-class>org.apache.soap.server.http.MessageRouterServlet</servlet-class>
  +  //    <init-param>
  +  //      <param-name>EnvelopeEditor</param-name>
  +  //      <param-value>MyEnvelopeEditorFactory</param-value>
  +  //    </init-param>
  +  //    <init-param>
  +  //      <param-name>XMLParser</param-name>
  +  //      <param-value>samples.messaging.SampleXMLParserLiaison</param-value>
  +  //    </init-param>
  +  // </servlet>
  +  private static final String ENVELOPE_EDITOR_FACTORY =
  +    "EnvelopeEditorFactory";
  +  private static final String XML_PARSER = "XMLParser";
  +
  +  private static final String TRANSPORT_HOOK_EXTENSION =
  +    "org.apache.soap.TransportHookExtension";
  +
  +  private EnvelopeEditor editor = null;
  +  private XMLParserLiaison xpl = new XercesParserLiaison();
  +  public void init() {
  +    if (System.getProperties().getProperty(TRANSPORT_HOOK_EXTENSION) != null) {
  +      EnvelopeEditorFactory factory =
  +        (EnvelopeEditorFactory)createObject(ENVELOPE_EDITOR_FACTORY);
  +      if (factory != null) {
  +        try {
  +          Properties props = new Properties();
  +          Enumeration enum = getServletConfig().getInitParameterNames();
  +          while(enum.hasMoreElements()) {
  +            String name = (String)enum.nextElement();
  +            if (!ENVELOPE_EDITOR_FACTORY.equals(name) &&
  +                !XML_PARSER.equals(name))
  +              props.setProperty(name, getServletConfig().getInitParameter(name));
  +          }
  +          editor = factory.create(props);
  +        } catch (SOAPException e) {
  +          System.err.println("WARNING: Can't create editor: " +
  +                             e.getMessage());
           }
  +      }
  +      if ((xpl = (XMLParserLiaison)createObject(XML_PARSER)) == null)
  +        xpl = new XercesParserLiaison();
       }
  +  }
   
  -    private Object createObject(String name) {
  -            String value ;
  -            if ((value = getServletConfig().getInitParameter(name)) == null) {
  -                System.err.println(getClass().getName() + " cannot get a init parameter '" + name) ;
  -                return null ;
  -            }
  -            System.err.println(getClass().getName() + " god a init parameter '" + name + "'=" + value) ;
  -        try {
  -            return Class.forName(value).newInstance() ;
  -        } catch (ClassNotFoundException e) {
  -            System.err.println("WARNING: Can't find class named '" + value + "'");
  -        } catch (InstantiationException e) {
  -            System.err.println("WARNING: Can't instantiate class '" + value + "'");
  -        } catch (IllegalAccessException e) {
  -            System.err.println("WARNING: Can't access constructor of class '" + value + "'");
  -        }
  -        return null ;
  +  private Object createObject(String name) {
  +    String value;
  +    if ((value = getServletConfig().getInitParameter(name)) == null) {
  +      System.err.println(getClass().getName() +
  +                         " cannot get a init parameter '" + name);
  +      return null;
       }
  -    /*
  -     * End Transport-Hook-Extension
  -     */
  +    System.err.println(getClass().getName() +
  +                       " god a init parameter '" + name + "'=" + value);
  +    try {
  +      return Class.forName(value).newInstance();
  +    } catch (ClassNotFoundException e) {
  +      System.err.println("WARNING: Can't find class named '" + value + "'");
  +    } catch (InstantiationException e) {
  +      System.err.println("WARNING: Can't instantiate class '" + value + "'");
  +    } catch (IllegalAccessException e) {
  +      System.err.println("WARNING: Can't access constructor of class '" +
  +                         value + "'");
  +    }
  +    return null;
  +  }
  +  /*
  +   * End Transport-Hook-Extension
  +   */
   
     public void doGet (HttpServletRequest req, HttpServletResponse res)
  -       throws ServletException, IOException {
  +    throws ServletException, IOException {
       PrintWriter out = res.getWriter ();
   	
  -	res.setContentType("text/html");
  -	out.println("<html><head><title>SOAP RPC Router</title></head>");
  +    res.setContentType("text/html");
  +    out.println("<html><head><title>SOAP RPC Router</title></head>");
       out.println ("<body><h1>SOAP RPC Router</h1>");
       out.println ("<p>Sorry, I don't speak via HTTP GET- you have to use");
       out.println ("HTTP POST to talk to me.</p></body></html>");
     }
   
     public void doPost (HttpServletRequest req, HttpServletResponse res)
  -       throws ServletException, IOException {
  +    throws ServletException, IOException {
       /*
        * Begin Transport-Hook-Extension
        */
  -      // Invokes EnvelopeEditor (editIncoming)
  -      Reader in ;
  -      int contentLength ;
  -      if (System.getProperties().getProperty("org.apache.soap.TransportHookExtension") != null && editor != null) {
  -          try {
  -              StringWriter sout = new StringWriter() ;
  -              editor.editIncoming(req.getReader(), sout) ;
  -              String xml = sout.getBuffer().toString() ;
  -              in = new StringReader(xml) ;
  -              contentLength = xml.length() ;
  -          } catch (SOAPException e) {
  -              e.printStackTrace() ;
  -              // SOAPException must be handled here.
  -              return ;
  -          }
  -      } else {
  -          in = req.getReader() ;
  -          contentLength = req.getContentLength() ;
  +    // Invokes EnvelopeEditor (editIncoming)
  +    Reader in;
  +    int contentLength;
  +    String opt = System.getProperties().getProperty(TRANSPORT_HOOK_EXTENSION) ;
  +    if (opt != null && editor != null) {
  +      try {
  +        StringWriter sout = new StringWriter();
  +        editor.editIncoming(req.getReader(), sout);
  +        String xml = sout.getBuffer().toString();
  +        in = new StringReader(xml);
  +        contentLength = xml.length();
  +      } catch (SOAPException e) {
  +        e.printStackTrace();
  +        // SOAPException must be handled here.
  +        return;
         }
  +    } else {
  +      in = req.getReader();
  +      contentLength = req.getContentLength();
  +    }
       /*
        * End Transport-Hook-Extension
        */
  @@ -207,7 +216,7 @@
       Call call = null;
       Response resp = null;
       String targetID = null;
  -    String fullTargetID = null ;
  +    String fullTargetID = null;
       int status = res.SC_OK;
       DeploymentDescriptor dd = null;
   
  @@ -215,24 +224,27 @@
   
         // extract the call
         try {
  -      /*
  -       * Begin Transport-Hook-Extension
  -       */
  -        //Envelope callEnv = ServerHTTPUtils.readEnvelopeFromRequest (req, res);
  -
  -      // Generate Envelope after the incoming message is translated by
  -      // EnvelopeEditor
  -      // Note: XMLParser that is specified by init-param isused in
  -      // this process.
  -      Envelope callEnv = ServerHTTPUtils.readEnvelopeFromRequest (xpl, req.getContentType(), contentLength, in, res);
  -      if (callEnv == null)
  -          return ;
  -      /*
  -       * End Transport-Hook-Extension
  -       */
  +        /*
  +         * Begin Transport-Hook-Extension
  +         */
  +        // Generate Envelope after the incoming message is translated by
  +        // EnvelopeEditor
  +        // Note: XMLParser that is specified by init-param isused in
  +        // this process.
  +        Envelope callEnv =
  +          ServerHTTPUtils.readEnvelopeFromRequest(xpl,
  +                                                  req.getContentType(),
  +                                                  contentLength,
  +                                                  in,
  +                                                  res);
  +        if (callEnv == null)
  +          return;
  +        /*
  +         * End Transport-Hook-Extension
  +         */
           call = RPCRouter.extractCallFromEnvelope (serviceManager, callEnv);
           targetID = call.getTargetObjectURI ();
  -	fullTargetID = call.getFullTargetObjectURI ();
  +        fullTargetID = call.getFullTargetObjectURI ();
         } catch (IllegalArgumentException e) {
           String msg = e.getMessage ();
           String faultCode =
  @@ -248,58 +260,55 @@
   
         if ( dd.getProviderType() == DeploymentDescriptor.PROVIDER_JAVA ) {
           // Handle Java based services
  -	Provider provider = new org.apache.soap.providers.JavaProvider();
  +        Provider provider = new org.apache.soap.providers.JavaProvider();
   
           provider.locate( dd, call, fullTargetID, this, session );
  -	resp = provider.invoke();
  -      }
  -      else if (dd.getProviderType() == DeploymentDescriptor.PROVIDER_USER_DEFINED) {
  +        resp = provider.invoke();
  +      } else if (dd.getProviderType() == DeploymentDescriptor.PROVIDER_USER_DEFINED) {
           // Handle user-defined providers
  -	Provider provider = ServerHTTPUtils.loadProvider(dd);
  +        Provider provider = ServerHTTPUtils.loadProvider(dd);
   
           provider.locate( dd, call, fullTargetID, this, session );
  -	resp = provider.invoke();
  -      }
  -      else {
  +        resp = provider.invoke();
  +      } else {
           // Handle scripts
  -	Provider provider = new org.apache.soap.providers.JavaProvider();
  +        Provider provider = new org.apache.soap.providers.JavaProvider();
   
           provider.locate( dd, call, fullTargetID, this, session );
  -	resp = provider.invoke();
  +        resp = provider.invoke();
         }
       } catch (Throwable t) {
  -    System.err.println( "\nERR1: " + t.toString() + "\n" );
  +      System.err.println( "\nERR1: " + t.toString() + "\n" );
         // note that we catch runtime errors too with the above .. the
         // idea is to do a SOAP fault for everything that goes out so
         // that if the recepient is expecting to read some XML they'll
         // get it. If not, it doesn't hurt.
  -	SOAPException e = null;
  -	if (t instanceof SOAPException) e = (SOAPException)	t; else e = new SOAPException(Constants.FAULT_CODE_SERVER + ".Exception:", "", t);
  +      SOAPException e = null;
  +      if (t instanceof SOAPException) e = (SOAPException)	t; else e = new SOAPException(Constants.FAULT_CODE_SERVER + ".Exception:", "", t);
   
         Fault fault = new Fault (e);
         fault.setFaultActorURI (req.getRequestURI ());
         if (dd != null)
  -          dd.buildFaultRouter().notifyListeners(fault, e);
  +        dd.buildFaultRouter().notifyListeners(fault, e);
   
  -	//determine the correct return HTTP status
  -	if (fault.getFaultCode().startsWith (Constants.FAULT_CODE_CLIENT)) {
  -		status = ServerConstants.SC_BAD_REQUEST;
  -	}
  -	else {
  +      //determine the correct return HTTP status
  +      if (fault.getFaultCode().startsWith (Constants.FAULT_CODE_CLIENT)) {
  +        status = ServerConstants.SC_BAD_REQUEST;
  +      } else {
   	      status = res.SC_INTERNAL_SERVER_ERROR;
  -	}
  +      }
   
  -	String respEncStyle = call.getEncodingStyleURI(); 
  -	if(respEncStyle == null) respEncStyle = Constants.NS_URI_SOAP_ENC; 
  +      String respEncStyle = call.getEncodingStyleURI(); 
  +      if(respEncStyle == null) respEncStyle = Constants.NS_URI_SOAP_ENC; 
   
         resp = new Response (null, null, fault, null, null, respEncStyle);
       }
     
       // create a writer to direct stuff to so that we can set the
       // content length
  -    ByteArrayOutputStream bytes = new ByteArrayOutputStream (4096) ;
  +    ByteArrayOutputStream bytes = new ByteArrayOutputStream (4096);
       OutputStreamWriter osw = new OutputStreamWriter (bytes, "UTF8");
  -    PrintWriter out = new PrintWriter (osw, true) ;
  +    PrintWriter out = new PrintWriter (osw, true);
       
       // put the response envelope out
       try {
  @@ -320,18 +329,21 @@
        * Begin Transport-Hook-Extension
        */
       // Translates response from server application with EnvelopeEditor
  -    if (System.getProperties().getProperty("org.apache.soap.TransportHookExtension") != null && editor != null) {
  -        in = new InputStreamReader(new ByteArrayInputStream(bytes.toByteArray())) ;
  -        Writer tout = new OutputStreamWriter(bytes = new ByteArrayOutputStream()) ;
  -        try {
  -            editor.editOutgoing(in, tout) ;
  -        } catch (SOAPException e) {
  -            e.printStackTrace() ;
  -            // SOAPException must be handled here.
  -            return ;
  -        }
  -        tout.flush() ;
  -        tout.close() ;
  +    opt = System.getProperties().getProperty(TRANSPORT_HOOK_EXTENSION);
  +    if (opt != null && editor != null) {
  +      byte[] data = bytes.toByteArray();
  +      in = new InputStreamReader(new ByteArrayInputStream(data));
  +      bytes = new ByteArrayOutputStream();
  +      Writer tout = new OutputStreamWriter(bytes);
  +      try {
  +        editor.editOutgoing(in, tout);
  +      } catch (SOAPException e) {
  +        e.printStackTrace();
  +        // SOAPException must be handled here.
  +        return;
  +      }
  +      tout.flush();
  +      tout.close();
       }
       /*
        * End Transport-Hook-Extension
  @@ -339,8 +351,8 @@
   
       // ship the stuff out
       res.setContentType (Constants.HEADERVAL_CONTENT_TYPE_UTF8);
  -    res.setContentLength (bytes.size ()) ;
  +    res.setContentLength (bytes.size ());
       res.setStatus(status);
  -    bytes.writeTo (res.getOutputStream ()) ;
  +    bytes.writeTo (res.getOutputStream ());
     }
   }
  
  
  

Re: cvs commit: xml-soap/java/src/org/apache/soap/server/http MessageRouterServlet.java RPCRouterServlet.java

Posted by Ryo Neyama <ne...@trl.ibm.co.jp>.
I fixed some the source codes I was concerned in to follow the coding
style including indentation, limitation of characters per line.

There is no semantic change this time.

Regards,
    Ryo Neyama @ IBM Research, Tokyo Research Laboratory
    Internet Technology
    neyama@trl.ibm.co.jp

Re: cvs commit: xml-soap/java/src/org/apache/soap/server/http MessageRouterServlet.java RPCRouterServlet.java

Posted by Ryo Neyama <ne...@trl.ibm.co.jp>.
I fixed some the source codes I was concerned in to follow the coding
style including indentation, limitation of characters per line.

There is no semantic change this time.

Regards,
    Ryo Neyama @ IBM Research, Tokyo Research Laboratory
    Internet Technology
    neyama@trl.ibm.co.jp