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 21:23:34 UTC
svn commit: r1475915 -
/cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/common/jaxb/JAXBContextCache.java
Author: dkulp
Date: Thu Apr 25 19:23:33 2013
New Revision: 1475915
URL: http://svn.apache.org/r1475915
Log:
Merged revisions 1475896 via git cherry-pick from
https://svn.apache.org/repos/asf/cxf/branches/2.7.x-fixes
........
r1475896 | dkulp | 2013-04-25 14:44:15 -0400 (Thu, 25 Apr 2013) | 11 lines
Merged revisions 1475893 via git cherry-pick from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1475893 | dkulp | 2013-04-25 14:40:47 -0400 (Thu, 25 Apr 2013) | 3 lines
[CXF-4947] More updates for the JAXBContextCache and aggressive GC's
Patch from Rex Wang applied
........
........
Modified:
cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/common/jaxb/JAXBContextCache.java
Modified: cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/common/jaxb/JAXBContextCache.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/common/jaxb/JAXBContextCache.java?rev=1475915&r1=1475914&r2=1475915&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/common/jaxb/JAXBContextCache.java (original)
+++ cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/common/jaxb/JAXBContextCache.java Thu Apr 25 19:23:33 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);
}
}
}
@@ -228,14 +233,14 @@ public final class JAXBContextCache {
}
}
}
- 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) {