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/encoding/ser BaseDeserializerFactory.java BaseSerializerFactory.java BeanDeserializerFactory.java BeanSerializerFactory.java
Date Tue, 17 Sep 2002 22:55:47 GMT
dims        2002/09/17 15:55:47

  Modified:    java/src/org/apache/axis/encoding/ser
                        BaseDeserializerFactory.java
                        BaseSerializerFactory.java
                        BeanDeserializerFactory.java
                        BeanSerializerFactory.java
  Log:
  Possible fix for Bug 12741 - Multithreaded Axis client causes serialization exceptions in
Axis service
  
  Note:
  - Got rid of firstCall as it does not protect the code properly in multi-threaded, heavy
volume situations.
  
  Revision  Changes    Path
  1.8       +42 -28    xml-axis/java/src/org/apache/axis/encoding/ser/BaseDeserializerFactory.java
  
  Index: BaseDeserializerFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/BaseDeserializerFactory.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- BaseDeserializerFactory.java	27 Jun 2002 17:22:32 -0000	1.7
  +++ BaseDeserializerFactory.java	17 Sep 2002 22:55:47 -0000	1.8
  @@ -83,7 +83,6 @@
       protected Class javaType = null;
       protected Constructor deserClassConstructor = null;
       protected Method getDeserializer = null;
  -    protected boolean firstCall = true;
   
       /**
        * Constructor
  @@ -124,7 +123,6 @@
           } catch (Exception e) {
               throw new JAXRPCException(e);
           }
  -        firstCall = false;
           return deser;
       }
   
  @@ -134,12 +132,8 @@
        */
       protected Deserializer getGeneralPurpose(String mechanismType) {
           if (javaType != null && xmlType != null) {
  -            if (deserClassConstructor == null && firstCall) {
  -                try {
  -                    deserClassConstructor = 
  -                        deserClass.getConstructor(
  -                            new Class[] {Class.class, QName.class});
  -                } catch (NoSuchMethodException e) {}
  +            if (deserClassConstructor == null) {
  +                deserClassConstructor = getConstructor(deserClass); 
               }
               if (deserClassConstructor != null) {
                   try {
  @@ -155,31 +149,24 @@
       }
   
       /**
  +     * return constructor for class if any
  +     */ 
  +     private Constructor getConstructor(Class clazz) {
  +        try {
  +           return clazz.getConstructor(
  +                   new Class[] {Class.class, QName.class});
  +        } catch (NoSuchMethodException e) {}
  +        return null;
  +     }
  +
  +    /**
        * Obtains a deserializer by invoking getDeserializer method in the 
        * javaType class or its Helper class.
        */
       protected Deserializer getSpecialized(String mechanismType) {
           if (javaType != null && xmlType != null) {
  -            if (getDeserializer == null && firstCall) {
  -                try {
  -                    getDeserializer = 
  -                        javaType.getMethod("getDeserializer",
  -                                           new Class[] {String.class, 
  -                                                        Class.class, 
  -                                                        QName.class});
  -                } catch (NoSuchMethodException e) {}
  -                if (getDeserializer == null) {
  -                    try {
  -                        Class helper = ClassUtils.forName(
  -                            javaType.getName() + "_Helper");
  -                        getDeserializer =
  -                            helper.getMethod("getDeserializer", 
  -                                             new Class[] {String.class, 
  -                                                          Class.class, 
  -                                                          QName.class});
  -                    } catch (NoSuchMethodException e) {
  -                    } catch (ClassNotFoundException e) {}
  -                }
  +            if (getDeserializer == null) {
  +                getDeserializer = getDeserializerMethod(javaType);    
               }
               if (getDeserializer != null) {
                   try {
  @@ -196,6 +183,33 @@
           return null;
       }
   
  +    /**
  +     * Returns the "getDeserializer" method if any.
  +     */
  +    private Method getDeserializerMethod(Class clazz) {
  +        Method method = null;
  +        try {
  +            method = 
  +                clazz.getMethod("getDeserializer",
  +                                   new Class[] {String.class, 
  +                                                Class.class, 
  +                                                QName.class});
  +        } catch (NoSuchMethodException e) {}
  +        if (method == null) {
  +            try {
  +                Class helper = ClassUtils.forName(
  +                    clazz.getName() + "_Helper");
  +                method =
  +                    helper.getMethod("getDeserializer", 
  +                                     new Class[] {String.class, 
  +                                                  Class.class, 
  +                                                  QName.class});
  +            } catch (NoSuchMethodException e) {
  +            } catch (ClassNotFoundException e) {}
  +        }
  +        return method;
  +    }
  +    
       /**
        * Returns a list of all XML processing mechanism types supported by this DeserializerFactory.
        *
  
  
  
  1.14      +45 -29    xml-axis/java/src/org/apache/axis/encoding/ser/BaseSerializerFactory.java
  
  Index: BaseSerializerFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/BaseSerializerFactory.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- BaseSerializerFactory.java	17 Sep 2002 22:21:27 -0000	1.13
  +++ BaseSerializerFactory.java	17 Sep 2002 22:55:47 -0000	1.14
  @@ -98,7 +98,6 @@
       protected Class javaType = null;
       protected Constructor serClassConstructor = null;
       protected Method getSerializer = null;
  -    protected boolean firstCall = true;
   
       /**
        * Constructor
  @@ -148,7 +147,6 @@
                                        serClass.getName()),
                   e);
           }
  -        firstCall = false;
           return ser;
       }
       
  @@ -158,13 +156,10 @@
        */
       protected Serializer getGeneralPurpose(String mechanismType) {
           if (javaType != null && xmlType != null) {
  -            if (serClassConstructor == null && firstCall) {
  -                try {
  -                    serClassConstructor = 
  -                        serClass.getConstructor(
  -                            new Class[] {Class.class, QName.class});
  -                } catch (NoSuchMethodException e) {}
  +            if (serClassConstructor == null) {
  +                serClassConstructor = getConstructor(serClass);
               }
  +
               if (serClassConstructor != null) {
                   try {
                       return (Serializer) 
  @@ -177,33 +172,26 @@
           }
           return null;
       }
  -
  +    
  +   /**
  +    * return constructor for class if any
  +    */ 
  +    private Constructor getConstructor(Class clazz) {
  +        try {
  +           return clazz.getConstructor(
  +                   new Class[] {Class.class, QName.class});
  +        } catch (NoSuchMethodException e) {}
  +        return null;
  +    }
  +    
       /**
        * Obtains a serializer by invoking getSerializer method in the 
        * javaType class or its Helper class.
        */
       protected Serializer getSpecialized(String mechanismType) {
           if (javaType != null && xmlType != null) {
  -            if (getSerializer == null && firstCall) {
  -                try {
  -                    getSerializer = 
  -                        javaType.getMethod("getSerializer",
  -                                           new Class[] {String.class, 
  -                                                        Class.class, 
  -                                                        QName.class});
  -                } catch (NoSuchMethodException e) {}
  -                if (getSerializer == null) {
  -                    try {
  -                        Class helper = ClassUtils.forName(
  -                            javaType.getName() + "_Helper");
  -                        getSerializer =
  -                            helper.getMethod("getSerializer", 
  -                                             new Class[] {String.class, 
  -                                                          Class.class, 
  -                                                          QName.class});
  -                    } catch (NoSuchMethodException e) {
  -                    } catch (ClassNotFoundException e) {}
  -                }
  +            if (getSerializer == null) {
  +                getSerializer = getSerializerMethod(javaType);
               }
               if (getSerializer != null) {
                   try {
  @@ -218,6 +206,34 @@
               }
           }
           return null;
  +    }
  +
  +    /**
  +     * Returns the "getSerializer" method if any.
  +     */
  +    private Method getSerializerMethod(Class clazz) {
  +        Method method = null;
  +        try {
  +            method = 
  +                clazz.getMethod("getSerializer",
  +                                   new Class[] {String.class, 
  +                                                Class.class, 
  +                                                QName.class});
  +        } catch (NoSuchMethodException e) {}
  +        
  +        if (method == null) {
  +            try {
  +                Class helper = ClassUtils.forName(
  +                    clazz.getName() + "_Helper");
  +                method =
  +                    helper.getMethod("getSerializer", 
  +                                     new Class[] {String.class, 
  +                                                  Class.class, 
  +                                                  QName.class});
  +            } catch (NoSuchMethodException e) {
  +            } catch (ClassNotFoundException e) {}
  +        }
  +        return method;
       }
   
       /**
  
  
  
  1.5       +3 -5      xml-axis/java/src/org/apache/axis/encoding/ser/BeanDeserializerFactory.java
  
  Index: BeanDeserializerFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/BeanDeserializerFactory.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- BeanDeserializerFactory.java	8 Aug 2002 14:35:48 -0000	1.4
  +++ BeanDeserializerFactory.java	17 Sep 2002 22:55:47 -0000	1.5
  @@ -85,6 +85,9 @@
           if (JavaUtils.isEnumClass(javaType)) {
               deserClass = EnumDeserializer.class;
           }
  +
  +        typeDesc = TypeDesc.getTypeDescForClass(javaType);
  +        propertyMap = getProperties(javaType, typeDesc);
       }
   
      /**
  @@ -119,11 +122,6 @@
   
           if (deserClass == EnumSerializer.class) {
              return super.getGeneralPurpose(mechanismType);
  -        }
  -
  -        if (propertyMap == null && firstCall) {
  -            typeDesc = TypeDesc.getTypeDescForClass(javaType);
  -            propertyMap = getProperties(javaType, typeDesc);
           }
   
           return new BeanDeserializer(javaType, xmlType, typeDesc, propertyMap);
  
  
  
  1.6       +8 -10     xml-axis/java/src/org/apache/axis/encoding/ser/BeanSerializerFactory.java
  
  Index: BeanSerializerFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/BeanSerializerFactory.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- BeanSerializerFactory.java	7 Aug 2002 22:31:33 -0000	1.5
  +++ BeanSerializerFactory.java	17 Sep 2002 22:55:47 -0000	1.6
  @@ -91,6 +91,14 @@
           if (JavaUtils.isEnumClass(javaType)) {
               serClass = EnumSerializer.class;
           }
  +        
  +        typeDesc = TypeDesc.getTypeDescForClass(javaType);
  +
  +        if (typeDesc != null) {
  +            propertyDescriptor = typeDesc.getPropertyDescriptors();
  +        } else {
  +            propertyDescriptor = BeanUtils.getPd(javaType, null);
  +        }
       }
   
       public javax.xml.rpc.encoding.Serializer getSerializerAs(String mechanismType)
  @@ -109,16 +117,6 @@
   
           if (serClass == EnumSerializer.class) {
              return super.getGeneralPurpose(mechanismType);
  -        }
  -
  -        if (propertyDescriptor == null && firstCall) {
  -            typeDesc = TypeDesc.getTypeDescForClass(javaType);
  -
  -            if (typeDesc != null) {
  -                propertyDescriptor = typeDesc.getPropertyDescriptors();
  -            } else {
  -                propertyDescriptor = BeanUtils.getPd(javaType, null);
  -            }
           }
   
           return new BeanSerializer(javaType, xmlType, typeDesc, 
  
  
  

Mime
View raw message