wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From el...@apache.org
Subject svn commit: r812918 - in /incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/atom: AbstractAtomEntryProvider.java AbstractAtomFeedProvider.java AtomEntrySyndEntryProvider.java AtomFeedSyndFeedProvider.java
Date Wed, 09 Sep 2009 12:13:17 GMT
Author: elman
Date: Wed Sep  9 12:13:17 2009
New Revision: 812918

URL: http://svn.apache.org/viewvc?rev=812918&view=rev
Log:
More redundant providers. See [WINK-169]

Removed:
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/atom/AbstractAtomEntryProvider.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/atom/AbstractAtomFeedProvider.java
Modified:
    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

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=812918&r1=812917&r2=812918&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
Wed Sep  9 12:13:17 2009
@@ -29,11 +29,13 @@
 import javax.ws.rs.Consumes;
 import javax.ws.rs.Produces;
 import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.ext.MessageBodyReader;
 import javax.ws.rs.ext.MessageBodyWriter;
 import javax.ws.rs.ext.Provider;
+import javax.ws.rs.ext.Providers;
 
 import org.apache.wink.common.model.atom.AtomEntry;
 import org.apache.wink.common.model.synd.SyndEntry;
@@ -41,8 +43,11 @@
 @Provider
 @Consumes(MediaType.APPLICATION_ATOM_XML)
 @Produces(MediaType.APPLICATION_ATOM_XML)
-public class AtomEntrySyndEntryProvider extends AbstractAtomEntryProvider<SyndEntry>
implements
-    MessageBodyReader<SyndEntry>, MessageBodyWriter<SyndEntry> {
+public class AtomEntrySyndEntryProvider implements MessageBodyReader<SyndEntry>,
+    MessageBodyWriter<SyndEntry> {
+
+    @Context
+    private Providers providers;
 
     public boolean isReadable(Class<?> type,
                               Type genericType,
@@ -57,13 +62,15 @@
                               MediaType mediaType,
                               MultivaluedMap<String, String> httpHeaders,
                               InputStream entityStream) throws IOException, WebApplicationException
{
+        MessageBodyReader<AtomEntry> reader =
+            providers.getMessageBodyReader(AtomEntry.class, genericType, annotations, mediaType);
         AtomEntry entry =
-            readEntry(AtomEntry.class,
-                      genericType,
-                      annotations,
-                      mediaType,
-                      httpHeaders,
-                      entityStream);
+            reader.readFrom(AtomEntry.class,
+                            genericType,
+                            annotations,
+                            mediaType,
+                            httpHeaders,
+                            entityStream);
         return entry.toSynd(new SyndEntry());
     }
 
@@ -82,12 +89,23 @@
                         MultivaluedMap<String, Object> httpHeaders,
                         OutputStream entityStream) throws IOException, WebApplicationException
{
         AtomEntry entry = new AtomEntry(t);
-        writeEntry(entry,
-                   AtomEntry.class,
-                   genericType,
-                   annotations,
-                   mediaType,
-                   httpHeaders,
-                   entityStream);
+        MessageBodyWriter<AtomEntry> writer =
+            providers.getMessageBodyWriter(AtomEntry.class, genericType, annotations, mediaType);
+
+        writer.writeTo(entry,
+                       AtomEntry.class,
+                       genericType,
+                       annotations,
+                       mediaType,
+                       httpHeaders,
+                       entityStream);
+    }
+
+    public long getSize(SyndEntry t,
+                        Class<?> type,
+                        Type genericType,
+                        Annotation[] annotations,
+                        MediaType mediaType) {
+        return -1;
     }
 }

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=812918&r1=812917&r2=812918&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
Wed Sep  9 12:13:17 2009
@@ -29,11 +29,13 @@
 import javax.ws.rs.Consumes;
 import javax.ws.rs.Produces;
 import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.ext.MessageBodyReader;
 import javax.ws.rs.ext.MessageBodyWriter;
 import javax.ws.rs.ext.Provider;
+import javax.ws.rs.ext.Providers;
 
 import org.apache.wink.common.model.atom.AtomFeed;
 import org.apache.wink.common.model.synd.SyndFeed;
@@ -41,8 +43,11 @@
 @Provider
 @Consumes(MediaType.APPLICATION_ATOM_XML)
 @Produces(MediaType.APPLICATION_ATOM_XML)
-public class AtomFeedSyndFeedProvider extends AbstractAtomFeedProvider<SyndFeed> implements
-    MessageBodyReader<SyndFeed>, MessageBodyWriter<SyndFeed> {
+public class AtomFeedSyndFeedProvider implements MessageBodyReader<SyndFeed>,
+    MessageBodyWriter<SyndFeed> {
+
+    @Context
+    private Providers providers;
 
     public boolean isReadable(Class<?> type,
                               Type genericType,
@@ -57,8 +62,16 @@
                              MediaType mediaType,
                              MultivaluedMap<String, String> httpHeaders,
                              InputStream entityStream) throws IOException, WebApplicationException
{
+
+        MessageBodyReader<AtomFeed> reader =
+            providers.getMessageBodyReader(AtomFeed.class, genericType, annotations, mediaType);
         AtomFeed feed =
-            readFeed(AtomFeed.class, genericType, annotations, mediaType, httpHeaders, entityStream);
+            reader.readFrom(AtomFeed.class,
+                            genericType,
+                            annotations,
+                            mediaType,
+                            httpHeaders,
+                            entityStream);
         return feed.toSynd(new SyndFeed());
     }
 
@@ -77,12 +90,22 @@
                         MultivaluedMap<String, Object> httpHeaders,
                         OutputStream entityStream) throws IOException, WebApplicationException
{
         AtomFeed feed = new AtomFeed(t);
-        writeFeed(feed,
-                  AtomFeed.class,
-                  genericType,
-                  annotations,
-                  mediaType,
-                  httpHeaders,
-                  entityStream);
+        MessageBodyWriter<AtomFeed> writer =
+            providers.getMessageBodyWriter(AtomFeed.class, genericType, annotations, mediaType);
+        writer.writeTo(feed,
+                       AtomFeed.class,
+                       genericType,
+                       annotations,
+                       mediaType,
+                       httpHeaders,
+                       entityStream);
+    }
+
+    public long getSize(SyndFeed t,
+                        Class<?> type,
+                        Type genericType,
+                        Annotation[] annotations,
+                        MediaType mediaType) {
+        return -1;
     }
 }



Mime
View raw message