axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacek Kopecky <ja...@idoox.com>
Subject Coding style (no flames please)
Date Fri, 09 Feb 2001 00:41:09 GMT
 Hello all. 8-)
 We discussed the coding style issue a bit on the IRC, and it seems
it's already hit us. In the following patch it's not clear what was
changed and what was only reformatted, because CVS has no easy way of
telling this.
 I suggest that until we solve this issue by either accepting common
coding style or by putting an indenter on the CVS server, we should
keep the style of the code we're changing when we make changes. This
way the patches will be much more descriptive and the changes will be
easy to understand (or at least more so). 
 It's certainly less productive to try to look what was changed
ourselves if CVS can do that easily for us.

                            Jacek Kopecky
                               Idoox



On 8 Feb 2001 gdaniels@apache.org wrote:

 > gdaniels    01/02/08 14:04:22
 > 
 >   Modified:    java/src/org/apache/axis/client EchoClient.java
 >   Added:       java/src/org/apache/axis/client TransportRoutingClient.java
 >   Log:
 >   Add '-l' option to EchoClient for local (in-memory) testing.
 >   
 >   Add TransportRoutingClient, which pretends to be the AxisServlet to demonstrate
 >   how transport-specific routing might work.  See comments for details.
 >   
 >   Revision  Changes    Path
 >   1.10      +79 -54    xml-axis/java/src/org/apache/axis/client/EchoClient.java
 >   
 >   Index: EchoClient.java
 >   ===================================================================
 >   RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/EchoClient.java,v
 >   retrieving revision 1.9
 >   retrieving revision 1.10
 >   diff -u -r1.9 -r1.10
 >   --- EchoClient.java	2001/01/26 20:55:00	1.9
 >   +++ EchoClient.java	2001/02/08 22:04:18	1.10
 >   @@ -61,67 +61,92 @@
 >    import java.io.*;
 >    import java.util.*;
 >    
 >   +import org.apache.axis.*;
 >   +import org.apache.axis.server.SimpleAxisEngine;
 >   +
 >    /**
 >     *
 >     * @author Doug Davis (dug@us.ibm.com)
 >   + * @author Glen Daniels (gdaniels@allaire.com)
 >     */
 >    public class EchoClient {
 >    
 >   -  public static void main(String args[]) {
 >   +    public static void main(String args[]) {
 >    
 >   -    String hdr = "POST /axis/servlet/AxisServlet HTTP/1.0\n" +
 >   -                 "Host: localhost:8080\n" +
 >   -                 "Content-Type: text/xml;charset=utf-8\n" +
 >   -                 "SOAPAction: EchoService\n";
 >   -
 >   -    String msg = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"
xmlns:xsi=\"http://www.w3.org/1999/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/1999/XMLSchema\">\n"
+
 >   -                 "<SOAP-ENV:Header>\n" +
 >   -                 "<t:Transaction xmlns:t=\"some-URI\" " +
 >   -                 "SOAP-ENV:mustUnderstand=\"1\"> 5 </t:Transaction>" +
 >   -                 "</SOAP-ENV:Header>\n" +
 >   -                 "<SOAP-ENV:Body>\n" +
 >   -                 "<m:GetLastTradePrice xmlns:m=\"Some-URI\">" +
 >   -                 "<symbol>IBM</symbol>" +
 >   -                 "</m:GetLastTradePrice>" +
 >   -                 "</SOAP-ENV:Body>\n" +
 >   -                 "</SOAP-ENV:Envelope>" ;
 >   -
 >   -    try {
 >   -      String  host = "localhost" ;
 >   -      int     port = 8080 ;
 >   -
 >   -      for ( int i = 0 ; i < args.length ; i++ ) {
 >   -        if ( args[i].charAt(0) == '-' ) {
 >   -          switch( args[i].toLowerCase().charAt(1) ) {
 >   -            case 'h': if ( args[i].length() > 2 )
 >   -                        host = args[i].substring(2);
 >   -                      break ;
 >   -            case 'p': if ( args[i].length() > 2 )
 >   -                        port = Integer.parseInt(args[i].substring(2));
 >   -                      break ;
 >   -            default: System.err.println( "Unknown option '" + 
 >   -                                         args[i].charAt(1) + "'" );
 >   -                     System.exit(1);
 >   -          }
 >   +        String hdr = "POST /axis/servlet/AxisServlet HTTP/1.0\n" +
 >   +                     "Host: localhost:8080\n" +
 >   +                     "Content-Type: text/xml;charset=utf-8\n" +
 >   +                     "SOAPAction: EchoService\n";
 >   +
 >   +        String msg = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"
xmlns:xsi=\"http://www.w3.org/1999/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/1999/XMLSchema\">\n"
+
 >   +                     "<SOAP-ENV:Header>\n" +
 >   +                     "<t:Transaction xmlns:t=\"some-URI\" " +
 >   +                     "SOAP-ENV:mustUnderstand=\"1\"> 5 </t:Transaction>"
+
 >   +                     "</SOAP-ENV:Header>\n" +
 >   +                     "<SOAP-ENV:Body>\n" +
 >   +                     "<m:GetLastTradePrice xmlns:m=\"Some-URI\">" +
 >   +                     "<symbol>IBM</symbol>" +
 >   +                     "</m:GetLastTradePrice>" +
 >   +                     "</SOAP-ENV:Body>\n" +
 >   +                     "</SOAP-ENV:Envelope>" ;
 >   +
 >   +        try {
 >   +            String  host = "localhost" ;
 >   +            int     port = 8080 ;
 >   +            boolean doLocal = false;
 >   +
 >   +            for ( int i = 0 ; i < args.length ; i++ ) {
 >   +                if ( args[i].charAt(0) == '-' ) {
 >   +                    switch( args[i].toLowerCase().charAt(1) ) {
 >   +                    case 'h': if ( args[i].length() > 2 )
 >   +                                  host = args[i].substring(2);
 >   +                              break ;
 >   +                    case 'p': if ( args[i].length() > 2 )
 >   +                                  port = Integer.parseInt(args[i].substring(2));
 >   +                              break ;
 >   +                    case 'l': doLocal = true;
 >   +                              break;
 >   +                    default: System.err.println( "Unknown option '" + 
 >   +                                                 args[i].charAt(1) + "'" );
 >   +                             System.exit(1);
 >   +                    }
 >   +                }
 >   +            }
 >   +            
 >   +            if (doLocal) {
 >   +                /** Run things in-memory, no servlet or anything.
 >   +                 */
 >   +                org.apache.axis.utils.Debug.setDebugLevel(10);
 >   +                SimpleAxisEngine engine = new SimpleAxisEngine();
 >   +                MessageContext msgContext = new MessageContext();
 >   +                Message message = new Message(msg, "String");
 >   +                msgContext.setIncomingMessage(message);
 >   +                
 >   +                // This is fixed, as this client tightly binds to the echo service.
 >   +                msgContext.setProperty(Constants.MC_TARGET, "EchoService");
 >   +                engine.init();
 >   +                engine.invoke(msgContext);
 >   +                
 >   +                System.out.println(msgContext.getOutgoingMessage().getAs("String"));
 >   +            } else {
 >   +                String         cl = "Content-Length: " + msg.length() + "\n\n" ;
 >   +                Socket         sock = new Socket( host, port );
 >   +                InputStream    inp = sock.getInputStream();
 >   +                OutputStream   out = sock.getOutputStream();
 >   +                byte           b ;
 >   +
 >   +                out.write( hdr.getBytes() );
 >   +                out.write( cl.getBytes() );
 >   +                out.write( msg.getBytes() );
 >   +
 >   +                while ( (b = (byte) inp.read()) != -1 ) 
 >   +                    System.out.write( b );
 >   +            }
 >            }
 >   -      }
 >   -
 >   -      String         cl = "Content-Length: " + msg.length() + "\n\n" ;
 >   -      Socket         sock = new Socket( host, port );
 >   -      InputStream    inp = sock.getInputStream();
 >   -      OutputStream   out = sock.getOutputStream();
 >   -      byte           b ;
 >   -
 >   -      out.write( hdr.getBytes() );
 >   -      out.write( cl.getBytes() );
 >   -      out.write( msg.getBytes() );
 >   -
 >   -      while ( (b = (byte) inp.read()) != -1 ) 
 >   -        System.out.write( b );
 >   -    }
 >   -    catch( Exception e ) {
 >   -      System.err.println( e );
 >   -    }
 >   -  };
 >   +        catch( Exception e ) {
 >   +            e.printStackTrace();
 >   +            System.err.println( e );
 >   +        }
 >   +    };
 >    
 >    };
 >   
 >   
 >   
 >   1.1                  xml-axis/java/src/org/apache/axis/client/TransportRoutingClient.java
 >   
 >   Index: TransportRoutingClient.java
 >   ===================================================================
 >   /*
 >    * The Apache Software License, Version 1.1
 >    *
 >    *
 >    * Copyright (c) 1999 The Apache Software Foundation.  All rights 
 >    * reserved.
 >    *
 >    * Redistribution and use in source and binary forms, with or without
 >    * modification, are permitted provided that the following conditions
 >    * are met:
 >    *
 >    * 1. Redistributions of source code must retain the above copyright
 >    *    notice, this list of conditions and the following disclaimer. 
 >    *
 >    * 2. Redistributions in binary form must reproduce the above copyright
 >    *    notice, this list of conditions and the following disclaimer in
 >    *    the documentation and/or other materials provided with the
 >    *    distribution.
 >    *
 >    * 3. The end-user documentation included with the redistribution,
 >    *    if any, must include the following acknowledgment:  
 >    *       "This product includes software developed by the
 >    *        Apache Software Foundation (http://www.apache.org/)."
 >    *    Alternately, this acknowledgment may appear in the software itself,
 >    *    if and wherever such third-party acknowledgments normally appear.
 >    *
 >    * 4. The names "Axis" and "Apache Software Foundation" must
 >    *    not be used to endorse or promote products derived from this
 >    *    software without prior written permission. For written 
 >    *    permission, please contact apache@apache.org.
 >    *
 >    * 5. Products derived from this software may not be called "Apache",
 >    *    nor may "Apache" appear in their name, without prior written
 >    *    permission of the Apache Software Foundation.
 >    *
 >    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 >    * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 >    * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 >    * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 >    * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 >    * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 >    * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 >    * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 >    * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 >    * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 >    * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 >    * SUCH DAMAGE.
 >    * ====================================================================
 >    *
 >    * This software consists of voluntary contributions made by many
 >    * individuals on behalf of the Apache Software Foundation and was
 >    * originally based on software copyright (c) 1999, International
 >    * Business Machines, Inc., http://www.ibm.com.  For more
 >    * information on the Apache Software Foundation, please see
 >    * <http://www.apache.org/>.
 >    */
 >   
 >   package org.apache.axis.client ;
 >   
 >   import java.net.*;
 >   import java.io.*;
 >   import java.util.*;
 >   
 >   import org.apache.axis.*;
 >   import org.apache.axis.server.SimpleAxisEngine;
 >   
 >   /** This is a quick in-memory client to demonstrate how transport-dependent
 >    * routing works.  It pretends to be the AxisServlet with a SOAPAction header
 >    * of "EchoService".  This ends up calling the AxisServlet chain, which
 >    * sets the new TARGET to be the value of the SOAPAction header, and then
 >    * uses the Router handler to dispatch to the service.
 >    *
 >    * @author Glen Daniels (gdaniels@allaire.com)
 >    */
 >   public class TransportRoutingClient {
 >   
 >       public static void main(String args[]) {
 >   
 >           String msg = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"
xmlns:xsi=\"http://www.w3.org/1999/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/1999/XMLSchema\">\n"
+
 >                        "<SOAP-ENV:Header>\n" +
 >                        "<t:Transaction xmlns:t=\"some-URI\" " +
 >                        "SOAP-ENV:mustUnderstand=\"1\"> 5 </t:Transaction>"
+
 >                        "</SOAP-ENV:Header>\n" +
 >                        "<SOAP-ENV:Body>\n" +
 >                        "<m:GetLastTradePrice xmlns:m=\"Some-URI\">" +
 >                        "<symbol>IBM</symbol>" +
 >                        "</m:GetLastTradePrice>" +
 >                        "</SOAP-ENV:Body>\n" +
 >                        "</SOAP-ENV:Envelope>" ;
 >   
 >           try {
 >               org.apache.axis.utils.Debug.setDebugLevel(10);
 >               SimpleAxisEngine engine = new SimpleAxisEngine();
 >               MessageContext msgContext = new MessageContext();
 >               Message message = new Message(msg, "String");
 >               msgContext.setIncomingMessage(message);
 >               
 >               /** The TARGET is "AxisServlet"
 >                */
 >               msgContext.setProperty(Constants.MC_TARGET, "AxisServlet");
 >               
 >               /** If we were a real servlet, we might have made the SOAPAction
 >                * HTTP header available like this...
 >                */
 >               msgContext.setProperty(Constants.MC_HTTP_SOAPACTION, "EchoService");
 >   
 >               engine.init();
 >               engine.invoke(msgContext);
 >               
 >               System.out.println(msgContext.getOutgoingMessage().getAs("String"));
 >           }
 >           catch( Exception e ) {
 >               e.printStackTrace();
 >           }
 >       };
 >   
 >   };
 >   
 >   
 >   
 > 


Mime
View raw message