incubator-wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jra...@apache.org
Subject svn commit: r891863 - /incubator/wink/trunk/wink-providers/wink-jaxbcollection-provider/src/main/java/org/apache/wink/providers/xml/AbstractJAXBCollectionProvider.java
Date Thu, 17 Dec 2009 20:02:56 GMT
Author: jramos
Date: Thu Dec 17 20:02:55 2009
New Revision: 891863

URL: http://svn.apache.org/viewvc?rev=891863&view=rev
Log:
Don't use a new Marshaller for every Object in the Collection

Modified:
    incubator/wink/trunk/wink-providers/wink-jaxbcollection-provider/src/main/java/org/apache/wink/providers/xml/AbstractJAXBCollectionProvider.java

Modified: incubator/wink/trunk/wink-providers/wink-jaxbcollection-provider/src/main/java/org/apache/wink/providers/xml/AbstractJAXBCollectionProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-providers/wink-jaxbcollection-provider/src/main/java/org/apache/wink/providers/xml/AbstractJAXBCollectionProvider.java?rev=891863&r1=891862&r2=891863&view=diff
==============================================================================
--- incubator/wink/trunk/wink-providers/wink-jaxbcollection-provider/src/main/java/org/apache/wink/providers/xml/AbstractJAXBCollectionProvider.java
(original)
+++ incubator/wink/trunk/wink-providers/wink-jaxbcollection-provider/src/main/java/org/apache/wink/providers/xml/AbstractJAXBCollectionProvider.java
Thu Dec 17 20:02:55 2009
@@ -143,12 +143,18 @@
                 writeStartTag(qname, entityStream, mediaType);
             }
 
+            Marshaller marshaller = null;
+            JAXBContext context = null;
             for (Object o : elementArray) {
-                Class<?> oType =
-                    isJAXBElement ? ((JAXBElement<?>)o).getDeclaredType() : o.getClass();
-                JAXBContext context = getContext(oType, mediaType);
-                Marshaller marshaller = getJAXBMarshaller(oType, context, mediaType);
-                marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
+                if(marshaller == null) {
+                    Class<?> oType =
+                        isJAXBElement ? ((JAXBElement<?>)o).getDeclaredType() : o.getClass();
+                        context = getContext(oType, mediaType);
+                        marshaller = getJAXBMarshaller(oType, context, mediaType);
+                        marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
+                        Charset charSet = getCharSet(mediaType);
+                        marshaller.setProperty(Marshaller.JAXB_ENCODING, charSet.name());
+                }
                 Object entityToMarshal = getEntityToMarshal(o, theType);
                 if (qname == null) {
                     if (entityToMarshal instanceof JAXBElement<?>)
@@ -159,8 +165,6 @@
                                       entityToMarshal.getClass().getSimpleName());
                     writeStartTag(qname, entityStream, mediaType);
                 }
-                Charset charSet = getCharSet(mediaType);
-                marshaller.setProperty(Marshaller.JAXB_ENCODING, charSet.name());
                 marshaller.marshal(entityToMarshal, entityStream);
                 releaseJAXBMarshaller(context, marshaller);
             }



Mime
View raw message