cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1169899 - /cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBContextCache.java
Date Mon, 12 Sep 2011 19:54:22 GMT
Author: dkulp
Date: Mon Sep 12 19:54:22 2011
New Revision: 1169899

URL: http://svn.apache.org/viewvc?rev=1169899&view=rev
Log:
[CXF-3801] Slight optimizations for the JAXBContextCache.

Modified:
    cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBContextCache.java

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBContextCache.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBContextCache.java?rev=1169899&r1=1169898&r2=1169899&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBContextCache.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBContextCache.java Mon Sep
12 19:54:22 2011
@@ -22,6 +22,7 @@ package org.apache.cxf.jaxb;
 import java.io.BufferedReader;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.lang.ref.SoftReference;
 import java.lang.ref.WeakReference;
 import java.lang.reflect.Method;
 import java.util.Collection;
@@ -46,12 +47,12 @@ import org.apache.cxf.common.util.String
  */
 public final class JAXBContextCache {
     public static final class CachedContextAndSchemas {
-        private WeakReference<JAXBContext> context;
+        private SoftReference<JAXBContext> context;
         private WeakReference<Set<Class<?>>> classes;
         private Collection<DOMSource> schemas;
 
         CachedContextAndSchemas(JAXBContext context, Set<Class<?>> classes) {
-            this.context = new WeakReference<JAXBContext>(context);
+            this.context = new SoftReference<JAXBContext>(context);
             this.classes = new WeakReference<Set<Class<?>>>(classes);
         }
 
@@ -153,15 +154,15 @@ public final class JAXBContextCache {
                         }
                     }
                 }
-            }
-        }
-        if (cachedContextAndSchemas != null) {
-            context = cachedContextAndSchemas.getContext();
-            if (context ==  null) {
-                synchronized (JAXBCONTEXT_CACHE) {
-                    JAXBCONTEXT_CACHE.remove(cachedContextAndSchemas.getClasses());
+                if (cachedContextAndSchemas != null) {
+                    context = cachedContextAndSchemas.getContext();
+                    if (context == null) {
+                        JAXBCONTEXT_CACHE.remove(cachedContextAndSchemas.getClasses());
+                        cachedContextAndSchemas = null;
+                    } else {
+                        return cachedContextAndSchemas;
+                    }
                 }
-                cachedContextAndSchemas = null;
             }
         }
         if (context == null) {



Mime
View raw message