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 di...@apache.org on 2005/09/26 04:13:02 UTC

svn commit: r291514 - /webservices/axis/trunk/java/src/org/apache/axis/description/TypeDesc.java

Author: dims
Date: Sun Sep 25 19:13:00 2005
New Revision: 291514

URL: http://svn.apache.org/viewcvs?rev=291514&view=rev
Log:
Fix for AXIS-2232 - Mappings in TypeDesc can't be GC'ed from David Blevins

Modified:
    webservices/axis/trunk/java/src/org/apache/axis/description/TypeDesc.java

Modified: webservices/axis/trunk/java/src/org/apache/axis/description/TypeDesc.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/src/org/apache/axis/description/TypeDesc.java?rev=291514&r1=291513&r2=291514&view=diff
==============================================================================
--- webservices/axis/trunk/java/src/org/apache/axis/description/TypeDesc.java (original)
+++ webservices/axis/trunk/java/src/org/apache/axis/description/TypeDesc.java Sun Sep 25 19:13:00 2005
@@ -27,6 +27,7 @@
 import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.Map;
+import java.util.WeakHashMap;
 
 /**
  * A TypeDesc represents a Java<->XML data binding.  It is essentially
@@ -39,8 +40,8 @@
     public static final Class [] noClasses = new Class [] {};
     public static final Object[] noObjects = new Object[] {};
     
-    /** A map of class -> TypeDesc */
-    private static Map classMap = new Hashtable();
+    /** A map of {classloader-> map of {class -> TypeDesc}} */
+    private static Map classMaps = new WeakHashMap();
 
     /** Have we already introspected for the special "any" property desc? */
     private boolean lookedForAny = false;
@@ -87,9 +88,23 @@
      */ 
     public static void registerTypeDescForClass(Class cls, TypeDesc td)
     {
+        Map classMap = getTypeDescMap(cls.getClassLoader());
         classMap.put(cls, td);
     }
 
+    private static Map getTypeDescMap(ClassLoader classLoader)
+    {
+        Map classMap;
+        synchronized (classMaps) {
+            classMap = (Map) classMaps.get(classLoader);
+            if (classMap == null){
+                classMap = new Hashtable();
+                classMaps.put(classLoader, classMap);
+            }
+        }
+        return classMap;
+    }
+
     /**
      * Static function for centralizing access to type metadata for a
      * given class.  
@@ -102,6 +117,8 @@
      */
     public static TypeDesc getTypeDescForClass(Class cls)
     {
+        Map classMap = getTypeDescMap(cls.getClassLoader());
+
         // First see if we have one explicitly registered
         // or cached from previous lookup
         TypeDesc result = (TypeDesc)classMap.get(cls);