You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@abdera.apache.org by jm...@apache.org on 2008/02/26 20:31:36 UTC

svn commit: r631347 - /incubator/abdera/java/trunk/extensions/json/src/main/java/org/apache/abdera/ext/json/JSONServlet.java

Author: jmsnell
Date: Tue Feb 26 11:31:34 2008
New Revision: 631347

URL: http://svn.apache.org/viewvc?rev=631347&view=rev
Log:
minor improvements

Modified:
    incubator/abdera/java/trunk/extensions/json/src/main/java/org/apache/abdera/ext/json/JSONServlet.java

Modified: incubator/abdera/java/trunk/extensions/json/src/main/java/org/apache/abdera/ext/json/JSONServlet.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/json/src/main/java/org/apache/abdera/ext/json/JSONServlet.java?rev=631347&r1=631346&r2=631347&view=diff
==============================================================================
--- incubator/abdera/java/trunk/extensions/json/src/main/java/org/apache/abdera/ext/json/JSONServlet.java (original)
+++ incubator/abdera/java/trunk/extensions/json/src/main/java/org/apache/abdera/ext/json/JSONServlet.java Tue Feb 26 11:31:34 2008
@@ -31,8 +31,13 @@
 import org.apache.abdera.protocol.client.AbderaClient;
 import org.apache.abdera.protocol.client.ClientResponse;
 import org.apache.abdera.protocol.client.RequestOptions;
-import org.apache.abdera.writer.Writer;
 
+/**
+ * Servlet that will do an HTTP GET to retrieve an Atom document then
+ * convert that into a JSON doc.  The URL pattern is simple:
+ * 
+ * http://.../servlet/path/{url}
+ */
 @SuppressWarnings("unchecked") 
 public class JSONServlet 
   extends HttpServlet {
@@ -69,8 +74,6 @@
     Abdera abdera = getAbdera();
     AbderaClient client = new AbderaClient(abdera);
     
-    Writer json = abdera.getWriterFactory().getWriter("json");
-
     RequestOptions options = client.getDefaultRequestOptions();
     if (request.getHeader("If-Match") != null)
       options.setIfMatch(request.getHeader("If-Match"));
@@ -95,7 +98,7 @@
           if (doc.getLastModified() != null)
             response.setDateHeader("Last-Modified", doc.getLastModified().getTime());
           OutputStream out = response.getOutputStream();
-          json.writeTo(doc.getRoot(), out);
+          doc.writeTo("json",out);
         } catch (Exception e) {
           response.sendError(500);
           return;