axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/utils resources.properties
Date Tue, 04 Dec 2001 19:43:29 GMT
tomj        01/12/04 11:43:29

  Modified:    java/src/org/apache/axis/wsdl Emitter.java JavaWriter.java
                        Namespaces.java SymbolTable.java Wsdl2java.java
               java/src/org/apache/axis/utils resources.properties
  Log:
  Add the --package switch to allow wsdl2java users to specify a global
  namespace to package mapping.
  
  If multiple classes/files of the same package & name are being emitted,
  throw an error and warn the user that their namespace to package
  mapping may be wrong.
  
  Clean up some unused code in the SymbolTable class.
  
  Revision  Changes    Path
  1.110     +35 -7     xml-axis/java/src/org/apache/axis/wsdl/Emitter.java
  
  Index: Emitter.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/Emitter.java,v
  retrieving revision 1.109
  retrieving revision 1.110
  diff -u -r1.109 -r1.110
  --- Emitter.java	2001/12/04 19:34:56	1.109
  +++ Emitter.java	2001/12/04 19:43:29	1.110
  @@ -99,6 +99,7 @@
       protected boolean bVerbose = false;
       protected boolean bGenerateImports = true;
       protected String outputDir = null;
  +    protected String packageName = null;
       protected byte scope = NO_EXPLICIT_SCOPE;
       protected ArrayList classList = new ArrayList();
       protected ArrayList fileList = new ArrayList();
  @@ -150,12 +151,16 @@
           this.doc = doc;
           namespaces = new Namespaces(outputDir);
   
  -        // First, read the namespace mapping file - NStoPkg.properties - if it
  -        // exists, and load the namespaceMap HashMap with its data.
  -        getNStoPkgFromPropsFile(namespaces);
  -
  -        if (delaySetMap != null) {
  -            namespaces.putAll(delaySetMap);
  +        if (packageName != null) {
  +             namespaces.setDefaultPackage(packageName);
  +        } else {
  +            // First, read the namespace mapping file - NStoPkg.properties - if it
  +            // exists, and load the namespaceMap HashMap with its data.
  +            getNStoPkgFromPropsFile(namespaces);
  +            
  +            if (delaySetMap != null) {
  +                namespaces.putAll(delaySetMap);
  +            }
           }
   
           symbolTable = new SymbolTable(namespaces, bGenerateImports);
  @@ -286,7 +291,7 @@
       }
   
       /**
  -     * Turn on/off server Message Context parm creation in skel
  +     * Turn on/off server Message Context parameter in skeleton
        * @param boolean value
        */
       public void generateMessageContext(boolean value) {
  @@ -301,6 +306,9 @@
           return this.bMessageContext;
       }
   
  +    /**
  +     * Return the current definition
  +     */ 
       public Definition getCurrentDefinition() {
           return this.def;
       }
  @@ -321,10 +329,16 @@
           this.bVerbose = value;
       }
   
  +    /**
  +     * Return the status of the verbose switch
  +     */ 
       public boolean getVerbose() {
           return this.bVerbose;
       }
   
  +    /**
  +     * Set a map of namespace -> Java package names
  +     */ 
       public void setNamespaceMap(HashMap map) {
           delaySetMap = map;
       }
  @@ -337,6 +351,20 @@
           this.outputDir = outputDir;
       }
   
  +    /**
  +     * Get global package name to use instead of mapping namespaces
  +     */ 
  +    public String getPackageName() {
  +        return packageName;
  +    }
  +
  +    /**
  +     * Set a global package name to use instead of mapping namespaces
  +     */ 
  +    public void setPackageName(String packageName) {
  +        this.packageName = packageName;
  +    }
  +    
       /**
        * Get the output directory to use for emitted source files
        */
  
  
  
  1.11      +13 -2     xml-axis/java/src/org/apache/axis/wsdl/JavaWriter.java
  
  Index: JavaWriter.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/JavaWriter.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- JavaWriter.java	2001/11/27 19:25:10	1.10
  +++ JavaWriter.java	2001/12/04 19:43:29	1.11
  @@ -142,8 +142,19 @@
        */
       public void write() throws IOException {
           String packageDirName = namespaces.toDir(packageName);
  -        emitter.fileList.add(packageDirName + fileName);
  -        emitter.classList.add(packageName + "." + className);
  +        String path = packageDirName + fileName;
  +        String fqClass = packageName + "." + className;
  +        
  +        // Check for duplicates, probably the result of namespace mapping
  +        if (emitter.classList.contains(fqClass)) {
  +            throw new IOException(JavaUtils.getMessage("duplicateClass00", fqClass));
  +        }
  +        if (emitter.fileList.contains(path)) {
  +            throw new IOException(JavaUtils.getMessage("duplicateFile00", path));
  +        }
  +        
  +        emitter.fileList.add(path);
  +        emitter.classList.add(fqClass);
           namespaces.mkdir(packageName);
           File file = new File(packageDirName, fileName);
           if (emitter.bVerbose) {
  
  
  
  1.12      +18 -0     xml-axis/java/src/org/apache/axis/wsdl/Namespaces.java
  
  Index: Namespaces.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/Namespaces.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Namespaces.java	2001/12/03 14:48:15	1.11
  +++ Namespaces.java	2001/12/04 19:43:29	1.12
  @@ -66,6 +66,7 @@
   */
   public class Namespaces extends HashMap {
       private String root;
  +    private String defaultPackage = null;
   
       /**
        * Instantiate a Namespaces object whose packages will all reside under root.
  @@ -81,6 +82,7 @@
       private Namespaces(Namespaces clone) {
           super(clone);
           this.root = clone.root;
  +        this.defaultPackage = clone.defaultPackage;
       } // ctor
   
       /**
  @@ -95,6 +97,9 @@
        * this namespace, create one.
        */
       public String getCreate(String key) {
  +        if (defaultPackage != null) {
  +            return defaultPackage;
  +        }
           Object value = super.get(key);
           if (value == null) {
               value = Utils.makePackageName((String) key);
  @@ -108,6 +113,9 @@
        * doesn't exist in the HashMap, return "".
        */
       public String getAsDir(String key) {
  +        if (defaultPackage != null) {
  +            return toDir(defaultPackage);
  +        }
           String pkg = (String) get(key);
           return toDir(pkg);
       } // getAsDir
  @@ -171,4 +179,14 @@
           File packageDir = new File(pkgDirString);
           packageDir.mkdirs();
       } // mkdir
  +
  +    /**
  +     * Set a package name that overrides the namespace map
  +     * 
  +     * @param a java package name (e.g. com.foo)
  +     */ 
  +    public void setDefaultPackage(String defaultPackage) {
  +        this.defaultPackage = defaultPackage;
  +    }
  +
   } // class Namespaces
  
  
  
  1.15      +11 -34    xml-axis/java/src/org/apache/axis/wsdl/SymbolTable.java
  
  Index: SymbolTable.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/SymbolTable.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- SymbolTable.java	2001/12/04 19:34:56	1.14
  +++ SymbolTable.java	2001/12/04 19:43:29	1.15
  @@ -171,7 +171,7 @@
                   }
               }
               
  -/* This is a bad idea right now
  +/* tomj: This is a bad idea, faults seem to be undefined
               // Messages
               Iterator i = def.getMessages().values().iterator();
               while (i.hasNext()) {
  @@ -480,16 +480,14 @@
           Input input = operation.getInput();
           if (input != null) {
               partStrings(inputs,
  -                    input.getMessage().getOrderedParts(null)/*,
  -                    (wsdlAttr.getInputBodyType(operation) == BindingEntry.USE_LITERAL)*/);
  +                    input.getMessage().getOrderedParts(null));
           }
   
           // Collect all the output parameters
           Output output = operation.getOutput();
           if (output != null) {
               partStrings(outputs,
  -                    output.getMessage().getOrderedParts(null)/*,
  -                    (wsdlAttr.getOutputBodyType(operation) == BindingEntry.USE_LITERAL)*/);
  +                    output.getMessage().getOrderedParts(null));
           }
   
           if (parameterOrder != null) {
  @@ -611,31 +609,21 @@
        * This method returns a vector containing the Java types (even indices) and
        * names (odd indices) of the parts.
        */
  -    protected void partStrings(Vector v, Collection parts/*, boolean literal*/) {
  +    protected void partStrings(Vector v, Collection parts) {
           Iterator i = parts.iterator();
   
           while (i.hasNext()) {
               Part part = (Part) i.next();
               QName elementName = part.getElementName();
               QName typeName = part.getTypeName();
  -/* The literal distinction doesn't belong here, it belongs in the writers - somewhere
  -            if (literal) {
  -                if (elementName != null) {
  -                    v.add(Utils.capitalizeFirstChar(elementName.getLocalPart()));
  -                    v.add(part.getName());
  -                }
  -            } else {
  -*/
  -                // Encoded
  -                if (typeName != null) {
  -                    v.add(getTypeEntry(typeName));
  -                    v.add(part.getName());
  -                } else if (elementName != null) {
  -                    v.add(getElementTypeEntry(elementName));
  -                    v.add(part.getName());
  -                }
  +            if (typeName != null) {
  +                v.add(getTypeEntry(typeName));
  +                v.add(part.getName());
  +            } else if (elementName != null) {
  +                v.add(getElementTypeEntry(elementName));
  +                v.add(part.getName());
               }
  -//        }
  +        }
       } // partStrings
   
       /**
  @@ -668,17 +656,6 @@
                       }
                   }
               }
  -
  -/* RJB:  I'm not sure about this attribute.  Waiting for Tom Jordahl's input.
  -            PortType port = binding.getPortType();
  -            PortTypeEntry ptEntry = (PortTypeEntry)symbolTable.get(port.getQName());
  -
  -            if (bindingType != BindingEntry.TYPE_SOAP) {
  -                ptEntry.setIsInSoapBinding(true);
  -            } else {
  -                ptEntry.setIsInSoapBinding(false);
  -            }
  -*/
   
               // Check the Binding Operations for use="literal"
               HashMap attributes = new HashMap();
  
  
  
  1.21      +15 -0     xml-axis/java/src/org/apache/axis/wsdl/Wsdl2java.java
  
  Index: Wsdl2java.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/Wsdl2java.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- Wsdl2java.java	2001/11/09 15:02:17	1.20
  +++ Wsdl2java.java	2001/12/04 19:43:29	1.21
  @@ -80,6 +80,7 @@
       protected static final int SCOPE_OPT = 'd';
       protected static final int TEST_OPT = 't';
       protected static final int NOIMPORTS_OPT = 'n';
  +    protected static final int PACKAGE_OPT = 'p';
   
       /**
        *  Define the understood options. Each CLOptionDescriptor contains:
  @@ -111,6 +112,10 @@
                   CLOptionDescriptor.DUPLICATES_ALLOWED + CLOptionDescriptor.ARGUMENTS_REQUIRED_2,
                   NAMESPACE_OPT,
                   JavaUtils.getMessage("optionNStoPkg00")),
  +        new CLOptionDescriptor("package",
  +                CLOptionDescriptor.ARGUMENT_REQUIRED,
  +                PACKAGE_OPT,
  +                JavaUtils.getMessage("optionPackage00")),
           new CLOptionDescriptor("output",
                   CLOptionDescriptor.ARGUMENT_REQUIRED,
                   OUTPUT_OPT,
  @@ -138,6 +143,7 @@
           boolean bTestClass = false;
           String wsdlURI = null;
           HashMap namespaceMap = new HashMap();
  +        boolean bPackageOpt = false;
   
           // Parse the arguments
           CLArgsParser parser = new CLArgsParser(args, options);
  @@ -196,6 +202,11 @@
                           namespaceMap.put(namespace, packageName);
                           break;
   
  +                    case PACKAGE_OPT:
  +                        bPackageOpt = true;
  +                        emitter.setPackageName(option.getArgument());
  +                        break;
  +
                       case OUTPUT_OPT:
                           emitter.setOutputDir(option.getArgument());
                           break;
  @@ -235,6 +246,10 @@
                   printUsage();
               }
               if (wsdlURI == null) {
  +                printUsage();
  +            }
  +            if (!namespaceMap.isEmpty() && bPackageOpt) {
  +                System.out.println(JavaUtils.getMessage("badpackage00"));
                   printUsage();
               }
   
  
  
  
  1.20      +6 -0      xml-axis/java/src/org/apache/axis/utils/resources.properties
  
  Index: resources.properties
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/resources.properties,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- resources.properties	2001/12/03 03:31:31	1.19
  +++ resources.properties	2001/12/04 19:43:29	1.20
  @@ -35,6 +35,7 @@
   badNameAttr00=No ''name'' attribute was specified in an undeployment element
   badNamespace00=Bad envelope namespace:  {0}
   badOffset00=Malformed offset attribute ''{0}''.
  +badpackage00=Error: --NStoPKG and --package switch can't be used together
   badPosition00=Malformed position attribute ''{0}''.
   badProxy00=Proxy port number, "{0}", incorrectly formatted
   
  @@ -119,6 +120,10 @@
   doList00=Doing a list
   done00=Done processing
   doQuit00=Doing a quit
  +
  +duplicateFile00=Duplicate file name: {0}.  \nHint: you may have mapped two namespaces with
elements of the same name to the same package name.
  +duplicateClass00=Duplicate class name: {0}.  \nHint: you may have mapped two namespaces
with elements of the same name to the same package name.
  +
   elapsed00=Elapsed:  {0} milliseconds
   
   # NOTE:  in emitFail00, do not translate "parameterOrder"
  @@ -407,6 +412,7 @@
   optionNStoPkg00=mapping of namespace to package
   
   optionOutput00=output directory for emitted files
  +optionPackage00=override all namespace to package mappings, use this package name instead
   options00=Options:
   
   # NOTE:  in optionScope00, do not translate "Application", "Request", "Session"
  
  
  

Mime
View raw message