abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1176512 - in /abdera/abdera2: common/src/main/java/org/apache/abdera2/common/protocol/servlet/async/ test/src/main/java/org/apache/abdera2/test/activities/server/
Date Tue, 27 Sep 2011 18:42:13 GMT
Author: jmsnell
Date: Tue Sep 27 18:42:13 2011
New Revision: 1176512

URL: http://svn.apache.org/viewvc?rev=1176512&view=rev
Log: (empty)

Modified:
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/async/AbderaChannelServlet.java
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/activities/server/AsyncBasicTest.java
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/activities/server/TestChannelServlet.java

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/async/AbderaChannelServlet.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/async/AbderaChannelServlet.java?rev=1176512&r1=1176511&r2=1176512&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/async/AbderaChannelServlet.java
(original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/async/AbderaChannelServlet.java
Tue Sep 27 18:42:13 2011
@@ -71,13 +71,11 @@ public abstract class AbderaChannelServl
                 context.addListener(
                   new javax.servlet.AsyncListener() {
                     public void onComplete(AsyncEvent event) throws IOException {
-                      System.out.println("on complete");
                       try {
                         receiver.stopListening(listener);
                       } catch (Throwable t) {}
                     }
                     public void onError(AsyncEvent event) throws IOException {
-                      System.out.println("on error");
                       event.getThrowable().printStackTrace();
                       try {
                         receiver.stopListening(listener);
@@ -87,7 +85,6 @@ public abstract class AbderaChannelServl
                         throws IOException {
                     }
                     public void onTimeout(AsyncEvent event) throws IOException {
-                      System.out.println("on timeout");
                       try {
                         receiver.stopListening(listener);
                       } catch (Throwable t) {}
@@ -137,14 +134,15 @@ public abstract class AbderaChannelServl
     
     public void afterItems() {
       if (!done) {
-      try {
-        finish();
-        getResponse().flushBuffer();
-      } catch (Throwable t) {
-        // whoops, must have lost the connection before the request completed.
-      }
-      context.complete();
-      done = true;
+        try {
+          finish();
+          getResponse().flushBuffer();
+          context.complete();
+        } catch (Throwable t) {
+          // whoops, must have lost the connection before the request completed.
+        } finally {
+          done = true;
+        }
       }
     }
     

Modified: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/activities/server/AsyncBasicTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/activities/server/AsyncBasicTest.java?rev=1176512&r1=1176511&r2=1176512&view=diff
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/activities/server/AsyncBasicTest.java
(original)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/activities/server/AsyncBasicTest.java
Tue Sep 27 18:42:13 2011
@@ -87,12 +87,10 @@ public class AsyncBasicTest {
     @Test
     public void testPostEntry() throws IOException {
       
-      
         try {
           Thread.sleep(20 * 1000);
         } catch (Throwable t) {}
       
-      
         Activity activity = new Activity();
         activity.setId("http://localhost:9002/sample/foo");
         activity.setTitle("test entry");

Modified: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/activities/server/TestChannelServlet.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/activities/server/TestChannelServlet.java?rev=1176512&r1=1176511&r2=1176512&view=diff
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/activities/server/TestChannelServlet.java
(original)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/activities/server/TestChannelServlet.java
Tue Sep 27 18:42:13 2011
@@ -1,6 +1,5 @@
 package org.apache.abdera2.test.activities.server;
 
-import java.io.IOException;
 import java.io.Writer;
 
 import javax.servlet.AsyncContext;
@@ -28,15 +27,8 @@ public class TestChannelServlet 
   protected AsyncListener<ASObject> createListener(final AsyncContext context) {
     return new AsyncListener<ASObject>(context) {
 
-      public void beforeItems() {
-        try {
-          HttpServletResponse response = 
-            (HttpServletResponse) context.getResponse();
-          Writer writer = response.getWriter();
-          writer.write("{\"items\":[");
-          response.flushBuffer();
-        } catch (IOException e) {}
-      }
+      public void beforeItems() {}
+      protected void finish() {}
       public void onItem(ASObject t) {
         try {
           HttpServletResponse response = 
@@ -44,17 +36,9 @@ public class TestChannelServlet 
           Writer writer = response.getWriter();
           IO.get().write(t,writer);
           response.flushBuffer();
+          context.complete(); // close out the request, make the user come back for more
         } catch (Throwable e) {}
       }
-      protected void finish() {
-        try {
-          HttpServletResponse response = 
-            (HttpServletResponse) context.getResponse();
-          Writer writer = response.getWriter();
-          writer.write("]}");
-          response.flushBuffer();
-        } catch (IOException e) {}
-      }
     };
   }
 



Mime
View raw message