axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/wsdl/fromJava ClassRep.java
Date Tue, 02 Apr 2002 19:07:17 GMT
dims        02/04/02 11:07:17

  Modified:    java     build.xml
               java/src/org/apache/axis/description ServiceDesc.java
               java/src/org/apache/axis/utils JavaUtils.java
               java/src/org/apache/axis/wsdl/fromJava ClassRep.java
  Added:       java/src/org/apache/axis/utils/bytecode Extractor.java
                        ExtractorFactory.java TechTrader.java
  Log:
  Break out code that uses ttbytecode.jar into a "component" such that a typical client won't
need it in his classpath. (Since this is used mainly for introspection on the server-side).
  
  Revision  Changes    Path
  1.127     +1 -0      xml-axis/java/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/build.xml,v
  retrieving revision 1.126
  retrieving revision 1.127
  diff -u -r1.126 -r1.127
  --- build.xml	19 Mar 2002 15:42:01 -0000	1.126
  +++ build.xml	2 Apr 2002 19:07:16 -0000	1.127
  @@ -237,6 +237,7 @@
         <exclude name="**/org/apache/axis/transport/http/AxisServlet.java" unless="servlet.present"/>
         <exclude name="**/org/apache/axis/server/JNDIAxisServerFactory.java" unless="servlet.present"/>
         <exclude name="**/org/apache/axis/security/servlet/*" unless="servlet.present"/>
  +      <exclude name="**/org/apache/axis/utils/bytecode/TechTrader*" unless="tt-bytecode.present"/>
         <exclude name="**/javax/xml/soap/*.java" unless="attachments.present"/>
         <exclude name="**/javax/xml/rpc/handler/soap/*.java" unless="attachments.present"/>
         <exclude name="**/*TestSuite.java" unless="junit.present"/>
  
  
  
  1.12      +3 -2      xml-axis/java/src/org/apache/axis/description/ServiceDesc.java
  
  Index: ServiceDesc.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/description/ServiceDesc.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ServiceDesc.java	1 Apr 2002 20:12:16 -0000	1.11
  +++ ServiceDesc.java	2 Apr 2002 19:07:16 -0000	1.12
  @@ -55,6 +55,7 @@
   package org.apache.axis.description;
   
   import org.apache.axis.utils.JavaUtils;
  +import org.apache.axis.utils.bytecode.ExtractorFactory;
   import org.apache.axis.encoding.TypeMapping;
   import org.apache.axis.encoding.TypeMappingRegistry;
   import org.apache.axis.wsdl.Skeleton;
  @@ -611,8 +612,8 @@
           operation.setReturnType(tm.getTypeQName(method.getReturnType()));
   
           Class [] paramTypes = method.getParameterTypes();
  -        String [] paramNames =
  -                JavaUtils.getParameterNamesFromDebugInfo(method);
  +        String [] paramNames = 
  +                ExtractorFactory.getExtractor().getParameterNamesFromDebugInfo(method);
   
           for (int k = 0; k < paramTypes.length; k++) {
               Class type = paramTypes[k];
  
  
  
  1.39      +1 -97     xml-axis/java/src/org/apache/axis/utils/JavaUtils.java
  
  Index: JavaUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/JavaUtils.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- JavaUtils.java	29 Mar 2002 22:13:05 -0000	1.38
  +++ JavaUtils.java	2 Apr 2002 19:07:17 -0000	1.39
  @@ -55,33 +55,19 @@
   
   package org.apache.axis.utils;
   
  +import org.apache.axis.encoding.Hex;
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   
   import java.lang.reflect.Array;
   import java.lang.reflect.Field;
  -import java.lang.reflect.Method;
  -
   import java.text.Collator;
   import java.text.MessageFormat;
  -
   import java.util.Arrays;
  -import java.util.HashMap;
   import java.util.List;
   import java.util.Locale;
   import java.util.MissingResourceException;
   import java.util.ResourceBundle;
  -import java.util.Hashtable;
  -import java.util.Vector;
  -import java.io.IOException;
  -
  -import org.apache.axis.encoding.Hex;
  -import com.techtrader.modules.tools.bytecode.BCClass;
  -import com.techtrader.modules.tools.bytecode.BCMethod;
  -import com.techtrader.modules.tools.bytecode.Code;
  -import com.techtrader.modules.tools.bytecode.LocalVariableTableAttribute;
  -import com.techtrader.modules.tools.bytecode.Constants;
  -import com.techtrader.modules.tools.bytecode.LocalVariable;
   
   /** Utility class to deal with Java language related issues, such
    * as type conversions.
  @@ -160,14 +146,6 @@
       }
   
       /**
  -     * Cache of tt-bytecode BCClass objects which correspond to particular
  -     * Java classes.
  -     *
  -     * !!! NOTE : AT PRESENT WE DO NOT CLEAN UP THIS CACHE.
  -     */
  -    private static Hashtable ttClassCache = new Hashtable();
  -
  -    /**
        * It the argument to the convert(...) method implements
        * the ConvertCache interface, the convert(...) method
        * will use the set/get methods to store and retrieve
  @@ -879,78 +857,4 @@
           return false;
       }
   
  -    /**
  -     * Get Parameter Names using tt-bytecode
  -     *
  -     * @param method the Java method we're interested in
  -     * @return list of names or null
  -     */
  -    public static String[] getParameterNamesFromDebugInfo(Method method) {
  -        Class c = method.getDeclaringClass();
  -        int numParams = method.getParameterTypes().length;
  -        Vector temp = new Vector();
  -
  -        // Don't worry about it if there are no params.
  -        if (numParams == 0)
  -            return null;
  -
  -        // Try to obtain a tt-bytecode class object
  -        BCClass bclass = (BCClass)ttClassCache.get(c);
  -
  -        if(bclass == null) {
  -            try {
  -                bclass = new BCClass(c);
  -                ttClassCache.put(c, bclass);
  -            } catch (IOException e) {
  -                // what now?
  -            }
  -        }
  -
  -        // Obtain the exact method we're interested in.
  -        BCMethod bmeth = bclass.getMethod(method.getName(),
  -                                          method.getParameterTypes());
  -
  -        if (bmeth == null)
  -            return null;
  -
  -        // Get the Code object, which contains the local variable table.
  -        Code code = bmeth.getCode();
  -        if (code == null)
  -            return null;
  -
  -        LocalVariableTableAttribute attr =
  -                (LocalVariableTableAttribute)code.getAttribute(Constants.ATTR_LOCALS);
  -
  -        if (attr == null)
  -            return null;
  -
  -        // OK, found it.  Now scan through the local variables and record
  -        // the names in the right indices.
  -        LocalVariable [] vars = attr.getLocalVariables();
  -
  -        String [] argNames = new String[numParams + 1];
  -        argNames[0] = null; // don't know return name
  -
  -        // NOTE: we scan through all the variables here, because I have been
  -        // told that jikes sometimes produces unpredictable ordering of the
  -        // local variable table.
  -        for (int j = 0; j < vars.length; j++) {
  -            LocalVariable var = vars[j];
  -            if (! var.getName().equals("this")) {
  -                if(temp.size() < var.getIndex() + 1)
  -                    temp.setSize(var.getIndex() + 1);
  -                temp.setElementAt(var.getName(), var.getIndex());
  -            }
  -        }
  -        int k = 0;
  -        for (int j = 0; j < temp.size(); j++) {
  -            if (temp.elementAt(j) != null) {
  -                k++;
  -                argNames[k] = (String)temp.elementAt(j);
  -                if(k + 1 == argNames.length)
  -                    break;
  -            }
  -        }
  -        return argNames;
  -    }
   }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/utils/bytecode/Extractor.java
  
  Index: Extractor.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.utils.bytecode;
  
  import java.lang.reflect.Method;
  
  /**
   * This class defines a Extractor interface.
   * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
   * @version $Revision: 1.1 $ $Date: 2002/04/02 19:07:17 $
   */
  public interface Extractor {
      public String[] getParameterNamesFromDebugInfo(Method method);
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/utils/bytecode/ExtractorFactory.java
  
  Index: ExtractorFactory.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.utils.bytecode;
  
  import org.apache.axis.utils.JavaUtils;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  /**
   * This class implements a factory to instantiate bytecode Extractor.
   * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
   * @version $Revision: 1.1 $ $Date: 2002/04/02 19:07:17 $
   */
  public class ExtractorFactory {
      protected static Log log =
              LogFactory.getLog(ExtractorFactory.class.getName());
  
      public static Extractor getExtractor() {
          String extractorClassName =
                  System.getProperty("axis.Extractor","org.apache.axis.utils.bytecode.TechTrader");
          log.debug("axis.Extractor:" + extractorClassName);
          Extractor extractor = null;
          try {
              Class extractorClass = Class.forName(extractorClassName);
              if (Extractor.class.isAssignableFrom(extractorClass))
                  return (Extractor) extractorClass.newInstance();
          } catch (Exception e) {
              // If something goes wrong here, should we just fall
              // through and use the default one?
              log.error(JavaUtils.getMessage("exception00"), e);
          }
          return extractor;
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/utils/bytecode/TechTrader.java
  
  Index: TechTrader.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.utils.bytecode;
  
  import com.techtrader.modules.tools.bytecode.BCClass;
  import com.techtrader.modules.tools.bytecode.BCMethod;
  import com.techtrader.modules.tools.bytecode.Code;
  import com.techtrader.modules.tools.bytecode.LocalVariableTableAttribute;
  import com.techtrader.modules.tools.bytecode.Constants;
  import com.techtrader.modules.tools.bytecode.LocalVariable;
  
  import java.lang.reflect.Method;
  import java.util.Vector;
  import java.util.Hashtable;
  import java.io.IOException;
  
  /**
   * This class implements an Extractor using "TechTrader Bytecode Toolkit"
   * from <a href="http://tt-bytecode.sourceforge.net/">tt-bytecode</a>
   * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
   * @version $Revision: 1.1 $ $Date: 2002/04/02 19:07:17 $
   */
  public class TechTrader implements Extractor {
  
      /**
       * Cache of tt-bytecode BCClass objects which correspond to particular
       * Java classes.
       *
       * !!! NOTE : AT PRESENT WE DO NOT CLEAN UP THIS CACHE.
       */
      private static Hashtable ttClassCache = new Hashtable();
  
      /**
       * Get Parameter Names using tt-bytecode
       *
       * @param method the Java method we're interested in
       * @return list of names or null
       */
      public String[] getParameterNamesFromDebugInfo(Method method) {
          Class c = method.getDeclaringClass();
          int numParams = method.getParameterTypes().length;
          Vector temp = new Vector();
  
          // Don't worry about it if there are no params.
          if (numParams == 0)
              return null;
  
          // Try to obtain a tt-bytecode class object
          BCClass bclass = (BCClass)ttClassCache.get(c);
  
          if(bclass == null) {
              try {
                  bclass = new BCClass(c);
                  ttClassCache.put(c, bclass);
              } catch (IOException e) {
                  // what now?
              }
          }
  
          // Obtain the exact method we're interested in.
          BCMethod bmeth = bclass.getMethod(method.getName(),
                                            method.getParameterTypes());
  
          if (bmeth == null)
              return null;
  
          // Get the Code object, which contains the local variable table.
          Code code = bmeth.getCode();
          if (code == null)
              return null;
  
          LocalVariableTableAttribute attr =
                  (LocalVariableTableAttribute)code.getAttribute(Constants.ATTR_LOCALS);
  
          if (attr == null)
              return null;
  
          // OK, found it.  Now scan through the local variables and record
          // the names in the right indices.
          LocalVariable [] vars = attr.getLocalVariables();
  
          String [] argNames = new String[numParams + 1];
          argNames[0] = null; // don't know return name
  
          // NOTE: we scan through all the variables here, because I have been
          // told that jikes sometimes produces unpredictable ordering of the
          // local variable table.
          for (int j = 0; j < vars.length; j++) {
              LocalVariable var = vars[j];
              if (! var.getName().equals("this")) {
                  if(temp.size() < var.getIndex() + 1)
                      temp.setSize(var.getIndex() + 1);
                  temp.setElementAt(var.getName(), var.getIndex());
              }
          }
          int k = 0;
          for (int j = 0; j < temp.size(); j++) {
              if (temp.elementAt(j) != null) {
                  k++;
                  argNames[k] = (String)temp.elementAt(j);
                  if(k + 1 == argNames.length)
                      break;
              }
          }
          return argNames;
      }
  }
  
  
  
  1.27      +94 -102   xml-axis/java/src/org/apache/axis/wsdl/fromJava/ClassRep.java
  
  Index: ClassRep.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/fromJava/ClassRep.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- ClassRep.java	1 Apr 2002 20:12:17 -0000	1.26
  +++ ClassRep.java	2 Apr 2002 19:07:17 -0000	1.27
  @@ -54,31 +54,21 @@
    */
   package org.apache.axis.wsdl.fromJava;
   
  -import com.techtrader.modules.tools.bytecode.BCClass;
  -import com.techtrader.modules.tools.bytecode.BCMethod;
  -import com.techtrader.modules.tools.bytecode.Code;
  -import com.techtrader.modules.tools.bytecode.Constants;
  -import com.techtrader.modules.tools.bytecode.LocalVariable;
  -import com.techtrader.modules.tools.bytecode.LocalVariableTableAttribute;
   import org.apache.axis.utils.JavaUtils;
  +import org.apache.axis.utils.bytecode.ExtractorFactory;
   import org.apache.axis.wsdl.Skeleton;
   
  -import java.io.IOException;
  +import javax.xml.rpc.ParameterMode;
   import java.lang.reflect.Field;
   import java.lang.reflect.Method;
   import java.lang.reflect.Modifier;
   import java.util.HashMap;
  -import java.util.Vector;
   import java.util.List;
  -import java.util.HashMap;
  -
  -import org.apache.axis.utils.JavaUtils;
  -import org.apache.axis.wsdl.Skeleton;
  -import javax.xml.rpc.ParameterMode;
  +import java.util.Vector;
   
   /**
    * ClassRep is the representation of a class used inside the Java2WSDL
  - * emitter.  The information in the ClassRep can be changed by 
  + * emitter.  The information in the ClassRep can be changed by
    * user provided code to affect the emitted wsdl file.
    *
    * If you wish to change the functionality (for example change the
  @@ -88,20 +78,20 @@
    *      and provide new build(...) methods that construct MyClassRep objects.
    *   3) Extend the DefaultFactory class (MyFactory) so that it locates your new Builder
classes.
    *   4) Provide MyFactory as an option when your invoke Java2WSDL.
  - *            
  - *             name  
  + *
  + *             name
    * ClassRep +-+---------> String
    *  | | | | | |
    *  | | | | | | isIntf
    *  | | | | | +---------> boolean
  - *  | | | | | 
  + *  | | | | |
    *  | | | | | modifiers
    *  | | | | +-----------> int (use java.lang.reflect.Modifier to decode)
  - *  | | | |  
  - *  | | | | super 
  + *  | | | |
  + *  | | | | super
    *  | | | +-------------> ClassRep
  - *  | | |  
  - *  | | | interfaces 
  + *  | | |
  + *  | | | interfaces
    *  | | +---------------> ClassRep(s)
    *  | |
    *  | | methods
  @@ -133,7 +123,7 @@
    *
    *           name
    *  ParamRep -----------> String
  - *      | |  
  + *      | |
    *      | |  type
    *      | +-------------> Class
    *      |
  @@ -148,11 +138,11 @@
    *       +--------------> Class
    *
    * Note: all classes extend BaseRep where meta data information can be stored.
  - * 
  + *
    * @author Rich Scheuerle  (scheu@us.ibm.com)
    */
   public class ClassRep extends BaseRep {
  -    
  +
       private String   _name       = "";
       private boolean  _isInterface= false;
       private int      _modifiers  = 0;  // Use java.lang.reflect.Modifer to decode
  @@ -162,11 +152,11 @@
       private Vector   _fields     = new Vector();
       private HashMap  _fieldNames = new HashMap();
       private List     _stopList    = null;
  -    
  +
       /**
        * Constructor
        * Create an empty ClassRep
  -     */ 
  +     */
       public ClassRep() {
       }
   
  @@ -179,10 +169,10 @@
        *                   the declared methods are put in the list
        * @param stopList An optional vector of class names which if inhMethods
        *                    is true, will stop the inheritence search if encountered.
  -     * @param implClass  This is an optional parameter which is a 
  +     * @param implClass  This is an optional parameter which is a
        *                   class that implements or extends cls.  The
        *                   implClass is used to obtain parameter names.
  -     */ 
  +     */
       public ClassRep(Class cls, boolean inhMethods, List stopList) {
           init(cls, inhMethods, stopList, null);
       }
  @@ -200,7 +190,7 @@
           if (isClassOk(superClass)) {
               _super = new ClassRep(superClass, inhMethods, _stopList);
           }
  -        
  +
           // Add the interfaces
           for (int i=0; i < cls.getInterfaces().length; i++) {
               _interfaces.add(new ClassRep(cls.getInterfaces()[i], inhMethods, _stopList));
  @@ -231,15 +221,15 @@
       public void     setFields(Vector v)      { _fields = v; }
   
       /**
  -     * Adds MethodReps to the ClassRep. 
  -     * @param cls the Class    
  +     * Adds MethodReps to the ClassRep.
  +     * @param cls the Class
        * @param inhMethods if true, then the methods array will contain
        *                   methods declared and/or inherited else only
  -     *                   the declared methods are put in the list           
  +     *                   the declared methods are put in the list
        * @param implClass  This is an optional parameter which is a
        *                   class that implements or extends cls.  The
  -     *                   implClass is used to obtain parameter names.            
  -     */ 
  +     *                   implClass is used to obtain parameter names.
  +     */
       protected void addMethods(Class cls, boolean inhMethods, Class implClass) {
           // Constructs a vector of all the public methods
   
  @@ -254,14 +244,14 @@
           Class[] interfaces = cls.getInterfaces();
           for (int i=0; i < interfaces.length; i++) {
               walkInheritanceChain(interfaces[i], inhMethods, implClass);
  -        } 
  -        
  +        }
  +
           return;
       }
   
       /**
        * Return true if we should process this class
  -     */ 
  +     */
       private boolean isClassOk(Class clazz) {
           if (clazz == null)
               return false;
  @@ -277,7 +267,7 @@
               if (name.startsWith("java.") || name.startsWith("javax."))
                   return false;
           }
  -        
  +
           // Didn't find a reason to reject this class
           return true;
       }
  @@ -286,13 +276,13 @@
       /**
        * Iterate up the inheritance chain and construct the list of methods
        * Appends to the _methods class variable.
  -     */ 
  -    private void walkInheritanceChain(Class cls, 
  -                                      boolean inhMethods, 
  +     */
  +    private void walkInheritanceChain(Class cls,
  +                                      boolean inhMethods,
                                         Class implClass) {
           Method[] m;
           Class currentClass = cls;
  -        
  +
           while (isClassOk(currentClass)) {
   
               // get the methods in this class
  @@ -317,12 +307,12 @@
                       _methods.add(methodRep);
                   }
               }
  -            
  +
               // if we don't want inherited methods, don't walk the chain
               if (!inhMethods) {
                   break;
               }
  -            
  +
               // move up the inhertance chain
               currentClass = currentClass.getSuperclass();
           }
  @@ -345,11 +335,11 @@
   
       /**
        * Adds FieldReps to the ClassRep.
  -     * @param cls the Class    
  +     * @param cls the Class
        * A complexType component element will be generated for each FieldRep.
        * This implementation generates FieldReps for public data fields and
        * also for properties exposed by java bean accessor methods.
  -     */ 
  +     */
       protected void addFields(Class cls) {
   
           // Constructs a FieldRep for every public field and
  @@ -406,7 +396,7 @@
                           _fieldNames.put(name.toLowerCase(), fr);
                       }
                   }
  -                
  +
               }
           }
           return;
  @@ -416,9 +406,9 @@
        * Get the list of parameter types for the specified method.
        * This implementation uses the specified type unless it is a holder class,
        * in which case the held type is used.
  -     * @param method is the Method.                          
  -     * @return array of parameter types.                                      
  -     */ 
  +     * @param method is the Method.
  +     * @return array of parameter types.
  +     */
       protected Class[] getParameterTypes(Method method) {
           Class[] types = new Class[method.getParameterTypes().length];
           for (int i=0; i < method.getParameterTypes().length; i++) {
  @@ -438,28 +428,29 @@
        * parameter names from the class file.  If parameter names are not
        * available for the method (perhaps the method is in an interface), the
        * corresponding method in the implClass is queried.
  -     * @param method is the Method to search.                
  -     * @param implClass  If the first search fails, the corresponding  
  -     *                   Method in this class is searched.           
  +     * @param method is the Method to search.
  +     * @param implClass  If the first search fails, the corresponding
  +     *                   Method in this class is searched.
        * @return array of Strings which represent the return name followed by parameter names
  -     */ 
  +     */
       protected String[] getParameterNames(Method method, Class implClass) {
           String[] paramNames = null;
  -        
  +
           paramNames = getParameterNamesFromSkeleton(method);
           if (paramNames != null) {
               return paramNames;
           }
  -        
  -        paramNames = JavaUtils.getParameterNamesFromDebugInfo(method); 
  -        
  +
  +        paramNames =
  +                ExtractorFactory.getExtractor().getParameterNamesFromDebugInfo(method);
  +
           // If failed, try getting a method of the impl class.
           if (paramNames == null && implClass != null) {
               Method m = null;
               try {
                   m = implClass.getDeclaredMethod(method.getName(), method.getParameterTypes());
               } catch (Exception e) {}
  -            if (m == null) { 
  +            if (m == null) {
                   try {
                       m = implClass.getMethod(method.getName(), method.getParameterTypes());
                   } catch (Exception e) {}
  @@ -469,9 +460,10 @@
                   if (paramNames != null) {
                       return paramNames;
                   }
  -                paramNames = JavaUtils.getParameterNamesFromDebugInfo(m); 
  +                paramNames =
  +                    ExtractorFactory.getExtractor().getParameterNamesFromDebugInfo(method);
               }
  -        }            
  +        }
   
           return paramNames;
       }
  @@ -479,17 +471,17 @@
       /**
        * Get the list of parameter names for the specified method.
        * This implementation uses Skeleton.getParameterNames to get the parameter names
  -     * from the class file.  If parameter names are not available, returns null. 
  -     * @param method is the Method to search.                
  +     * from the class file.  If parameter names are not available, returns null.
  +     * @param method is the Method to search.
        * @return array of Strings which represent the return name followed by parameter names
  -     */ 
  +     */
       protected String[] getParameterNamesFromSkeleton(Method method) {
           String[] paramNames = null;
           Class cls = method.getDeclaringClass();
           Class skel = Skeleton.class;
           if (!cls.isInterface() && skel.isAssignableFrom(cls)) {
               try {
  -                // Use the getParameterNameStatic method so that we don't have to new up

  +                // Use the getParameterNameStatic method so that we don't have to new up
                   // an object.
                   Method getParameterName = cls.getMethod("getParameterNameStatic",
                                                            new Class [] {String.class, int.class});
  @@ -504,8 +496,8 @@
                   int numNames = method.getParameterTypes().length + 1; // Parms + return
                   paramNames = new String[numNames];
                   for (int i=0; i < numNames; i++) {
  -                    paramNames[i] = (String) getParameterName.invoke(skelObj, 
  -                                                                     new Object[] {method.getName(),

  +                    paramNames[i] = (String) getParameterName.invoke(skelObj,
  +                                                                     new Object[] {method.getName(),
                                                                                      new
Integer(i-1)});
                   }
               } catch (Exception e) {
  @@ -518,29 +510,29 @@
       /**
        * Get the list of return/parameter modes for the specified method.
        * This implementation uses Skeleton.getParameterModes to get the modes
  -     * If parameter modes are not available 
  +     * If parameter modes are not available
        * for the method (perhaps the method is in an interface), the
        * corresponding method in the implClass is queried.
  -     * @param method is the Method to search.                
  -     * @param implClass  If the first search fails, the corresponding  
  -     *                   Method in this class is searched.           
  +     * @param method is the Method to search.
  +     * @param implClass  If the first search fails, the corresponding
  +     *                   Method in this class is searched.
        * @return array of Strings which represent the return mode followed by parameter modes
  -     */ 
  +     */
       protected ParameterMode[] getParameterModes(Method method, Class implClass) {
           ParameterMode[] paramModes = null;
  -        
  +
           paramModes = getParameterModesFromSkeleton(method);
           if (paramModes != null) {
               return paramModes;
           }
  -                
  +
           // If failed, try getting a method of the impl class
           if (paramModes == null && implClass != null) {
               Method m = null;
               try {
                   m = implClass.getDeclaredMethod(method.getName(), method.getParameterTypes());
               } catch (Exception e) {}
  -            if (m == null) { 
  +            if (m == null) {
                   try {
                       m = implClass.getMethod(method.getName(), method.getParameterTypes());
                   } catch (Exception e) {}
  @@ -548,7 +540,7 @@
               if (m != null) {
                   paramModes = getParameterModesFromSkeleton(m);
               }
  -        }            
  +        }
   
           if (paramModes == null) {
               paramModes = getParameterModes(method);
  @@ -560,17 +552,17 @@
       /**
        * Get the list of return/parameter modes for the specified method.
        * This implementation uses Skeleton.getParameterModes to get the parameter modes
  -     * from the class file.  If parameter modes are not available, returns null. 
  -     * @param method is the Method to search.                
  +     * from the class file.  If parameter modes are not available, returns null.
  +     * @param method is the Method to search.
        * @return array of Strings which represent the return mode followed by parameter modes
  -     */ 
  +     */
       protected ParameterMode[] getParameterModesFromSkeleton(Method method) {
           ParameterMode[] paramModes = null;
           Class cls = method.getDeclaringClass();
           Class skel = Skeleton.class;
           if (!cls.isInterface() && skel.isAssignableFrom(cls)) {
               try {
  -                // Use the getParameterModeStatic method so that we don't have to new up

  +                // Use the getParameterModeStatic method so that we don't have to new up
                   // an object.
                   Method getParameterMode = cls.getMethod("getParameterModeStatic",
                                                            new Class [] {String.class, int.class});
  @@ -585,8 +577,8 @@
                   int numModes = method.getParameterTypes().length + 1; // Parms + return
                   paramModes = new ParameterMode[numModes];
                   for (int i=0; i < numModes; i++) {
  -                    paramModes[i] = (ParameterMode) getParameterMode.invoke(skelObj, 
  -                                                                     new Object[] {method.getName(),

  +                    paramModes[i] = (ParameterMode) getParameterMode.invoke(skelObj,
  +                                                                     new Object[] {method.getName(),
                                                                                      new
Integer(i-1)});
                   }
               } catch (Exception e) {
  @@ -598,9 +590,9 @@
       /**
        * Get the list of return/parameter modes for the specified method.
        * This default implementation assumes IN unless the type is a holder class
  -     * @param method is the Method.                          
  -     * @return array of parameter modes.                                      
  -     */ 
  +     * @param method is the Method.
  +     * @return array of parameter modes.
  +     */
       protected ParameterMode[] getParameterModes(Method method) {
           ParameterMode[] modes = new ParameterMode[method.getParameterTypes().length+1];
           modes[0] = ParameterMode.OUT;
  @@ -617,25 +609,25 @@
   
   
       /**
  -     * Gets additional meta data and sets it on the MethodRep.            
  -     * @param methodRep is the target MethodRep.                
  -     * @param method is the Method to search.                
  -     * @param implClass  If the first search fails, the corresponding  
  -     *                   Method in this class is searched.           
  -     */ 
  +     * Gets additional meta data and sets it on the MethodRep.
  +     * @param methodRep is the target MethodRep.
  +     * @param method is the Method to search.
  +     * @param implClass  If the first search fails, the corresponding
  +     *                   Method in this class is searched.
  +     */
       protected void getMethodMetaData(MethodRep methodRep, Method method, Class implClass)
{
  -        
  +
           if (getMethodMetaDataFromSkeleton(methodRep, method)) {
               return;
           }
  -                
  +
           // If failed, try getting a method of the impl class
           if (implClass != null) {
               Method m = null;
               try {
                   m = implClass.getDeclaredMethod(method.getName(), method.getParameterTypes());
               } catch (Exception e) {}
  -            if (m == null) { 
  +            if (m == null) {
                   try {
                       m = implClass.getMethod(method.getName(), method.getParameterTypes());
                   } catch (Exception e) {}
  @@ -643,17 +635,17 @@
               if (m != null) {
                   getMethodMetaDataFromSkeleton(methodRep, m);
               }
  -        }            
  +        }
           return;
       }
   
   
       /**
  -     * Gets additional meta data and sets it on the MethodRep.            
  -     * @param methodRep is the target MethodRep.                
  -     * @param method is the Method to search.               
  +     * Gets additional meta data and sets it on the MethodRep.
  +     * @param methodRep is the target MethodRep.
  +     * @param method is the Method to search.
        * @return true if the method is part of a skeleton.
  -     */ 
  +     */
       protected boolean getMethodMetaDataFromSkeleton(MethodRep methodRep, Method method)
{
           Class cls = method.getDeclaringClass();
           Class skel = Skeleton.class;
  @@ -702,7 +694,7 @@
       protected boolean isJavaBeanNormal(Class cls, String name, Class type) {
           if ((name == null) || (name.length() == 0))
               return false;
  -        
  +
           try {
               String propName = name.substring(0,1).toUpperCase()
                   + name.substring(1);
  @@ -723,7 +715,7 @@
               mod = m.getModifiers();
               if (!Modifier.isPublic(mod)) {
                   return false;
  -            }       
  +            }
           }
           catch (NoSuchMethodException ex) {
               return false;
  @@ -764,7 +756,7 @@
               mod = m.getModifiers();
               if (!Modifier.isPublic(mod)) {
                   return false;
  -            }       
  +            }
           }
           catch (NoSuchMethodException ex) {
               return false;
  
  
  

Mime
View raw message