You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2004/10/24 21:12:56 UTC

cvs commit: ws-axis/java/test/wsdl/wsrf build.xml

dims        2004/10/24 12:12:56

  Modified:    java/src/org/apache/axis/wsdl/toJava
                        JavaGeneratorFactory.java Namespaces.java
               java/test/wsdl/wsrf build.xml
  Log:
  Fix for AXIS-1614 - Name collision of generated code caused by AXIS-1598
  from Jongjin Choi
  
  Revision  Changes    Path
  1.60      +24 -35    ws-axis/java/src/org/apache/axis/wsdl/toJava/JavaGeneratorFactory.java
  
  Index: JavaGeneratorFactory.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/toJava/JavaGeneratorFactory.java,v
  retrieving revision 1.59
  retrieving revision 1.60
  diff -u -r1.59 -r1.60
  --- JavaGeneratorFactory.java	20 Oct 2004 13:49:35 -0000	1.59
  +++ JavaGeneratorFactory.java	24 Oct 2004 19:12:56 -0000	1.60
  @@ -935,7 +935,7 @@
       protected String getPortJavaNameHook(String portName) {
           return null;
       }
  -
  +    
       /**
        * Messages, PortTypes, Bindings, and Services can share the same name.  If they do in this
        * Definition, force their names to be suffixed with _PortType and _Service, respectively.
  @@ -946,49 +946,38 @@
   
           // Keep a list of anonymous types so we don't try to resolve them twice.
           HashSet anonTypes = new HashSet();
  -        Iterator it = symbolTable.getHashMap().values().iterator();
  -
  -        // MUST check Name Collisions between different namespaces 
  -        // in case package name is set with default package name.
  -        // To do it, reconstruct iterator.
  -        if (emitter.getPackageName() != null) {
  -            List entries = new ArrayList();
  -            List namespaceURIs = new ArrayList();
  -            List localParts = new ArrayList();
  -            
  -            // Collect namespaceURIs and names related to the all entry of SymbolTable.
  -            HashMap map = symbolTable.getHashMap();
  -            Set keySet = map.keySet();
  -            for (Iterator itr = keySet.iterator(); itr.hasNext(); ) {
  -                QName qName = (QName)itr.next();
  -
  -                String namespaceURI = qName.getNamespaceURI();
  -                if (!namespaceURIs.contains(namespaceURI))
  -                    namespaceURIs.add(namespaceURI);
  -
  -                String localPart = qName.getLocalPart();
  -                if (!localParts.contains(localPart))
  -                    localParts.add(localPart);
  -            }
  +        List collisionCanidates = new ArrayList();      // List of vector of SymbolTable entry
  +        
  +        List localParts = new ArrayList();      // all localparts in all symboltable entries        
  +        for (Iterator i = symbolTable.getHashMap().keySet().iterator(); i.hasNext(); ) {
  +            QName qName = (QName)i.next();
  +            String localPart = qName.getLocalPart();
  +            if (!localParts.contains(localPart))
  +                localParts.add(localPart);
  +        }
               
  +        Map pkg2NamespacesMap = emitter.getNamespaces().getPkg2NamespacesMap();
  +        for (Iterator i = pkg2NamespacesMap.values().iterator(); i.hasNext(); ) {            
  +            Vector namespaces = (Vector)i.next();  // namepaces mapped to same package
  +                    
               // Combine entry vectors, which have the same entry name, into a new entry vector.
  -            for (int i = 0; i < localParts.size(); i++) {
  +            for (int j = 0; j < localParts.size(); j++) {
                   Vector v = new Vector();
  -                for (int j = 0; j < namespaceURIs.size(); j++) {
  -                    QName qName = new QName((String)namespaceURIs.get(j), (String)localParts.get(i));
  -                    if (map.get(qName) != null) {
  -                        v.addAll((Vector)map.get(qName));
  +                for (int k = 0; k < namespaces.size(); k++) {
  +                    QName qName = new QName((String)namespaces.get(k), (String)localParts.get(j));
  +                    if (symbolTable.getHashMap().get(qName) != null) {
  +                        v.addAll((Vector)symbolTable.getHashMap().get(qName));
                       }
                   }
  -                entries.add(v);
  -            }
  -            it = entries.iterator();
  -        }                
  +                collisionCanidates.add(v);
  +            }                            
  +        }
  +        Iterator it = collisionCanidates.iterator();        
           
           while (it.hasNext()) {
               Vector v = new Vector(
                       (Vector) it.next());    // New vector we can temporarily add to it
  -
  +          
               // Remove MessageEntries since they are not mapped
               int index = 0;
   
  
  
  
  1.11      +22 -0     ws-axis/java/src/org/apache/axis/wsdl/toJava/Namespaces.java
  
  Index: Namespaces.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/toJava/Namespaces.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- Namespaces.java	25 Feb 2004 14:02:52 -0000	1.10
  +++ Namespaces.java	24 Oct 2004 19:12:56 -0000	1.11
  @@ -22,6 +22,7 @@
   import java.util.Iterator;
   import java.util.Map;
   import java.util.StringTokenizer;
  +import java.util.Vector;
   
   /**
    * This class is essentially a HashMap of <namespace, package name> pairs with
  @@ -40,6 +41,9 @@
   
       /** Field javaPkgSeparator */
       private static final char javaPkgSeparator = pkgSeparators[0];
  +    
  +    /** Field pkg2Namespaces : reverse mapping of Namespaces */
  +    private Map pkg2NamespacesMap = new HashMap();
   
       /**
        * Method normalizePackageName
  @@ -243,5 +247,23 @@
        */
       public void setDefaultPackage(String defaultPackage) {
           this.defaultPackage = defaultPackage;
  +    }
  +    
  +    public Object put(Object key, Object value) {
  +        // Store pakcage->namespaces vector mapping
  +        Vector v = null;
  +        if (!pkg2NamespacesMap.containsKey(value)) {
  +            v = new Vector();                       
  +        } else {
  +            v = (Vector)pkg2NamespacesMap.get(value);
  +        }
  +        v.add(key);
  +        pkg2NamespacesMap.put(value, v);
  +         
  +        return super.put(key, value);
  +    }
  +    
  +    public Map getPkg2NamespacesMap() {
  +        return pkg2NamespacesMap;
       }
   }    // class Namespaces
  
  
  
  1.2       +3 -1      ws-axis/java/test/wsdl/wsrf/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/test/wsdl/wsrf/build.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- build.xml	20 Oct 2004 13:49:35 -0000	1.1
  +++ build.xml	24 Oct 2004 19:12:56 -0000	1.2
  @@ -61,7 +61,9 @@
                  testcase="no">
           <mapping namespace="http://www.tempuri.org" package="test.wsdl.wsrf"/>
           <mapping namespace="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft-01.wsdl" package="test.wsdl.wsrf.draft"/>
  -        <mapping namespace="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft-01.xsd" package="test.wsdl.wsrf.draft.xsd"/>
  +        <mapping namespace="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft-01.xsd" package="test.wsdl.wsrf.draft"/>
  +        <mapping namespace="http://schemas.xmlsoap.org/ws/2003/03/addressing" package="test.wsdl.wsrf.addressing"/>
  +        <mapping namespace="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-BaseFaults-1.2-draft-01.xsd" package="test.wsdl.wsrf.draft"/>
       </wsdl2java>
   
       <copy todir="${build.dir}/work/test/wsdl/wsrf" overwrite="yes">