gdaniels    02/02/14 14:46:34

  Modified:    java/samples/echo TestClient.java
               java/samples/transport FileTest.java
               java/src/org/apache/axis MessageContext.java
               java/src/org/apache/axis/client Call.java ServiceClient.java
               java/src/org/apache/axis/utils LockableHashtable.java
               java/src/org/apache/axis/wsdl/fromJava ClassRep.java
  Added:       java/lib bcel.jar
  Removed:     java/src/org/apache/axis/utils JavapUtils.java
  Log:
  Two changes:
  
  1) Introduce a slight performance improvement by allowing the non-field
      properties of the Call object to be automatically located by the
      MessageContext's getProperty() call.  If the given property isn't found
      in the MC's bag, it will automatically ask any "parent" Hashtable for the
      same key.
  
  2) Don't use javap for obtaining parameter name information, since it was
      too heavyweight and required spawning another process.  Instead, check
      in a copy of the BCEL (http://jakarta.apache.org/bcel) and use those
      APIs in-proc.
  
  Revision  Changes    Path
  1.1                  xml-axis/java/lib/bcel.jar
  
        <<Binary file>>
  
  
  1.51      +1 -1      xml-axis/java/samples/echo/TestClient.java
  
  Index: TestClient.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/samples/echo/TestClient.java,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- TestClient.java   8 Feb 2002 23:18:53 -0000       1.50
  +++ TestClient.java   14 Feb 2002 22:46:34 -0000      1.51
  @@ -185,7 +185,7 @@
               call.setSOAPActionURI( action );
   
               // safety first
  -            call.setProperty(Call.TIMEOUT, "60000");
  +            call.setTimeout(new Integer(60000));
   
               // issue the request
               call.setOperationName( new QName("http://soapinterop.org/";, 
method.trim()) );
  
  
  
  1.26      +1 -1      xml-axis/java/samples/transport/FileTest.java
  
  Index: FileTest.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/samples/transport/FileTest.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- FileTest.java     8 Feb 2002 22:14:11 -0000       1.25
  +++ FileTest.java     14 Feb 2002 22:46:34 -0000      1.26
  @@ -54,7 +54,7 @@
           call.setTransport( new FileTransport() );
           call.setUsername(opts.getUser() );
           call.setPassword(opts.getPassword() );
  -        call.setProperty(Call.TIMEOUT, "10000");
  +        call.setTimeout(new Integer(10000));
   
           Float res = new Float(0.0F);
           res = (Float) call.invoke( new Object[] {symbol} );
  
  
  
  1.74      +8 -2      xml-axis/java/src/org/apache/axis/MessageContext.java
  
  Index: MessageContext.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/MessageContext.java,v
  retrieving revision 1.73
  retrieving revision 1.74
  diff -u -r1.73 -r1.74
  --- MessageContext.java       8 Feb 2002 22:14:11 -0000       1.73
  +++ MessageContext.java       14 Feb 2002 22:46:34 -0000      1.74
  @@ -61,6 +61,7 @@
   import org.apache.axis.handlers.soap.SOAPService;
   import org.apache.axis.session.Session;
   import org.apache.axis.utils.JavaUtils;
  +import org.apache.axis.utils.LockableHashtable;
   import org.apache.log4j.Category;
   
   import java.util.Hashtable;
  @@ -156,7 +157,7 @@
        * Storage for an arbitrary bag of properties associated with this
        * MessageContext.
        */
  -    private Hashtable bag ;
  +    private LockableHashtable bag ;
       
       /**
        * These variables are logically part of the bag, but are separated
  @@ -639,7 +640,7 @@
           }
           else {
               if (bag == null) {
  -                bag = new Hashtable();
  +                bag = new LockableHashtable();
               }
               bag.put(name, value);
           }
  @@ -684,6 +685,11 @@
           else {
               return null;
           }
  +    }
  +    
  +    public void setPropertyParent(Hashtable parent)
  +    {
  +        bag.setParent(parent);
       }
   
       /**
  
  
  
  1.73      +9 -18     xml-axis/java/src/org/apache/axis/client/Call.java
  
  Index: Call.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/Call.java,v
  retrieving revision 1.72
  retrieving revision 1.73
  diff -u -r1.72 -r1.73
  --- Call.java 12 Feb 2002 12:46:23 -0000      1.72
  +++ Call.java 14 Feb 2002 22:46:34 -0000      1.73
  @@ -157,6 +157,7 @@
       private boolean            useSOAPAction   = false;
       private String             SOAPActionURI   = null;
       private String             encodingStyle   = Constants.URI_CURRENT_SOAP_ENC;
  +    private Integer            timeout         = null;
   
   
       // Our Transport, if any
  @@ -170,7 +171,6 @@
       private Vector             myHeaders       = null;
   
       public static final String SEND_TYPE_ATTR    = "send_type_attr" ;
  -    public static final String TIMEOUT           = "timeout" ;
       public static final String TRANSPORT_NAME    = "transport_name" ;
       public static final String TRANSPORT_PROPERTY= "java.protocol.handler.pkgs";
   
  @@ -583,6 +583,13 @@
           }
       }
   
  +    public Integer getTimeout() {
  +        return timeout;
  +    }
  +
  +    public void setTimeout(Integer timeout) {
  +        this.timeout = timeout;
  +    }
       //
       // end properties code.
       //
  @@ -1573,23 +1580,7 @@
            *   security.auth.subject
            */
           if (myProperties != null) {
  -            Enumeration enum = myProperties.keys();
  -            while (enum.hasMoreElements()) {
  -                String name = (String) enum.nextElement();
  -                Object value = myProperties.get(name);
  -                int    intValue = 0 ;
  -
  -                if ( name.equals( TIMEOUT ) ) {
  -                    if ( value instanceof Integer )
  -                        intValue = ((Integer)value).intValue();
  -                    else
  -                        intValue = Integer.parseInt((String)value);
  -
  -                    msgContext.setTimeout( intValue );
  -                }
  -                else // Just pass the property through to the message context
  -                    msgContext.setProperty(name, value);
  -            }
  +            msgContext.setPropertyParent(myProperties);
           }
   
           // Determine client target service
  
  
  
  1.74      +2 -2      xml-axis/java/src/org/apache/axis/client/ServiceClient.java
  
  Index: ServiceClient.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/ServiceClient.java,v
  retrieving revision 1.73
  retrieving revision 1.74
  diff -u -r1.73 -r1.74
  --- ServiceClient.java        26 Jan 2002 02:50:51 -0000      1.73
  +++ ServiceClient.java        14 Feb 2002 22:46:34 -0000      1.74
  @@ -290,7 +290,7 @@
        * @param value the maximum amount of time, in milliseconds
        */
       public void setTimeout (int value) {
  -        call.setProperty(Call.TIMEOUT,  new Integer(value));
  +        call.setTimeout(new Integer(value));
       }
   
       /**
  @@ -299,7 +299,7 @@
        * @return value the maximum amount of time, in milliseconds
        */
       public int getTimeout () {
  -        Integer timeout = (Integer)call.getProperty(Call.TIMEOUT);
  +        Integer timeout = call.getTimeout();
           if (timeout == null) return -1;
           
           return timeout.intValue();
  
  
  
  1.7       +22 -0     xml-axis/java/src/org/apache/axis/utils/LockableHashtable.java
  
  Index: LockableHashtable.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/LockableHashtable.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- LockableHashtable.java    7 Nov 2001 21:04:21 -0000       1.6
  +++ LockableHashtable.java    14 Feb 2002 22:46:34 -0000      1.7
  @@ -74,6 +74,9 @@
        * Stores the keys of the locked entries
        */
       Vector lockedEntries = new Vector();
  +    
  +    /** Place to look for properties which we don't find locally. */
  +    private Hashtable parent = null;
   
       public LockableHashtable() {
           super();
  @@ -90,7 +93,26 @@
       public LockableHashtable(int p1) {
           super(p1);
       }
  +    
  +    /**
  +     * Set the parent Hashtable for this object
  +     */ 
  +    public synchronized void setParent(Hashtable parent)
  +    {
  +        this.parent = parent;
  +    }
   
  +    /**
  +     * Get an entry from this hashtable, and if we don't find anything,
  +     * defer to our parent, if any.
  +     */ 
  +    public synchronized Object get(Object key) {
  +        Object ret = super.get(key);
  +        if ((ret == null) && (parent != null)) {
  +            ret = parent.get(key);
  +        }
  +        return ret;
  +    }
       /**
        * New version of the put() method that allows for explicitly marking
        * items added to the hashtable as locked.
  
  
  
  1.14      +44 -3     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.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- ClassRep.java     8 Feb 2002 20:48:30 -0000       1.13
  +++ ClassRep.java     14 Feb 2002 22:46:34 -0000      1.14
  @@ -61,9 +61,12 @@
   import java.util.Vector;
   import java.util.HashMap;
   
  -import org.apache.axis.utils.JavapUtils;
   import org.apache.axis.utils.JavaUtils;
   import org.apache.axis.wsdl.Skeleton;
  +import org.apache.bcel.classfile.JavaClass;
  +import org.apache.bcel.classfile.LocalVariableTable;
  +import org.apache.bcel.classfile.LocalVariable;
  +import org.apache.bcel.Repository;
   
   /**
    * ClassRep is the representation of a class used inside the Java2WSDL
  @@ -427,7 +430,7 @@
               return paramNames;
           }
           
  -        paramNames = JavapUtils.getParameterNames(method); 
  +        paramNames = getParameterNames(method); 
           
           // If failed, try getting a method of the impl class
           // It is possible that the impl class is a skeleton, thus the
  @@ -458,7 +461,7 @@
                   if (paramNames != null) {
                       return paramNames;
                   }
  -                paramNames = JavapUtils.getParameterNames(m); 
  +                paramNames = getParameterNames(m); 
               }
           }            
   
  @@ -582,6 +585,44 @@
               return false;
           }
           return true;
  +    }
  +    
  +    public String[] getParameterNames(java.lang.reflect.Method method) {
  +        Class c = method.getDeclaringClass();
  +        int numParams = method.getParameterTypes().length;
  +        
  +        if (numParams == 0)
  +            return null;
  +        
  +        JavaClass jc = Repository.lookupClass(c.getName());
  +        if (jc == null)
  +            return null;
  +        org.apache.bcel.classfile.Method [] methods = jc.getMethods();
  +        for (int i = 0; i < methods.length; i++) {
  +            org.apache.bcel.classfile.Method meth = methods[i];
  +            if (!meth.getName().equals(method.getName()))
  +                continue;
  +            
  +            LocalVariableTable lt = meth.getLocalVariableTable();
  +            if (lt == null)
  +                continue;
  +            LocalVariable [] vars = lt.getLocalVariableTable();
  +            if (vars.length == numParams + 1) {
  +                String [] argNames = new String[numParams + 1];
  +                argNames[0] = null; // don't know return name
  +                int idx = 1;
  +                // This is it?  Check types?
  +                for (int j = 0; j < vars.length; j++) {
  +                    LocalVariable var = vars[j];
  +                    if (var.getName().equals("this"))
  +                        continue;
  +                    argNames[var.getIndex()] = var.getName();
  +                }
  +                return argNames;
  +            }
  +        }
  +        
  +        return null;
       }
   
   };
  
  
  


Reply via email to