incubator-wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: r888126 - in /incubator/wink/trunk: wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/ wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/atom/ wink-common/src/main/java/org/apache/wink/commo...
Date Mon, 07 Dec 2009 20:38:45 GMT
Author: rott
Date: Mon Dec  7 20:38:44 2009
New Revision: 888126

URL: http://svn.apache.org/viewvc?rev=888126&view=rev
Log:
WINK-234: improve debug and processing for no writer found in providers

Modified:
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/FormatedExceptionProvider.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/atom/AtomEntrySyndEntryProvider.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/atom/AtomFeedSyndFeedProvider.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/csv/CsvSyndFeedSerializerProvider.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/ProvidersRegistry.java
    incubator/wink/trunk/wink-providers/wink-json-provider/src/main/java/org/apache/wink/providers/json/JsonArrayProvider.java
    incubator/wink/trunk/wink-providers/wink-json-provider/src/main/java/org/apache/wink/providers/json/JsonProvider.java
    incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/providers/entity/html/HtmlSyndEntryProvider.java
    incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/providers/entity/html/HtmlSyndFeedProvider.java

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/FormatedExceptionProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/FormatedExceptionProvider.java?rev=888126&r1=888125&r2=888126&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/FormatedExceptionProvider.java
(original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/FormatedExceptionProvider.java
Mon Dec  7 20:38:44 2009
@@ -65,6 +65,7 @@
                                Type genericType,
                                Annotation[] annotations,
                                MediaType mediaType) {
+        // do not check for non-null writer here; writeTo will handle this situation
         return Throwable.class.isAssignableFrom(type);
     }
 

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/atom/AtomEntrySyndEntryProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/atom/AtomEntrySyndEntryProvider.java?rev=888126&r1=888125&r2=888126&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/atom/AtomEntrySyndEntryProvider.java
(original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/atom/AtomEntrySyndEntryProvider.java
Mon Dec  7 20:38:44 2009
@@ -79,7 +79,9 @@
                                Type genericType,
                                Annotation[] annotations,
                                MediaType mediaType) {
-        return type == SyndEntry.class;
+        MessageBodyWriter<AtomEntry> writer =
+            providers.getMessageBodyWriter(AtomEntry.class, genericType, annotations, mediaType);
+        return ((type.isAssignableFrom(SyndEntry.class)) && (writer != null));
     }
 
     public void writeTo(SyndEntry t,
@@ -93,6 +95,8 @@
         MessageBodyWriter<AtomEntry> writer =
             providers.getMessageBodyWriter(AtomEntry.class, genericType, annotations, mediaType);
 
+        // already checked for non-null writer in isWriteable
+        
         writer.writeTo(entry,
                        AtomEntry.class,
                        genericType,

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/atom/AtomFeedSyndFeedProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/atom/AtomFeedSyndFeedProvider.java?rev=888126&r1=888125&r2=888126&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/atom/AtomFeedSyndFeedProvider.java
(original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/atom/AtomFeedSyndFeedProvider.java
Mon Dec  7 20:38:44 2009
@@ -46,7 +46,7 @@
 @Produces( {MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON, MediaTypeUtils.JAVASCRIPT})
 public class AtomFeedSyndFeedProvider implements MessageBodyReader<SyndFeed>,
     MessageBodyWriter<SyndFeed> {
-
+    
     @Context
     private Providers providers;
 
@@ -80,7 +80,9 @@
                                Type genericType,
                                Annotation[] annotations,
                                MediaType mediaType) {
-        return type == SyndFeed.class;
+        MessageBodyWriter<AtomFeed> writer =
+            providers.getMessageBodyWriter(AtomFeed.class, genericType, annotations, mediaType);
+        return ((type.isAssignableFrom(SyndFeed.class)) && (writer != null));
     }
 
     public void writeTo(SyndFeed t,
@@ -93,6 +95,9 @@
         AtomFeed feed = new AtomFeed(t);
         MessageBodyWriter<AtomFeed> writer =
             providers.getMessageBodyWriter(AtomFeed.class, genericType, annotations, mediaType);
+
+        // already checked for non-null writer in isWriteable
+        
         writer.writeTo(feed,
                        AtomFeed.class,
                        genericType,

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/csv/CsvSyndFeedSerializerProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/csv/CsvSyndFeedSerializerProvider.java?rev=888126&r1=888125&r2=888126&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/csv/CsvSyndFeedSerializerProvider.java
(original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/csv/CsvSyndFeedSerializerProvider.java
Mon Dec  7 20:38:44 2009
@@ -47,7 +47,7 @@
 @Provider
 @Produces("text/csv")
 public class CsvSyndFeedSerializerProvider implements MessageBodyWriter<SyndFeed> {
-
+    
     private final static String[] EMPTY_ARRAY = new String[0];
 
     @Context
@@ -65,7 +65,12 @@
                                Type genericType,
                                Annotation[] annotations,
                                MediaType mediaType) {
-        return SyndFeed.class.isAssignableFrom(type);
+        MessageBodyWriter<SyndFeedSerializer> messageBodyWriter =
+            providers.getMessageBodyWriter(SyndFeedSerializer.class,
+                                           genericType,
+                                           annotations,
+                                           mediaType);
+        return ((SyndFeed.class.isAssignableFrom(type)) && (messageBodyWriter !=
null));
     }
 
     public void writeTo(SyndFeed t,
@@ -81,6 +86,9 @@
                                            genericType,
                                            annotations,
                                            mediaType);
+        
+        // already checked for non-null writer in isWriteable
+        
         messageBodyWriter.writeTo(new SyndFeedSerializer(t),
                                   type,
                                   genericType,

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/ProvidersRegistry.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/ProvidersRegistry.java?rev=888126&r1=888125&r2=888126&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/ProvidersRegistry.java
(original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/ProvidersRegistry.java
Mon Dec  7 20:38:44 2009
@@ -408,19 +408,25 @@
             MessageBodyWriter<?> writer = factory.getInstance(runtimeContext);
             if (logger.isDebugEnabled()) {
                 List<Annotation> anns = (annotations == null) ? null : Arrays.asList(annotations);
-                logger.debug("Calling {}.isWritable( {}, {}, {}, {} )", new Object[] {writer,
type,
+                logger.debug("Calling {}.isWriteable( {}, {}, {}, {} )", new Object[] {writer,
type,
                     genericType, anns, mediaType});
             }
             if (writer.isWriteable(type, genericType, annotations, mediaType)) {
                 if (logger.isDebugEnabled()) {
                     List<Annotation> anns =
                         (annotations == null) ? null : Arrays.asList(annotations);
-                    logger.debug("{}.isWritable( {}, {}, {}, {} ) returned true", new Object[]
{
+                    logger.debug("{}.isWriteable( {}, {}, {}, {} ) returned true", new Object[]
{
                         writer, type, genericType, anns, mediaType});
                 }
                 return (MessageBodyWriter<T>)writer;
             }
         }
+        if (logger.isDebugEnabled()) {
+            List<Annotation> anns =
+                (annotations == null) ? null : Arrays.asList(annotations);
+            logger.debug("No MessageBodyWriter returned true for isWriteable( {}, {}, {},
{} )", new Object[] {
+                type, genericType, anns, mediaType});
+        }
         return null;
     }
 

Modified: incubator/wink/trunk/wink-providers/wink-json-provider/src/main/java/org/apache/wink/providers/json/JsonArrayProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-providers/wink-json-provider/src/main/java/org/apache/wink/providers/json/JsonArrayProvider.java?rev=888126&r1=888125&r2=888126&view=diff
==============================================================================
--- incubator/wink/trunk/wink-providers/wink-json-provider/src/main/java/org/apache/wink/providers/json/JsonArrayProvider.java
(original)
+++ incubator/wink/trunk/wink-providers/wink-json-provider/src/main/java/org/apache/wink/providers/json/JsonArrayProvider.java
Mon Dec  7 20:38:44 2009
@@ -71,6 +71,7 @@
                                Type genericType,
                                Annotation[] annotations,
                                MediaType mediaType) {
+        // TODO: use isAssignableFrom instead of == ?
         return type == JSONArray.class;
     }
 

Modified: incubator/wink/trunk/wink-providers/wink-json-provider/src/main/java/org/apache/wink/providers/json/JsonProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-providers/wink-json-provider/src/main/java/org/apache/wink/providers/json/JsonProvider.java?rev=888126&r1=888125&r2=888126&view=diff
==============================================================================
--- incubator/wink/trunk/wink-providers/wink-json-provider/src/main/java/org/apache/wink/providers/json/JsonProvider.java
(original)
+++ incubator/wink/trunk/wink-providers/wink-json-provider/src/main/java/org/apache/wink/providers/json/JsonProvider.java
Mon Dec  7 20:38:44 2009
@@ -71,6 +71,7 @@
                                Type genericType,
                                Annotation[] annotations,
                                MediaType mediaType) {
+        // TODO: use isAssignableFrom instead of == ?
         return type == JSONObject.class;
     }
 

Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/providers/entity/html/HtmlSyndEntryProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/providers/entity/html/HtmlSyndEntryProvider.java?rev=888126&r1=888125&r2=888126&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/providers/entity/html/HtmlSyndEntryProvider.java
(original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/providers/entity/html/HtmlSyndEntryProvider.java
Mon Dec  7 20:38:44 2009
@@ -54,7 +54,12 @@
                                Type genericType,
                                Annotation[] annotations,
                                MediaType mediaType) {
-        return SyndEntry.class.isAssignableFrom(type);
+        MessageBodyWriter<HtmlDescriptor> writer =
+            providers.getMessageBodyWriter(HtmlDescriptor.class,
+                                           HtmlDescriptor.class,
+                                           annotations,
+                                           mediaType);
+        return ((SyndEntry.class.isAssignableFrom(type)) && (writer != null));
     }
 
     public void writeTo(SyndEntry t,
@@ -71,6 +76,8 @@
                                            annotations,
                                            mediaType);
 
+        // already checked for non-null writer in isWriteable
+        
         writer.writeTo(new HtmlDescriptor(t),
                        HtmlDescriptor.class,
                        HtmlDescriptor.class,

Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/providers/entity/html/HtmlSyndFeedProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/providers/entity/html/HtmlSyndFeedProvider.java?rev=888126&r1=888125&r2=888126&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/providers/entity/html/HtmlSyndFeedProvider.java
(original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/providers/entity/html/HtmlSyndFeedProvider.java
Mon Dec  7 20:38:44 2009
@@ -54,7 +54,12 @@
                                Type genericType,
                                Annotation[] annotations,
                                MediaType mediaType) {
-        return SyndFeed.class.isAssignableFrom(type);
+        MessageBodyWriter<HtmlDescriptor> writer =
+            providers.getMessageBodyWriter(HtmlDescriptor.class,
+                                           HtmlDescriptor.class,
+                                           annotations,
+                                           mediaType);
+        return ((SyndFeed.class.isAssignableFrom(type)) && (writer != null));
     }
 
     public void writeTo(SyndFeed t,
@@ -71,6 +76,8 @@
                                            annotations,
                                            mediaType);
 
+        // already checked for non-null writer in isWriteable
+        
         writer.writeTo(new HtmlDescriptor(t),
                        HtmlDescriptor.class,
                        HtmlDescriptor.class,



Mime
View raw message