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/toJava JavaServiceImplWriter.java
Date Tue, 27 Aug 2002 14:52:48 GMT
butek       2002/08/27 07:52:48

  Modified:    java/src/org/apache/axis/client Service.java
               java/src/org/apache/axis/wsdl/toJava
                        JavaServiceImplWriter.java
  Log:
  I fixed bugzilla http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11825.
  It says that generated Locator classes should override all methods where
  the Service method would throw an exception if it doesn't have the WSDL.
  Locator classes DO NOT have the WSDL, but they were generated from
  WSDL, so they have all the necessary info, so calls to those methods
  shouldn't fail.
  
  Along the way I also noticed that Service.getPorts was returning the
  wrong thing.  It was returning an Iterator of javax.wsdl.Ports when it
  SHOULD be returning an Iterator of port QNames.  I guess this isn't a
  tested feature!
  
  Revision  Changes    Path
  1.72      +8 -7      xml-axis/java/src/org/apache/axis/client/Service.java
  
  Index: Service.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/Service.java,v
  retrieving revision 1.71
  retrieving revision 1.72
  diff -u -r1.71 -r1.72
  --- Service.java	23 Aug 2002 15:05:14 -0000	1.71
  +++ Service.java	27 Aug 2002 14:52:48 -0000	1.72
  @@ -581,20 +581,21 @@
       }
   
       /**
  -     * Returns an Iterator that can be used to get all of the ports
  -     * specified in the WSDL file associated with this Service (if there
  -     * is a WSDL file).
  +     * Returns an <code>Iterator</code> for the list of
  +     * <code>QName</code>s of service endpoints grouped by this
  +     * service
        *
  -     * @return Iterator The ports specified in the WSDL file
  -     * @throws ServiceException If this Service class does not have access to the
  -     *         required WSDL metadata
  +     * @return Returns <code>java.util.Iterator</code> with elements
  +     *     of type <code>javax.xml.namespace.QName</code>
  +     * @throws ServiceException If this Service class does not
  +     *     have access to the required WSDL metadata
        */
       public Iterator getPorts() throws ServiceException {
           if (wsdlService == null || wsdlService.getPorts() == null){
               // Return an empty iterator;
               return new Vector().iterator();
           }
  -        return wsdlService.getPorts().values().iterator();
  +        return wsdlService.getPorts().keySet().iterator();
       }
   
       /**
  
  
  
  1.22      +144 -55   xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaServiceImplWriter.java
  
  Index: JavaServiceImplWriter.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaServiceImplWriter.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- JavaServiceImplWriter.java	19 Aug 2002 15:35:21 -0000	1.21
  +++ JavaServiceImplWriter.java	27 Aug 2002 14:52:48 -0000	1.22
  @@ -64,6 +64,8 @@
   import java.util.Map;
   import java.util.Vector;
   
  +import javax.xml.namespace.QName;
  +
   import javax.wsdl.Binding;
   import javax.wsdl.Port;
   import javax.wsdl.Service;
  @@ -196,65 +198,105 @@
                   throw new IOException(JavaUtils.getMessage("emitFail03",
                           new String[] {portName, className, address}));
               }
  +            writeAddressInfo(pw, portName, address, p);
  +            String wsddServiceName = portName + "WSDDServiceName";
  +            writeWSDDServiceNameInfo(pw, wsddServiceName, portName);
  +            writeGetPortName(pw, bindingType, portName);
  +            writeGetPortNameURL(pw, bindingType, portName, stubClass,
  +                    wsddServiceName);
  +        }
  +        writeGetPortClass(pw, getPortIfaces, getPortStubClasses,
  +                getPortPortNames, printGetPortNotice);
  +        writeGetPortQNameClass(pw);
  +        writeGetServiceName(pw, sEntry.getQName());
  +        writeGetPorts(pw, getPortPortNames);
  +    } // writeFileBody
   
  -            // Write the private address info for this port
  -            pw.println();
  -            pw.println("    // " + JavaUtils.getMessage("getProxy00", portName));
  -            writeComment(pw, p.getDocumentationElement());
  -            pw.println("    private final java.lang.String " + portName + "_address = \""
+ address + "\";");
  -
  -            // Write the public address getter for this port
  -            pw.println();
  -            pw.println("    public java.lang.String get" + portName + "Address() {" );
  -            pw.println("        return " + portName + "_address;" );
  -            pw.println("    }" );
  -            pw.println();
  +    /**
  +     * Write the private address field for this port and the public getter for it.
  +     */
  +    protected void writeAddressInfo(PrintWriter pw, String portName,
  +            String address, Port p) {
  +        // Write the private address field for this port
  +        pw.println();
  +        pw.println("    // " + JavaUtils.getMessage("getProxy00", portName));
  +        writeComment(pw, p.getDocumentationElement());
  +        pw.println("    private final java.lang.String " + portName + "_address = \"" +
address + "\";");
   
  -            // Write the private WSDD service name for this port
  -            String wsddServiceName = portName + "WSDDServiceName";
  -            pw.println("    // " + JavaUtils.getMessage("wsddServiceName00"));
  -            pw.println("    private java.lang.String " + wsddServiceName + " = \"" + portName
+ "\";");
  -            pw.println();
  -
  -            // Write the public accessors for the WSDD service name for this port
  -            pw.println("    public java.lang.String get" + wsddServiceName + "() {");
  -            pw.println("        return " + wsddServiceName + ";");
  -            pw.println("    }");
  -            pw.println();
  -            pw.println("    public void set" + wsddServiceName + "(java.lang.String name)
{");
  -            pw.println("        " + wsddServiceName + " = name;");
  -            pw.println("    }");
  -            pw.println();
  -
  -            // Write the get<portName>() method
  -            pw.println("    public " + bindingType + " get" + portName + "() throws " +
javax.xml.rpc.ServiceException.class.getName() + " {");
  -            pw.println("       java.net.URL endpoint;");
  -            pw.println("        try {");
  -            pw.println("            endpoint = new java.net.URL(" + portName + "_address);");
  -            pw.println("        }");
  -            pw.println("        catch (java.net.MalformedURLException e) {");
  -            pw.println("            return null; // " +
  -                    JavaUtils.getMessage("unlikely00"));
  -            pw.println("        }");
  -            pw.println("        return get" + portName + "(endpoint);");
  -            pw.println("    }");
  -            pw.println();
  +        // Write the public address getter for this field
  +        pw.println();
  +        pw.println("    public java.lang.String get" + portName + "Address() {" );
  +        pw.println("        return " + portName + "_address;" );
  +        pw.println("    }" );
  +        pw.println();
   
  -            // Write the get<portName>(URL) method
  -            pw.println("    public " + bindingType + " get" + portName + "(java.net.URL
portAddress) throws " + javax.xml.rpc.ServiceException.class.getName() + " {");
  -            pw.println("        try {");
  -            pw.println("            " + stubClass + " _stub = new " + stubClass + "(portAddress,
this);");
  -            pw.println("            _stub.setPortName(get" + wsddServiceName + "());");
  -            pw.println("            return _stub;");
  -            pw.println("        }");
  -            pw.println("        catch (org.apache.axis.AxisFault e) {");
  -            pw.println("            return null; // ???");
  -            pw.println("        }");
  -            pw.println("    }");
  -        }
  +    } // writeAddressInfo
  +
  +    /**
  +     * Write the private WSDD service name field and the public accessors for it.
  +     */
  +    protected void writeWSDDServiceNameInfo(PrintWriter pw,
  +            String wsddServiceName, String portName) {
  +        // Write the private WSDD service name field
  +        pw.println("    // " + JavaUtils.getMessage("wsddServiceName00"));
  +        pw.println("    private java.lang.String " + wsddServiceName + " = \"" + portName
+ "\";");
  +        pw.println();
   
  -        // Build the getPort method.
  +        // Write the public accessors for the WSDD service name
  +        pw.println("    public java.lang.String get" + wsddServiceName + "() {");
  +        pw.println("        return " + wsddServiceName + ";");
  +        pw.println("    }");
  +        pw.println();
  +        pw.println("    public void set" + wsddServiceName + "(java.lang.String name) {");
  +        pw.println("        " + wsddServiceName + " = name;");
  +        pw.println("    }");
           pw.println();
  +    } // writeWSDDServiceNameInfo
  +
  +    /**
  +     * Write the get<portName>() method.
  +     */
  +    protected void writeGetPortName(PrintWriter pw, String bindingType,
  +            String portName) {
  +        pw.println("    public " + bindingType + " get" + portName + "() throws " + javax.xml.rpc.ServiceException.class.getName()
+ " {");
  +        pw.println("       java.net.URL endpoint;");
  +        pw.println("        try {");
  +        pw.println("            endpoint = new java.net.URL(" + portName + "_address);");
  +        pw.println("        }");
  +        pw.println("        catch (java.net.MalformedURLException e) {");
  +        pw.println("            return null; // " +
  +                   JavaUtils.getMessage("unlikely00"));
  +        pw.println("        }");
  +        pw.println("        return get" + portName + "(endpoint);");
  +        pw.println("    }");
  +        pw.println();
  +    } // writeGetPortName
  +
  +    /**
  +     * Write the get<portName>(URL) method.
  +     */
  +    protected void writeGetPortNameURL(PrintWriter pw, String bindingType,
  +            String portName, String stubClass, String wsddServiceName) {
  +        pw.println("    public " + bindingType + " get" + portName + "(java.net.URL portAddress)
throws " + javax.xml.rpc.ServiceException.class.getName() + " {");
  +        pw.println("        try {");
  +        pw.println("            " + stubClass + " _stub = new " + stubClass + "(portAddress,
this);");
  +        pw.println("            _stub.setPortName(get" + wsddServiceName + "());");
  +        pw.println("            return _stub;");
  +        pw.println("        }");
  +        pw.println("        catch (org.apache.axis.AxisFault e) {");
  +        pw.println("            return null; // ???");
  +        pw.println("        }");
  +        pw.println("    }");
  +        pw.println();
  +    } // writeGetPortNameURL
  +
  +    /**
  +     * Write the getPort(Class serviceInterfaceWriter) method.
  +     */
  +    protected void writeGetPortClass(PrintWriter pw, Vector getPortIfaces,
  +            Vector getPortStubClasses, Vector getPortPortNames,
  +            boolean printGetPortNotice)
  +    {
           pw.println("    /**");
           pw.println("     * " + JavaUtils.getMessage("getPortDoc00"));
           pw.println("     * " + JavaUtils.getMessage("getPortDoc01"));
  @@ -290,6 +332,53 @@
           }
           pw.println("    }");
           pw.println();
  -    } // writeFileBody
  +
  +    } // writeGetPortClass
  +
  +    /**
  +     * Write the getPort(QName portName, Class serviceInterfaceWriter) method.
  +     */
  +    protected void writeGetPortQNameClass(PrintWriter pw) {
  +        pw.println("    /**");
  +        pw.println("     * " + JavaUtils.getMessage("getPortDoc00"));
  +        pw.println("     * " + JavaUtils.getMessage("getPortDoc01"));
  +        pw.println("     * " + JavaUtils.getMessage("getPortDoc02"));
  +        pw.println("     */");
  +        pw.println("    public java.rmi.Remote getPort(javax.xml.namespace.QName portName,
Class serviceEndpointInterface) throws " + javax.xml.rpc.ServiceException.class.getName()
+ " {");
  +        pw.println("        java.rmi.Remote _stub = getPort(serviceEndpointInterface);");
  +        pw.println("        ((org.apache.axis.client.Stub) _stub).setPortName(portName);");
  +        pw.println("        return _stub;");
  +        pw.println("    }");
  +        pw.println();
  +    } // writeGetPortQNameClass
  +
  +    /**
  +     * Write the getServiceName method.
  +     */
  +    protected void writeGetServiceName(PrintWriter pw, QName qname) {
  +        pw.println("    public javax.xml.namespace.QName getServiceName() {");
  +        pw.println("        return " + Utils.getNewQName(qname) + ";");
  +        pw.println("    }");
  +        pw.println();
  +    } // writeGetServiceName
  +
  +    /**
  +     * Write the getPorts method.
  +     */
  +    protected void writeGetPorts(PrintWriter pw, Vector portNames) {
  +        pw.println("    private java.util.HashSet ports = null;");
  +        pw.println();
  +        pw.println("    public java.util.Iterator getPorts() {");
  +        pw.println("        if (ports == null) {");
  +        pw.println("            ports = new java.util.HashSet();");
  +        for (int i = 0; i < portNames.size(); ++i) {
  +            pw.println("            ports.add(new javax.xml.namespace.QName(\"" +
  +                    portNames.get(i) + "\"));");
  +        }
  +        pw.println("        }");
  +        pw.println("        return ports.iterator();");
  +        pw.println("    }");
  +        pw.println();
  +    } // writeGetPorts
   
   } // class JavaServiceImplWriter
  
  
  

Mime
View raw message