You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2013/04/25 20:40:47 UTC
svn commit: r1475893 -
/cxf/trunk/api/src/main/java/org/apache/cxf/common/jaxb/JAXBContextCache.java
Author: dkulp
Date: Thu Apr 25 18:40:47 2013
New Revision: 1475893
URL: http://svn.apache.org/r1475893
Log:
[CXF-4947] More updates for the JAXBContextCache and aggressive GC's
Patch from Rex Wang applied
Modified:
cxf/trunk/api/src/main/java/org/apache/cxf/common/jaxb/JAXBContextCache.java
Modified: cxf/trunk/api/src/main/java/org/apache/cxf/common/jaxb/JAXBContextCache.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/common/jaxb/JAXBContextCache.java?rev=1475893&r1=1475892&r2=1475893&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/common/jaxb/JAXBContextCache.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/common/jaxb/JAXBContextCache.java Thu Apr 25 18:40:47 2013
@@ -62,9 +62,14 @@ public final class JAXBContextCache {
private final JAXBContext context;
private final Set<Class<?>> classes;
private final WeakReference<CachedContextAndSchemasInternal> ccas;
+ private CachedContextAndSchemas(JAXBContext context, Set<Class<?>> classes, CachedContextAndSchemasInternal i) {
+ this.context = context;
+ this.classes = classes;
+ ccas = new WeakReference<CachedContextAndSchemasInternal>(i);
+ }
private CachedContextAndSchemas(CachedContextAndSchemasInternal i) {
- classes = i.getClasses();
- context = i.getContext();
+ this.context = i.getContext();
+ this.classes = i.getClasses();
ccas = new WeakReference<CachedContextAndSchemasInternal>(i);
}
public JAXBContext getContext() {
@@ -179,28 +184,28 @@ public final class JAXBContextCache {
if (props != null) {
map.putAll(props);
}
- CachedContextAndSchemasInternal cachedContextAndSchemas = null;
+ CachedContextAndSchemasInternal cachedContextAndSchemasInternal = null;
JAXBContext context = null;
if (typeRefs == null || typeRefs.isEmpty()) {
synchronized (JAXBCONTEXT_CACHE) {
if (exact) {
- cachedContextAndSchemas = JAXBCONTEXT_CACHE.get(classes);
+ cachedContextAndSchemasInternal = JAXBCONTEXT_CACHE.get(classes);
} else {
for (Map.Entry<Set<Class<?>>, CachedContextAndSchemasInternal> k : JAXBCONTEXT_CACHE.entrySet()) {
Set<Class<?>> key = k.getKey();
if (key != null && key.containsAll(classes)) {
- cachedContextAndSchemas = k.getValue();
+ cachedContextAndSchemasInternal = k.getValue();
break;
}
}
}
- if (cachedContextAndSchemas != null) {
- context = cachedContextAndSchemas.getContext();
+ if (cachedContextAndSchemasInternal != null) {
+ context = cachedContextAndSchemasInternal.getContext();
if (context == null) {
- JAXBCONTEXT_CACHE.remove(cachedContextAndSchemas.getClasses());
- cachedContextAndSchemas = null;
+ JAXBCONTEXT_CACHE.remove(cachedContextAndSchemasInternal.getClasses());
+ cachedContextAndSchemasInternal = null;
} else {
- return new CachedContextAndSchemas(cachedContextAndSchemas);
+ return new CachedContextAndSchemas(cachedContextAndSchemasInternal);
}
}
}
@@ -227,14 +232,14 @@ public final class JAXBContextCache {
throw ex;
}
}
- cachedContextAndSchemas = new CachedContextAndSchemasInternal(context, classes);
+ cachedContextAndSchemasInternal = new CachedContextAndSchemasInternal(context, classes);
synchronized (JAXBCONTEXT_CACHE) {
if (typeRefs == null || typeRefs.isEmpty()) {
- JAXBCONTEXT_CACHE.put(classes, cachedContextAndSchemas);
+ JAXBCONTEXT_CACHE.put(classes, cachedContextAndSchemasInternal);
}
}
- return new CachedContextAndSchemas(cachedContextAndSchemas);
+ return new CachedContextAndSchemas(context, classes, cachedContextAndSchemasInternal);
}
private static boolean checkObjectFactoryNamespaces(Class<?> clz) {