You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ga...@apache.org on 2004/11/15 08:13:11 UTC

cvs commit: ws-axis/java/src/org/apache/axis/utils/cache MethodCache.java

gawor       2004/11/14 23:13:11

  Modified:    java/src/org/apache/axis/encoding/ser
                        BaseDeserializerFactory.java
                        BaseSerializerFactory.java SimpleDeserializer.java
                        SimpleDeserializerFactory.java
                        SimpleListDeserializerFactory.java
               java/src/org/apache/axis/utils/cache MethodCache.java
  Log:
  just a few more minor optimizations
  
  Revision  Changes    Path
  1.23      +5 -2      ws-axis/java/src/org/apache/axis/encoding/ser/BaseDeserializerFactory.java
  
  Index: BaseDeserializerFactory.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/encoding/ser/BaseDeserializerFactory.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- BaseDeserializerFactory.java	14 Nov 2004 05:07:04 -0000	1.22
  +++ BaseDeserializerFactory.java	15 Nov 2004 07:13:11 -0000	1.23
  @@ -41,6 +41,7 @@
   
       protected static Log log =
               LogFactory.getLog(BaseDeserializerFactory.class.getName());
  +
       transient static Vector mechanisms = null;
       
       protected Class deserClass = null;
  @@ -62,8 +63,6 @@
                               Deserializer.class.getName()));
           }
           this.deserClass = deserClass;
  -        mechanisms = new Vector();
  -        mechanisms.add(Constants.AXIS_SAX);
       }
   
       public BaseDeserializerFactory(Class deserClass,
  @@ -178,6 +177,10 @@
        * @return List of unique identifiers for the supported XML processing mechanism types
        */
       public Iterator getSupportedMechanismTypes() {
  +        if (mechanisms == null) {
  +            mechanisms = new Vector(1);
  +            mechanisms.add(Constants.AXIS_SAX);
  +        }
           return mechanisms.iterator();
       }
   
  
  
  
  1.31      +1 -1      ws-axis/java/src/org/apache/axis/encoding/ser/BaseSerializerFactory.java
  
  Index: BaseSerializerFactory.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/encoding/ser/BaseSerializerFactory.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- BaseSerializerFactory.java	14 Nov 2004 05:07:04 -0000	1.30
  +++ BaseSerializerFactory.java	15 Nov 2004 07:13:11 -0000	1.31
  @@ -190,7 +190,7 @@
        */
       public Iterator getSupportedMechanismTypes() {
           if (mechanisms == null) {
  -            mechanisms = new Vector();
  +            mechanisms = new Vector(1);
               mechanisms.add(Constants.AXIS_SAX);
           }
           return mechanisms.iterator();
  
  
  
  1.40      +8 -2      ws-axis/java/src/org/apache/axis/encoding/ser/SimpleDeserializer.java
  
  Index: SimpleDeserializer.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/encoding/ser/SimpleDeserializer.java,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- SimpleDeserializer.java	18 Apr 2004 18:07:36 -0000	1.39
  +++ SimpleDeserializer.java	15 Nov 2004 07:13:11 -0000	1.40
  @@ -49,6 +49,12 @@
    */
   public class SimpleDeserializer extends DeserializerImpl {
       
  +    private static final Class[] STRING_STRING_CLASS = 
  +        new Class [] {String.class, String.class};
  +
  +    private static final Class[] STRING_CLASS = 
  +        new Class [] {String.class};
  +
       private final CharArrayWriter val = new CharArrayWriter();
       private Constructor constructor = null;
       private Map propertyMap = null;
  @@ -259,10 +265,10 @@
               try {
                   if (QName.class.isAssignableFrom(javaType)) {
                       constructor = 
  -                        javaType.getDeclaredConstructor(new Class [] {String.class, String.class});
  +                        javaType.getDeclaredConstructor(STRING_STRING_CLASS);
                   } else {
                       constructor = 
  -                        javaType.getDeclaredConstructor(new Class [] {String.class});
  +                        javaType.getDeclaredConstructor(STRING_CLASS);
                   }
               } catch (Exception e) {
                   return null;
  
  
  
  1.10      +9 -3      ws-axis/java/src/org/apache/axis/encoding/ser/SimpleDeserializerFactory.java
  
  Index: SimpleDeserializerFactory.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/encoding/ser/SimpleDeserializerFactory.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- SimpleDeserializerFactory.java	7 Apr 2004 13:00:35 -0000	1.9
  +++ SimpleDeserializerFactory.java	15 Nov 2004 07:13:11 -0000	1.10
  @@ -33,6 +33,12 @@
    */
   public class SimpleDeserializerFactory extends BaseDeserializerFactory {
   
  +    private static final Class[] STRING_STRING_CLASS = 
  +        new Class [] {String.class, String.class};
  +    
  +    private static final Class[] STRING_CLASS = 
  +        new Class [] {String.class};
  +
       private Constructor constructor = null;
       /**
        * Note that the factory is constructed with the QName and xmlType.  This is important
  @@ -44,17 +50,17 @@
               if (!javaType.isPrimitive()) {
                   if (QName.class.isAssignableFrom(javaType)) {
                       constructor = 
  -                        javaType.getDeclaredConstructor(new Class [] {String.class, String.class});
  +                        javaType.getDeclaredConstructor(STRING_STRING_CLASS);
                   } else {
                       constructor = 
  -                        javaType.getDeclaredConstructor(new Class [] {String.class});
  +                        javaType.getDeclaredConstructor(STRING_CLASS);
                   }
               }
               else {
                   Class wrapper = JavaUtils.getWrapperClass(javaType);
                   if (wrapper != null)
                       constructor = 
  -                        wrapper.getDeclaredConstructor(new Class [] {String.class});
  +                        wrapper.getDeclaredConstructor(STRING_CLASS);
               }
           } catch (java.lang.NoSuchMethodException e) {
               throw new IllegalArgumentException(e.toString());
  
  
  
  1.3       +5 -2      ws-axis/java/src/org/apache/axis/encoding/ser/SimpleListDeserializerFactory.java
  
  Index: SimpleListDeserializerFactory.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/encoding/ser/SimpleListDeserializerFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SimpleListDeserializerFactory.java	25 Feb 2004 14:02:37 -0000	1.2
  +++ SimpleListDeserializerFactory.java	15 Nov 2004 07:13:11 -0000	1.3
  @@ -32,6 +32,9 @@
    */
   public class SimpleListDeserializerFactory extends BaseDeserializerFactory {
   
  +    private static final Class[] STRING_CLASS = 
  +        new Class [] {String.class};
  +
       private Constructor constructor = null;
       /**
        * Note that the factory is constructed with the QName and xmlType.  This is important
  @@ -43,13 +46,13 @@
           try {
               if (!componentType.isPrimitive()) {
                   constructor = 
  -                componentType.getDeclaredConstructor(new Class [] {String.class});
  +                componentType.getDeclaredConstructor(STRING_CLASS);
               }
               else {
                   Class wrapper = JavaUtils.getWrapperClass(componentType);
                   if (wrapper != null)
                       constructor = 
  -                        wrapper.getDeclaredConstructor(new Class [] {String.class});
  +                        wrapper.getDeclaredConstructor(STRING_CLASS);
               }
           } catch (java.lang.NoSuchMethodException e) {
               throw new IllegalArgumentException(e.toString());
  
  
  
  1.7       +14 -16    ws-axis/java/src/org/apache/axis/utils/cache/MethodCache.java
  
  Index: MethodCache.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/utils/cache/MethodCache.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- MethodCache.java	8 Apr 2004 13:09:06 -0000	1.6
  +++ MethodCache.java	15 Nov 2004 07:13:11 -0000	1.7
  @@ -158,26 +158,24 @@
           
           // Check the cache first.
           MethodKey key = new MethodKey(methodName, parameterTypes);
  -        if (cache.containsKey(className)) {
  -            methods = (Map) cache.get(className);
  -            if (methods != null) {
  -                Object o = methods.get(key);
  -                if (o != null) {  // cache hit
  -                    if (o instanceof Method) { // good cache hit
  -                        return (Method) o;
  -                    } else {                   // bad cache hit
  -                        // we hit the NULL_OBJECT, so this is a search
  -                        // that previously failed; no point in doing
  -                        // it again as it is a worst case search
  -                        // through the entire classpath.
  -                        return null;
  -                    }
  -                } else {
  -                    // cache miss: fall through to reflective search
  +        methods = (Map) cache.get(className);
  +        if (methods != null) {
  +            Object o = methods.get(key);
  +            if (o != null) {  // cache hit
  +                if (o instanceof Method) { // good cache hit
  +                    return (Method) o;
  +                } else {                   // bad cache hit
  +                    // we hit the NULL_OBJECT, so this is a search
  +                    // that previously failed; no point in doing
  +                    // it again as it is a worst case search
  +                    // through the entire classpath.
  +                    return null;
                   }
               } else {
                   // cache miss: fall through to reflective search
               }
  +        } else {
  +            // cache miss: fall through to reflective search
           }
   
           try {