axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sc...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/wsdl/fromJava Emitter.java Types.java todo.txt
Date Tue, 11 Dec 2001 19:47:01 GMT
scheu       01/12/11 11:47:01

  Modified:    java/src/org/apache/axis/providers/java JavaProvider.java
               java/src/org/apache/axis/wsdl Java2WSDL.java
               java/src/org/apache/axis/wsdl/fromJava Emitter.java
                        Types.java todo.txt
  Removed:     java/src/org/apache/axis/utils WSDLUtils.java
  Log:
  Added the code to hook the ?wsdl runtime wsdl generation to the new Java2WSDL Emitter.
  Removed the utils.WSDLUtils.java class which used to perform this function.
  
  Revision  Changes    Path
  1.29      +11 -3     xml-axis/java/src/org/apache/axis/providers/java/JavaProvider.java
  
  Index: JavaProvider.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/providers/java/JavaProvider.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- JavaProvider.java	2001/12/08 23:29:43	1.28
  +++ JavaProvider.java	2001/12/11 19:47:00	1.29
  @@ -65,8 +65,8 @@
   import org.apache.axis.providers.BasicProvider;
   import org.apache.axis.utils.AxisClassLoader;
   import org.apache.axis.utils.JavaUtils;
  -import org.apache.axis.utils.WSDLUtils;
   import org.apache.axis.utils.cache.JavaClass;
  +import org.apache.axis.wsdl.fromJava.Emitter;
   import org.apache.log4j.Category;
   import org.w3c.dom.Document;
   
  @@ -302,15 +302,23 @@
               String url = msgContext.getStrProp(MessageContext.TRANS_URL);
               String urn = (String)msgContext.getTargetService();
               String description = "Service";
  -            Document doc = WSDLUtils.writeWSDLDoc(cls, allowedMethods,
  -                    url, urn, description, msgContext);
   
  +            Emitter emitter = new Emitter();
  +            emitter.setClsSmart(cls,url);
  +            emitter.setAllowedMethods(allowedMethods);
  +            emitter.setIntfNamespace(url);
  +            emitter.setLocationUrl(url);
  +            emitter.setReg(msgContext.getTypeMappingRegistry());
  +            Document  doc = emitter.emit(Emitter.MODE_ALL);
  +
               msgContext.setProperty("WSDL", doc);
           } catch (Exception e) {
               throw AxisFault.makeFault(e);
           }
   
       }
  +
  +
   
       public void undo(MessageContext msgContext) {
           category.debug(JavaUtils.getMessage("enter00", "RPCDispatchHandler::undo") );
  
  
  
  1.2       +1 -1      xml-axis/java/src/org/apache/axis/wsdl/Java2WSDL.java
  
  Index: Java2WSDL.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/Java2WSDL.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Java2WSDL.java	2001/12/11 15:13:55	1.1
  +++ Java2WSDL.java	2001/12/11 19:47:00	1.2
  @@ -273,7 +273,7 @@
               }
   
               // Find the class using the name and optionally the classDir
  -            emitter.setCls(className, classDir);
  +            emitter.setCls(className, "");
   
               // Generate a full wsdl, or interface & implementation wsdls
               if (wsdlImplFilename == null) {
  
  
  
  1.2       +80 -73    xml-axis/java/src/org/apache/axis/wsdl/fromJava/Emitter.java
  
  Index: Emitter.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/fromJava/Emitter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Emitter.java	2001/12/11 15:13:55	1.1
  +++ Emitter.java	2001/12/11 19:47:00	1.2
  @@ -185,11 +185,11 @@
        * mode 1: Interface
        * mode 2: Implementation
        * 
  -     * @param filename  WSDL
        * @param mode generation mode - all, interface, implementation                   
 
  +     * @return Document                     
        * @throws Exception
        */
  -    public void emit(String filename, int mode) throws Exception {
  +    public Document emit(int mode) throws Exception {
           Document doc = null;
           Definition def = null;
           switch (mode) {
  @@ -211,6 +211,24 @@
                   throw new Exception ("unrecognized output WSDL mode"); 
           }
   
  +        // Return the document
  +        return doc;
  +    }
  +
  +    /**
  +     * 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 = emit(mode);
  +
           // Supply a reasonable file name if not supplied
           if (filename == null) {
               filename = getServiceName();
  @@ -721,6 +739,66 @@
           this.cls = cls;
       }
   
  +    /**
  +     * Sets the <code>Class</code> to export.
  +     * If the class looks like a skeleton class, do some searching to find the
  +     * interface class.  
  +     * @param cls the <code>Class</code> to export
  +     * @param name service name
  +     */
  +    public void setClsSmart(Class cls, String serviceName) {
  +
  +        if (cls == null || serviceName == null)
  +            return;
  +
  +        // Strip off \ and / from serviceName
  +        if (serviceName.lastIndexOf('/') > 0) {
  +            serviceName = serviceName.substring(serviceName.lastIndexOf('/') + 1);
  +        } else if (serviceName.lastIndexOf('\\') > 0) {
  +            serviceName = serviceName.substring(serviceName.lastIndexOf('\\') + 1);
  +        } 
  +
  +        // Get the constructors of the class
  +        java.lang.reflect.Constructor[] constructors = cls.getDeclaredConstructors();
  +        Class intf = null;
  +        for (int i=0; i < constructors.length && intf == null; i++) {
  +            Class[] parms = constructors[i].getParameterTypes();
  +            // If the constructor has a single parameter that is an interface which
  +            // matches the serviceName, then use this as the interface class.
  +            if (parms.length == 1 &&
  +                parms[0].isInterface() &&
  +                parms[0].getName() != null &&
  +                Types.getLocalNameFromFullName(parms[0].getName()).equals(serviceName))
{
  +                intf = parms[0];
  +            }
  +        }
  +        if (intf != null)
  +            setCls(intf);
  +        else
  +            setCls(cls);
  +    }
  +
  +    /**
  +     * Sets the <code>Class</code> to export
  +     * @param className the name of the <code>Class</code> to export
  +     * @param classDir the directory containing the class (optional)
  +     */
  +    public void setCls(String className, String classDir) {
  +        try {
  +            cls = Class.forName(className);
  +        }
  +        catch (Exception ex) {
  +            /** @todo ravi: use classDir to load class directly into the class loader
  +             *  The case for it is that one can create a new directory, drop some source,
compile and use a
  +             *  WSDL gen tool to generate wsdl - without editing the Wsdl gen tool's classpath
  +             *  Assuming all of the classes are either under classDir or otherwise in the
classpath
  +             *
  +             *  Would this be useful?
  +             *  */
  +            ex.printStackTrace();
  +        }
  +    }
  +
      /**
        * Returns the interface namespace
        * @return interface target namespace
  @@ -754,28 +832,6 @@
       }
   
       /**
  -     * Sets the <code>Class</code> to export
  -     * @param className the name of the <code>Class</code> to export
  -     * @param classDir the directory containing the class (optional)
  -     */
  -    public void setCls(String className, String classDir) {
  -        try {
  -            cls = Class.forName(className);
  -        }
  -        catch (Exception ex) {
  -            /** @todo ravi: use classDir to load class directly into the class loader
  -             *  The case for it is that one can create a new directory, drop some source,
compile and use a
  -             *  WSDL gen tool to generate wsdl - without editing the Wsdl gen tool's classpath
  -             *  Assuming all of the classes are either under classDir or otherwise in the
classpath
  -             *
  -             *  Would this be useful?
  -             *  */
  -            ex.printStackTrace();
  -        }
  -    }
  -
  -
  -    /**
        * Returns a list of a space separated list of methods to export
        * @return a space separated list of methods to export
        */
  @@ -912,53 +968,4 @@
           this.reg = reg;
       }
   
  -
  -    /**
  -     * @todo: this is the logic to hook into the existing WSDLUtils code.
  -     * WSDLUtils should be changed to invoke Emitter using the same interface
  -     * as Java2Wsdl.  Remove this method after WSDLUtils is changed.
  -     * 
  -     * Generates a WSDL document for a given <code>Class</code> and
  -     * a space separated list of methods at runtime
  -     *
  -     * @param cls <code>Class</code> object
  -     * @param allowedMethods space separated methods
  -     * @param locationUrl location of the service
  -     * @param serviceUrn service URN
  -     * @param description description of service
  -     * @param msgContext <code>MsgContext</code> of the service invocation
  -     * @return WSDL <code>Document</code>
  -     * @throws Exception
  -     */
  -        /** @todo ravi: fix targetNamespace for runtime generation
  -        // This is set to auto generated or user defined targetNamespace
  -        // need to figure out what it should be in the runtime situation
  -        // till we revisit, leave it as it was in WSDLUtils **/
  -
  -    /*    
  -    public static Document writeWSDLDoc(Class cls,
  -                                    String allowedMethods,
  -                                    String locationUrl,
  -                                    String serviceUrn,
  -                                    String description,
  -                                    MessageContext msgContext) throws Exception
  -    {
  -        Emitter emitter = new Emitter();
  -        emitter.setCls(cls);
  -        emitter.setAllowedMethods(allowedMethods);
  -        emitter.setLocationUrl(locationUrl);
  -
  -        emitter.setTargetNamespace(locationUrl);
  -
  -        emitter.setServiceUrn(serviceUrn);
  -        emitter.setDescription(description);
  -        String targetService = msgContext.getTargetService();
  -        if ((targetService == null) || ("JWSProcessor".equals(targetService)))
  -            targetService = "";
  -        emitter.setTargetService(targetService);
  -        emitter.setReg(msgContext.getTypeMappingRegistry());
  -        Document doc = WSDLFactory.newInstance().newWSDLWriter().getDocument(emitter.emit());
  -        return doc;
  -    }
  -    */
   }
  
  
  
  1.2       +2 -2      xml-axis/java/src/org/apache/axis/wsdl/fromJava/Types.java
  
  Index: Types.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/fromJava/Types.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Types.java	2001/12/11 15:13:55	1.1
  +++ Types.java	2001/12/11 19:47:01	1.2
  @@ -222,7 +222,7 @@
        * @param full input class name
        * @return package name
        */
  -    private String getPackageNameFromFullName(String full) {
  +    public static String getPackageNameFromFullName(String full) {
           if (full.lastIndexOf('.') < 0)
               return "";
           else 
  @@ -234,7 +234,7 @@
        * @param full input class name
        * @return package name
        */
  -    private String getLocalNameFromFullName(String full) {
  +    public static String getLocalNameFromFullName(String full) {
           if (full.lastIndexOf('.') < 0)
               return full;
           else 
  
  
  
  1.2       +1 -0      xml-axis/java/src/org/apache/axis/wsdl/fromJava/todo.txt
  
  Index: todo.txt
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/fromJava/todo.txt,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- todo.txt	2001/12/11 15:13:55	1.1
  +++ todo.txt	2001/12/11 19:47:01	1.2
  @@ -43,6 +43,7 @@
   -------
   * Style/use support: rpc/encoded, document/literal, rpc/literal and document/encoded
   * Switch the runtime WSDL generation to use Java2WSDL
  +   - Rich: Done.  But someone may want to add ability to get interface/implementation wsdl.
   
   
   
  
  
  

Mime
View raw message