Author: ningjiang
Date: Tue Dec 14 05:09:07 2010
New Revision: 1048937
URL: http://svn.apache.org/viewvc?rev=1048937&view=rev
Log:
Merged revisions 1048930 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1048930 | ningjiang | 2010-12-14 12:08:42 +0800 (Tue, 14 Dec 2010) | 1 line
CXF-3180 remove the marshal and unmarshal cache as the lock is related to
XmlStreamReader
........
Modified:
cxf/branches/2.3.x-fixes/ (props changed)
cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Dec 14 05:09:07 2010
@@ -1 +1 @@
-/cxf/trunk:1041183,1041790,1041993,1042346,1042571,1042724,1042805,1042821,1043225,1043229,1043902,1043907,1043954,1044085,1044238-1044305,1045024,1048915,1048919
+/cxf/trunk:1041183,1041790,1041993,1042346,1042571,1042724,1042805,1042821,1043225,1043229,1043902,1043907,1043954,1044085,1044238-1044305,1045024,1048915,1048919,1048930
Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified:
cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java?rev=1048937&r1=1048936&r2=1048937&view=diff
==============================================================================
---
cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
(original)
+++
cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
Tue Dec 14 05:09:07 2010
@@ -24,7 +24,6 @@ import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.annotation.Annotation;
-import java.lang.ref.SoftReference;
import java.lang.reflect.Array;
import java.lang.reflect.Type;
import java.util.ArrayList;
@@ -92,6 +91,7 @@ public abstract class AbstractJAXBProvid
private static Map<String, JAXBContext> packageContexts = new
HashMap<String, JAXBContext>();
private static Map<Class<?>, JAXBContext> classContexts = new
HashMap<Class<?>, JAXBContext>();
+
protected Set<Class<?>> collectionContextClasses = new HashSet<Class<?>>();
protected JAXBContext collectionContext;
@@ -106,8 +106,6 @@ public abstract class AbstractJAXBProvid
protected List<String> inDropElements;
protected Map<String, String> inElementsMap;
protected Map<String, String> inAppendMap;
- protected Map<Long, SoftReference<JAXBMarshallerUnmarshallerCache>>
threadMarshallerCaches
- = new HashMap<Long, SoftReference<JAXBMarshallerUnmarshallerCache>>();
private boolean attributesToElements;
private MessageContext mc;
@@ -351,7 +349,6 @@ public abstract class AbstractJAXBProvid
}
}
-
public JAXBContext getPackageContext(Class<?> type) {
if (type == null || type == JAXBElement.class) {
return null;
@@ -375,24 +372,6 @@ public abstract class AbstractJAXBProvid
}
}
- public JAXBMarshallerUnmarshallerCache getThreadMarshallerCache(Thread
thread) {
- JAXBMarshallerUnmarshallerCache marshallerUnMarshallerCache = null;
- synchronized (threadMarshallerCaches) {
- SoftReference<JAXBMarshallerUnmarshallerCache>
marshallerUnMarshallerCacheRef =
- threadMarshallerCaches.get(thread.getId());
- if (marshallerUnMarshallerCacheRef != null) {
- marshallerUnMarshallerCache =
marshallerUnMarshallerCacheRef.get();
- }
- if (marshallerUnMarshallerCache == null) {
- marshallerUnMarshallerCache = new
JAXBMarshallerUnmarshallerCache();
- threadMarshallerCaches
- .put(thread.getId(),
- new
SoftReference<JAXBMarshallerUnmarshallerCache>(marshallerUnMarshallerCache));
- }
- return marshallerUnMarshallerCache;
- }
- }
-
protected boolean isSupported(Class<?> type, Type genericType,
Annotation[] anns) {
if (jaxbElementClassMap != null &&
jaxbElementClassMap.containsKey(type.getName())
|| isSkipJaxbChecks()) {
@@ -429,10 +408,7 @@ public abstract class AbstractJAXBProvid
throws JAXBException {
JAXBContext context = isCollection ? getCollectionContext(cls)
: getJAXBContext(cls, genericType);
-
- JAXBMarshallerUnmarshallerCache marshallerUnmarshallerCache =
- getThreadMarshallerCache(Thread.currentThread());
- Unmarshaller unmarshaller =
marshallerUnmarshallerCache.getUnmarshall(context);
+ Unmarshaller unmarshaller = context.createUnmarshaller();
if (schema != null) {
unmarshaller.setSchema(schema);
}
@@ -451,16 +427,9 @@ public abstract class AbstractJAXBProvid
? ((JAXBElement)obj).getDeclaredType() : cls;
JAXBContext context = getJAXBContext(objClazz, genericType);
- JAXBMarshallerUnmarshallerCache marshallerUnmarshallerCache =
- getThreadMarshallerCache(Thread.currentThread());
- Marshaller marshaller =
marshallerUnmarshallerCache.getMarshall(context);
- // need to set this value to make JAXRSClientServerBookTest passed
- marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.FALSE);
+ Marshaller marshaller = context.createMarshaller();
if (enc != null) {
marshaller.setProperty(Marshaller.JAXB_ENCODING, enc);
- } else {
- // set the default the value to the marshaller
- marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
}
return marshaller;
}
@@ -706,40 +675,6 @@ public abstract class AbstractJAXBProvid
}
- protected static class JAXBMarshallerUnmarshallerCache {
- private Map<JAXBContext, Marshaller> marshallers = new
HashMap<JAXBContext, Marshaller>();
- private Map<JAXBContext, Unmarshaller> unmarshallers = new
HashMap<JAXBContext, Unmarshaller>();
-
- public Marshaller getMarshall(JAXBContext jaxbContext) throws
JAXBException {
- if (jaxbContext == null) {
- return null;
- }
- // don't need the synchronized statement, as this ojbect is used
per thread
- Marshaller marshaller = marshallers.get(jaxbContext);
- if (marshaller == null) {
- marshaller = jaxbContext.createMarshaller();
- marshallers.put(jaxbContext, marshaller);
- }
- return marshaller;
-
- }
-
- public Unmarshaller getUnmarshall(JAXBContext jaxbContext) throws
JAXBException {
- if (jaxbContext == null) {
- return null;
- }
- // don't need the synchronized statement, as this ojbect is used
per thread
- Unmarshaller unmarshaller = unmarshallers.get(jaxbContext);
- if (unmarshaller == null) {
- unmarshaller = jaxbContext.createUnmarshaller();
- unmarshallers.put(jaxbContext, unmarshaller);
- }
- return unmarshaller;
-
- }
-
- }
-
protected static class OutTransformWriter extends
DelegatingXMLStreamWriter {
private QNamesMap elementsMap;
private Map<QName, QName> appendMap = new HashMap<QName, QName>(5);