axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bu...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/wsdl Utils.java SymbolTable.java JavaStubWriter.java
Date Fri, 30 Nov 2001 15:56:35 GMT
butek       01/11/30 07:56:35

  Modified:    java/src/org/apache/axis/wsdl Utils.java SymbolTable.java
                        JavaStubWriter.java
  Log:
  More isReferenced work.  In a previous commit, I said the following remained to be done:
  1.  Make the writers query this flag before generating files.
  2.  Make sure things are generated even if the WSDL isn't complete (ie., doesn't have
  all of service, binding, portType, message, types).
  3.  Make sure setting noImports works with this new feature.
  
  This commit did 2 & 3.  All that's left is 1.
  
  Revision  Changes    Path
  1.17      +25 -0     xml-axis/java/src/org/apache/axis/wsdl/Utils.java
  
  Index: Utils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/Utils.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- Utils.java	2001/11/27 16:57:25	1.16
  +++ Utils.java	2001/11/30 15:56:35	1.17
  @@ -65,6 +65,7 @@
   import java.net.URL;
   import java.text.Collator;
   import java.util.Arrays;
  +import java.util.HashSet;
   import java.util.Locale;
   import java.util.StringTokenizer;
   import java.util.Vector;
  @@ -629,6 +630,30 @@
           }
           return null;
       }
  +
  +    /**
  +     * This method returns a set of all the nested Types.
  +     * The elements of the returned HashSet are Types.
  +     */
  +    public static HashSet getNestedTypes(Node type, SymbolTable symbolTable) {
  +        HashSet types = new HashSet();
  +        getNestedTypes(type, types, symbolTable);
  +        return types;
  +    } // getNestedTypes
  +
  +    private static void getNestedTypes(
  +            Node type, HashSet types,SymbolTable symbolTable) {
  +        Vector v = Utils.getComplexElementTypesAndNames(type, symbolTable);
  +        if (v != null) {
  +            for (int i = 0; i < v.size(); i+=2) {
  +                if (!types.contains(v.get(i))) {
  +                    types.add(v.get(i));
  +                    getNestedTypes(
  +                            ((Type) v.get(i)).getNode(), types, symbolTable);
  +                }
  +            }
  +        }
  +    } // getNestedTypes
   
       /**
        * Query Java Local Name
  
  
  
  1.9       +143 -26   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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SymbolTable.java	2001/11/30 14:12:52	1.8
  +++ SymbolTable.java	2001/11/30 15:56:35	1.9
  @@ -140,7 +140,7 @@
        */
       protected void add(Definition def, Document doc) throws IOException {
           populate(def, doc);
  -        setReferences();
  +        setReferences(def, doc);
       } // add
   
       /**
  @@ -911,39 +911,105 @@
        * Set each SymTabEntry's isReferenced flag.  The default is false.  If no other symbol
        * references this symbol, then leave it false, otherwise set it to true.
        */
  -    private void setReferences() {
  -        Iterator it = symbolTable.values().iterator();
  -        while (it.hasNext()) {
  -            Vector v = (Vector) it.next();
  -            for (int i = 0; i < v.size(); ++i) {
  -                SymTabEntry entry = (SymTabEntry) v.elementAt(i);
  -                if (entry instanceof MessageEntry) {
  -                    setMessageReferences((MessageEntry) entry);
  -                }
  -                else if (entry instanceof PortTypeEntry) {
  -                    setPortTypeReferences((PortTypeEntry) entry);
  +    private void setReferences(Definition def, Document doc) {
  +        Map stuff = def.getServices();
  +        if (stuff.isEmpty()) {
  +            stuff = def.getBindings();
  +            if (stuff.isEmpty()) {
  +                stuff = def.getPortTypes();
  +                if (stuff.isEmpty()) {
  +                    stuff = def.getMessages();
  +                    if (stuff.isEmpty()) {
  +                        for (int i = 0; i < types.size(); ++i) {
  +                            Type type = (Type) types.get(i);
  +                            setTypeReferences(type, doc);
  +                        }
  +                    }
  +                    else {
  +                        Iterator i = stuff.values().iterator();
  +                        while (i.hasNext()) {
  +                            Message message = (Message) i.next();
  +                            MessageEntry mEntry =
  +                                    getMessageEntry(message.getQName());
  +                            setMessageReferences(mEntry, def, doc);
  +                        }
  +                    }
                   }
  -                else if (entry instanceof BindingEntry) {
  -                    setBindingReferences((BindingEntry) entry);
  +                else {
  +                    Iterator i = stuff.values().iterator();
  +                    while (i.hasNext()) {
  +                        PortType portType = (PortType) i.next();
  +                        PortTypeEntry ptEntry =
  +                                getPortTypeEntry(portType.getQName());
  +                        setPortTypeReferences(ptEntry, def, doc);
  +                    }
                   }
  -                else if (entry instanceof ServiceEntry) {
  -                    setServiceReferences((ServiceEntry) entry);
  +            }
  +            else {
  +                Iterator i = stuff.values().iterator();
  +                while (i.hasNext()) {
  +                    Binding binding = (Binding) i.next();
  +                    BindingEntry bEntry = getBindingEntry(binding.getQName());
  +                    setBindingReferences(bEntry, def, doc);
                   }
               }
           }
  +        else {
  +            Iterator i = stuff.values().iterator();
  +            while (i.hasNext()) {
  +                Service service = (Service) i.next();
  +                ServiceEntry sEntry = getServiceEntry(service.getQName());
  +                setServiceReferences(sEntry, def, doc);
  +            }
  +        }
       } // setReferences
   
  +    private void setTypeReferences(Type entry, Document doc) {
  +        // If we don't want to emit stuff from imported files, only set the
  +        // isReferenced flag if this entry exists in the immediate WSDL file.
  +        Node node = entry.getNode();
  +        if (addImports || node == null || node.getOwnerDocument() == doc) {
  +            entry.setIsReferenced(true);
  +        }
  +
  +        HashSet nestedTypes = Utils.getNestedTypes(node, this);
  +        Iterator it = nestedTypes.iterator();
  +        while (it.hasNext()) {
  +            Type nestedType = (Type) it.next();
  +            if (!nestedType.isReferenced()) {
  +                setTypeReferences(nestedType, doc);
  +            }
  +        }
  +    } // setTypeReferences
  +
       /**
        * Set the isReferenced flag to true on all SymTabEntries that the given Meesage refers
to.
        */
  -    private void setMessageReferences(MessageEntry entry) {
  +    private void setMessageReferences(
  +            MessageEntry entry, Definition def, Document doc) {
  +        // If we don't want to emit stuff from imported files, only set the
  +        // isReferenced flag if this entry exists in the immediate WSDL file.
           Message message = entry.getMessage();
  +        if (addImports) {
  +            entry.setIsReferenced(true);
  +        }
  +        else {
  +            // NOTE:  I thought I could have simply done:
  +            // if (def.getMessage(message.getQName()) != null)
  +            // but that method traces through all imported messages.
  +            Map messages = def.getMessages();
  +            if (messages.containsValue(message)) {
  +                entry.setIsReferenced(true);
  +            }
  +        }
  +
  +        // Set all the message's types
           Iterator parts = message.getParts().values().iterator();
           while (parts.hasNext()) {
               Part part = (Part) parts.next();
               Type type = getTypeEntry(part.getTypeName());
               if (type != null) {
  -                type.setIsReferenced(true);
  +                setTypeReferences(type, doc);
               }
           }
       } // setMessageReference
  @@ -951,8 +1017,25 @@
       /**
        * Set the isReferenced flag to true on all SymTabEntries that the given PortType refers
to.
        */
  -    private void setPortTypeReferences(PortTypeEntry entry) {
  +    private void setPortTypeReferences(
  +            PortTypeEntry entry, Definition def, Document doc) {
  +        // If we don't want to emit stuff from imported files, only set the
  +        // isReferenced flag if this entry exists in the immediate WSDL file.
           PortType portType = entry.getPortType();
  +        if (addImports) {
  +            entry.setIsReferenced(true);
  +        }
  +        else {
  +            // NOTE:  I thought I could have simply done:
  +            // if (def.getPortType(portType.getQName()) != null)
  +            // but that method traces through all imported portTypes.
  +            Map portTypes = def.getPortTypes();
  +            if (portTypes.containsValue(portType)) {
  +                entry.setIsReferenced(true);
  +            }
  +        }
  +
  +        // Set all the portType's messages
           Iterator operations = portType.getOperations().iterator();
   
           // For each operation, query its input, output, and fault messages
  @@ -966,7 +1049,7 @@
                   if (message != null) {
                       MessageEntry mEntry = getMessageEntry(message.getQName());
                       if (mEntry != null) {
  -                        mEntry.setIsReferenced(true);
  +                        setMessageReferences(mEntry, def, doc);
                       }
                   }
               }
  @@ -978,7 +1061,7 @@
                   if (message != null) {
                       MessageEntry mEntry = getMessageEntry(message.getQName());
                       if (mEntry != null) {
  -                        mEntry.setIsReferenced(true);
  +                        setMessageReferences(mEntry, def, doc);
                       }
                   }
               }
  @@ -991,7 +1074,7 @@
                   if (message != null) {
                       MessageEntry mEntry = getMessageEntry(message.getQName());
                       if (mEntry != null) {
  -                        mEntry.setIsReferenced(true);
  +                        setMessageReferences(mEntry, def, doc);
                       }
                   }
               }
  @@ -1001,27 +1084,61 @@
       /**
        * Set the isReferenced flag to true on all SymTabEntries that the given Meesage refers
to.
        */
  -    private void setBindingReferences(BindingEntry entry) {
  +    private void setBindingReferences(
  +            BindingEntry entry, Definition def, Document doc) {
  +        // If we don't want to emit stuff from imported files, only set the
  +        // isReferenced flag if this entry exists in the immediate WSDL file.
           Binding binding = entry.getBinding();
  +        if (addImports) {
  +            entry.setIsReferenced(true);
  +        }
  +        else {
  +            // NOTE:  I thought I could have simply done:
  +            // if (def.getBindng(binding.getQName()) != null)
  +            // but that method traces through all imported bindings.
  +            Map bindings = def.getBindings();
  +            if (bindings.containsValue(binding)) {
  +                entry.setIsReferenced(true);
  +            }
  +        }
  +
  +        // Set all the binding's portTypes
           PortType portType = binding.getPortType();
           PortTypeEntry ptEntry = getPortTypeEntry(portType.getQName());
           if (ptEntry != null) {
  -            ptEntry.setIsReferenced(true);
  +            setPortTypeReferences(ptEntry, def, doc);
           }
       } // setBindingReferences
   
       /**
        * Set the isReferenced flag to true on all SymTabEntries that the given Meesage refers
to.
        */
  -    private void setServiceReferences(ServiceEntry entry) {
  +    private void setServiceReferences(
  +            ServiceEntry entry, Definition def, Document doc) {
  +        // If we don't want to emit stuff from imported files, only set the
  +        // isReferenced flag if this entry exists in the immediate WSDL file.
           Service service = entry.getService();
  +        if (addImports) {
  +            entry.setIsReferenced(true);
  +        }
  +        else {
  +            // NOTE:  I thought I could have simply done:
  +            // if (def.getService(service.getQName()) != null)
  +            // but that method traces through all imported services.
  +            Map services = def.getServices();
  +            if (services.containsValue(service)) {
  +                entry.setIsReferenced(true);
  +            }
  +        }
  +
  +        // Set all the service's bindings
           Iterator ports = service.getPorts().values().iterator();
           while (ports.hasNext()) {
               Port port = (Port) ports.next();
               Binding binding = (Binding) port.getBinding();
               BindingEntry bEntry = getBindingEntry(binding.getQName());
               if (bEntry != null) {
  -                bEntry.setIsReferenced(true);
  +                setBindingReferences(bEntry, def, doc);
               }
           }
       } // setServiceReferences
  
  
  
  1.16      +2 -23     xml-axis/java/src/org/apache/axis/wsdl/JavaStubWriter.java
  
  Index: JavaStubWriter.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/JavaStubWriter.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- JavaStubWriter.java	2001/11/30 14:12:52	1.15
  +++ JavaStubWriter.java	2001/11/30 15:56:35	1.16
  @@ -245,7 +245,8 @@
               if (!types.contains(type)) {
                   types.add(type);
                   if (type.isDefined() && type.getBaseType() == null) {
  -                    types.addAll(getNestedTypes(type.getNode()));
  +                    types.addAll(
  +                            Utils.getNestedTypes(type.getNode(), symbolTable));
                   }
               }
           }
  @@ -297,28 +298,6 @@
               types.add(v.get(i));
           return types;
       } // getTypesInOperation
  -
  -    /**
  -     * This method returns a set of all the nested Types.
  -     * The elements of the returned HashSet are Types.
  -     */
  -    private HashSet getNestedTypes(Node type) {
  -        HashSet types = new HashSet();
  -        getNestedTypes(type, types);
  -        return types;
  -    } // getNestedTypes
  -
  -    private void getNestedTypes(Node type, HashSet types) {
  -        Vector v = Utils.getComplexElementTypesAndNames(type, symbolTable);
  -        if (v != null) {
  -            for (int i = 0; i < v.size(); i+=2) {
  -                if (!types.contains(v.get(i))) {
  -                    types.add(v.get(i));
  -                    getNestedTypes(((Type) v.get(i)).getNode(), types);
  -                }
  -            }
  -        }
  -    } // getNestedTypes
   
       /**
        * This method returns a vector of Types for the parts.
  
  
  

Mime
View raw message