wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r816771 - in /incubator/wink/trunk: wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/ wink-common/src/main/resources/META-INF/core/ wink-server/src/test/java/org/apache/wink/server/ wink-server/src/test/java/or...
Date Fri, 18 Sep 2009 20:17:24 GMT
Author: bluk
Date: Fri Sep 18 20:17:23 2009
New Revision: 816771

URL: http://svn.apache.org/viewvc?rev=816771&view=rev
Log:
XmlFormatting options should do nothing by default

See [WINK-202]

Added:
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/XMLFormattingOptionsProvider.java
  (with props)
Modified:
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/AbstractJAXBProvider.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/JAXBElementXmlProvider.java
    incubator/wink/trunk/wink-common/src/main/resources/META-INF/core/wink-providers
    incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/AbstractResourceBeanTest.java
    incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/AbstractResourceWithDuplicateWorkspaceTest.java
    incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/providers/entity/AssetProviderTest.java
    incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/providers/entity/JAXBElementProviderTest.java

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/AbstractJAXBProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/AbstractJAXBProvider.java?rev=816771&r1=816770&r2=816771&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/AbstractJAXBProvider.java
(original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/AbstractJAXBProvider.java
Fri Sep 18 20:17:23 2009
@@ -87,9 +87,6 @@
         }
         if (formatingOptions != null) {
             JAXBUtils.setXmlFormattingOptions(marshaller, formatingOptions);
-        } else {
-            JAXBUtils.setXmlFormattingOptions(marshaller, XmlFormattingOptions
-                .getDefaultXmlFormattingOptions());
         }
         return marshaller;
     }

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/JAXBElementXmlProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/JAXBElementXmlProvider.java?rev=816771&r1=816770&r2=816771&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/JAXBElementXmlProvider.java
(original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/JAXBElementXmlProvider.java
Fri Sep 18 20:17:23 2009
@@ -45,8 +45,6 @@
 
 import org.apache.wink.common.internal.i18n.Messages;
 import org.apache.wink.common.internal.model.ModelUtils;
-import org.apache.wink.common.internal.utils.JAXBUtils;
-import org.apache.wink.common.model.XmlFormattingOptions;
 import org.apache.wink.common.utils.ProviderUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -121,10 +119,8 @@
                         OutputStream entityStream) throws IOException, WebApplicationException
{
         try {
             Marshaller marshaller = getMarshaller(t.getDeclaredType(), mediaType);
-            marshaller.setProperty(Marshaller.JAXB_ENCODING, ProviderUtils.getCharset(mediaType));
-            JAXBUtils.setXmlFormattingOptions(marshaller, XmlFormattingOptions
-                .getDefaultXmlFormattingOptions());
 
+            // Use an OutputStream directly instead of a Writer for performance.
             marshaller.marshal(t, entityStream);
         } catch (JAXBException e) {
             logger.error(Messages.getMessage("jaxbFailToMarshal"), t.getName());

Added: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/XMLFormattingOptionsProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/XMLFormattingOptionsProvider.java?rev=816771&view=auto
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/XMLFormattingOptionsProvider.java
(added)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/XMLFormattingOptionsProvider.java
Fri Sep 18 20:17:23 2009
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.wink.common.internal.providers.entity.xml;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.ws.rs.ext.ContextResolver;
+import javax.ws.rs.ext.Provider;
+
+import org.apache.wink.common.model.XmlFormattingOptions;
+import org.apache.wink.common.model.app.AppCategories;
+import org.apache.wink.common.model.app.AppService;
+import org.apache.wink.common.model.atom.AtomEntry;
+import org.apache.wink.common.model.atom.AtomFeed;
+
+@Provider
+public class XMLFormattingOptionsProvider implements
+    ContextResolver<XmlFormattingOptions> {
+
+    private final Set<Class<?>> classesWithDefault = new HashSet<Class<?>>();
+
+    public XMLFormattingOptionsProvider() {
+        classesWithDefault.add(AtomFeed.class);
+        classesWithDefault.add(AtomEntry.class);
+        classesWithDefault.add(AppCategories.class);
+        classesWithDefault.add(AppService.class);
+    }
+
+    public XmlFormattingOptions getContext(Class<?> type) {
+        if (classesWithDefault.contains(type)) {
+            return XmlFormattingOptions.getDefaultXmlFormattingOptions();
+        }
+        return null;
+    }
+
+}

Propchange: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/XMLFormattingOptionsProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/wink/trunk/wink-common/src/main/resources/META-INF/core/wink-providers
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/resources/META-INF/core/wink-providers?rev=816771&r1=816770&r2=816771&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/resources/META-INF/core/wink-providers (original)
+++ incubator/wink/trunk/wink-common/src/main/resources/META-INF/core/wink-providers Fri Sep
18 20:17:23 2009
@@ -42,6 +42,7 @@
 # JAXB Providers
 org.apache.wink.common.internal.providers.entity.xml.JAXBElementXmlProvider
 org.apache.wink.common.internal.providers.entity.xml.JAXBXmlProvider
+org.apache.wink.common.internal.providers.entity.xml.XMLFormattingOptionsProvider
 
 # Atom 
 org.apache.wink.common.internal.providers.entity.atom.AtomFeedSyndFeedProvider

Modified: incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/AbstractResourceBeanTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/AbstractResourceBeanTest.java?rev=816771&r1=816770&r2=816771&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/AbstractResourceBeanTest.java
(original)
+++ incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/AbstractResourceBeanTest.java
Fri Sep 18 20:17:23 2009
@@ -35,7 +35,6 @@
 import org.apache.wink.server.internal.servlet.MockServletInvocationTest;
 import org.apache.wink.test.mock.MockRequestConstructor;
 import org.apache.wink.test.mock.TestUtils;
-import org.custommonkey.xmlunit.Diff;
 import org.springframework.mock.web.MockHttpServletRequest;
 import org.springframework.mock.web.MockHttpServletResponse;
 

Modified: incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/AbstractResourceWithDuplicateWorkspaceTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/AbstractResourceWithDuplicateWorkspaceTest.java?rev=816771&r1=816770&r2=816771&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/AbstractResourceWithDuplicateWorkspaceTest.java
(original)
+++ incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/AbstractResourceWithDuplicateWorkspaceTest.java
Fri Sep 18 20:17:23 2009
@@ -34,7 +34,6 @@
 import org.apache.wink.server.internal.servlet.MockServletInvocationTest;
 import org.apache.wink.test.mock.MockRequestConstructor;
 import org.apache.wink.test.mock.TestUtils;
-import org.custommonkey.xmlunit.Diff;
 import org.springframework.mock.web.MockHttpServletRequest;
 import org.springframework.mock.web.MockHttpServletResponse;
 

Modified: incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/providers/entity/AssetProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/providers/entity/AssetProviderTest.java?rev=816771&r1=816770&r2=816771&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/providers/entity/AssetProviderTest.java
(original)
+++ incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/providers/entity/AssetProviderTest.java
Fri Sep 18 20:17:23 2009
@@ -53,10 +53,10 @@
 
     private static final String STRING = "hello message";
     private static final String XML    =
-                                           "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
+ "<entry>\r\n"
-                                               + "    <id>entry:id</id>\r\n"
-                                               + "    <title type=\"text\">entry title</title>\r\n"
-                                               + "</entry>\r\n";
+                                           "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<entry>"
+                                               + "<id>entry:id</id>"
+                                               + "<title type=\"text\">entry title</title>"
+                                               + "</entry>";
     private static final String JSON   =
                                            "{\"entry\": {\n" + "  \"id\": {\"$\": \"entry:id\"},\n"
                                                + "  \"title\": {\n"

Modified: incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/providers/entity/JAXBElementProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/providers/entity/JAXBElementProviderTest.java?rev=816771&r1=816770&r2=816771&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/providers/entity/JAXBElementProviderTest.java
(original)
+++ incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/providers/entity/JAXBElementProviderTest.java
Fri Sep 18 20:17:23 2009
@@ -61,18 +61,18 @@
                                                                 "<JAXBXmlRootElement><id>ID</id><name>NAME</name></JAXBXmlRootElement>";
     private static final byte[] JAXBXmlRootElement_BYTES    = JAXBXmlRootElement_REQUEST.getBytes();
     private static final String JAXBXmlRootElement_RESPONSE =
-                                                                "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\r\n" + "<JAXBXmlRootElement>\r\n"
-                                                                    + "    <id>ID</id>\r\n"
-                                                                    + "    <name>NAME</name>\r\n"
+                                                                "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>" + "<JAXBXmlRootElement>"
+                                                                    + "<id>ID</id>"
+                                                                    + "<name>NAME</name>"
                                                                     + "</JAXBXmlRootElement>";
 
     private static final String JAXBXmlType_REQUEST         =
                                                                 "<JAXBXmlType><id>ID</id><name>NAME</name></JAXBXmlType>";
     private static final byte[] JAXBXmlType_REQUEST_BYTES   = JAXBXmlType_REQUEST.getBytes();
     private static final String JAXBXmlType_RESPONSE        =
-                                                                "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\r\n" + "<JAXBXmlType>\r\n"
-                                                                    + "    <id>ID</id>\r\n"
-                                                                    + "    <name>NAME</name>\r\n"
+                                                                "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>" + "<JAXBXmlType>"
+                                                                    + "<id>ID</id>"
+                                                                    + "<name>NAME</name>"
                                                                     + "</JAXBXmlType>";
 
     JAXBElement<AtomFeed>       atomfeed;



Mime
View raw message