axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tom Jordahl <t...@macromedia.com>
Subject RE: cvs commit: xml-axis/java/src/org/apache/axis/wsdlgen Emitter .java Java2Wsdl.java
Date Fri, 30 Nov 2001 16:13:29 GMT
+                        if ("All".equals(modeArg))
+                            mode = Emitter.MODE_ALL;
+                        else if ("Interface".equals(modeArg))
+                            mode = Emitter.MODE_INTERFACE;
+                        else if ("Implementation".equals(modeArg))
+                            mode = Emitter.MODE_IMPLEMENTATION;


Ravi,

How about making these compares case insensitive?
That would be the user friendly thing to do.

P.S.  This java2wsdl work is great!

--
Tom Jordahl
Macromedia



-----Original Message-----
From: rkumar@apache.org [mailto:rkumar@apache.org]
Sent: Friday, November 30, 2001 10:29 AM
To: xml-axis-cvs@apache.org
Subject: cvs commit: xml-axis/java/src/org/apache/axis/wsdlgen
Emitter.java Java2Wsdl.java


rkumar      01/11/30 07:29:26

  Modified:    java/src/org/apache/axis/wsdlgen Emitter.java Java2Wsdl.java
  Log:
  Introduce WSDL generation modes options for the command line - options are
  All, interface only, implementation only.
  some day, need to do types as well
  
  Revision  Changes    Path
  1.9       +40 -4
xml-axis/java/src/org/apache/axis/wsdlgen/Emitter.java
  
  Index: Emitter.java
  ===================================================================
  RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/wsdlgen/Emitter.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Emitter.java	2001/11/30 13:51:31	1.8
  +++ Emitter.java	2001/11/30 15:29:26	1.9
  @@ -107,6 +107,10 @@
    */
   public class Emitter {
   
  +    public static final int MODE_ALL = 0;
  +    public static final int MODE_INTERFACE = 1;
  +    public static final int MODE_IMPLEMENTATION = 2;
  +
       private Class cls;
       private String allowedMethods;
       private String intfNS;          
  @@ -161,9 +165,41 @@
        * @throws Exception
        */
       public void emit(String filename) throws Exception {
  -        Definition def = getWSDL();
  -        Document doc =
WSDLFactory.newInstance().newWSDLWriter().getDocument(def);
  -        types.insertTypesFragment(doc);
  +        emit(filename, MODE_ALL);
  +    }
  +
  +    /**
  +     * Generates a WSDL document for a given <code>Class</code>. The
sections of
  +     * the WSDL generated are controlled by the mode parameter 
  +     * mode 0: All
  +     * mode 1: Interface
  +     * mode 2: Implementation
  +     * 
  +     * @param filename  WSDL
  +     * @param mode generation mode - all, interface, implementation

  +     * @throws Exception
  +     */
  +    public void emit(String filename, int mode) throws Exception {
  +        Document doc = null;
  +        Definition def = null;
  +        switch (mode) {
  +            case MODE_ALL:
  +                def = getWSDL();
  +                doc =
WSDLFactory.newInstance().newWSDLWriter().getDocument(def);
  +                types.insertTypesFragment(doc);
  +                break;
  +            case MODE_INTERFACE:
  +                def = getIntfWSDL();
  +                doc =
WSDLFactory.newInstance().newWSDLWriter().getDocument(def);
  +                types.insertTypesFragment(doc);
  +                break;
  +            case MODE_IMPLEMENTATION:
  +                def = getImplWSDL();
  +                doc =
WSDLFactory.newInstance().newWSDLWriter().getDocument(def);
  +                break;
  +            default:
  +                throw new Exception ("unrecognized output WSDL mode"); 
  +        }
           XMLUtils.PrettyDocumentToStream(doc, new FileOutputStream(new
File(filename)));
       }
   
  @@ -258,7 +294,7 @@
                   implNS = intfNS + "-impl";
   
               namespaces.put(cls.getName(), intfNS, "intf");
  -            namespaces.put(cls.getName(), implNS, "impl");
  +            namespaces.putPrefix(implNS, "impl");
           }
       }
   
  
  
  
  1.5       +25 -2
xml-axis/java/src/org/apache/axis/wsdlgen/Java2Wsdl.java
  
  Index: Java2Wsdl.java
  ===================================================================
  RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/wsdlgen/Java2Wsdl.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Java2Wsdl.java	2001/11/30 13:40:06	1.4
  +++ Java2Wsdl.java	2001/11/30 15:29:26	1.5
  @@ -71,6 +71,7 @@
   public class Java2Wsdl {
       // Define our short one-letter option identifiers.
       protected static final int HELP_OPT = 'h';
  +    protected static final int OUTPUT_WSDL_MODE_OPT = 'w';
       protected static final int OUTPUT_OPT = 'o';
       protected static final int OUTPUT_IMPL_OPT = 'O';
       protected static final int PACKAGE_OPT = 'p';
  @@ -130,6 +131,10 @@
   //                CLOptionDescriptor.ARGUMENT_REQUIRED,
   //                CLASSDIR_OPT,
   //                "classes directory"),
  +        new CLOptionDescriptor("outputWsdlMode",
  +                CLOptionDescriptor.ARGUMENT_REQUIRED,
  +                OUTPUT_WSDL_MODE_OPT,
  +                "output WSDL mode: All, Interface, Implementation"),
           new CLOptionDescriptor("output",
                   CLOptionDescriptor.ARGUMENT_REQUIRED,
                   OUTPUT_OPT,
  @@ -137,9 +142,10 @@
           new CLOptionDescriptor("outputImpl",
                   CLOptionDescriptor.ARGUMENT_REQUIRED,
                   OUTPUT_IMPL_OPT,
  -                "output Implementation Wsdl filename"),
  +                "output Implementation Wsdl filename, setting this causes
--outputWsdlMode to be ignored"),
       };
   
  +    
       /**
        * Main
        */
  @@ -150,6 +156,7 @@
           String wsdlFilename = null;
           String wsdlImplFilename = null;
           HashMap namespaceMap = new HashMap();
  +        int mode = Emitter.MODE_ALL;
   
           // Parse the arguments
           CLArgsParser parser = new CLArgsParser(args, options);
  @@ -193,6 +200,22 @@
   //                        classDir = option.getArgument();
   //                        break;
   //
  +                    case OUTPUT_WSDL_MODE_OPT:
  +                        String modeArg = option.getArgument();
  +                        if ("All".equals(modeArg))
  +                            mode = Emitter.MODE_ALL;
  +                        else if ("Interface".equals(modeArg))
  +                            mode = Emitter.MODE_INTERFACE;
  +                        else if ("Implementation".equals(modeArg))
  +                            mode = Emitter.MODE_IMPLEMENTATION;
  +                        else {
  +                            mode = Emitter.MODE_ALL; 
  +                            System.err.println("unrecognized mode : " +
modeArg);
  +                            System.err.println("use All, Interface and
Implementation");
  +                            System.err.println("using default: All");
  +                        }
  +                        break;
  +
                       case OUTPUT_OPT:
                           wsdlFilename = option.getArgument();
                           break;
  @@ -243,7 +266,7 @@
   
               // Generate a full wsdl, or interface & implementation wsdls
               if (wsdlImplFilename == null) {
  -                emitter.emit(wsdlFilename);
  +                emitter.emit(wsdlFilename, mode);
               } else {
                   emitter.emit(wsdlFilename, wsdlImplFilename);
               }
  
  
  

Mime
View raw message