geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pra...@apache.org
Subject svn commit: r574676 - in /geronimo/samples/trunk/samples/async-http/http-local-app/src/main/java/org/apache/geronimo: AsyncServlet.java Callback.java
Date Tue, 11 Sep 2007 19:36:22 GMT
Author: prasad
Date: Tue Sep 11 12:36:22 2007
New Revision: 574676

URL: http://svn.apache.org/viewvc?rev=574676&view=rev
Log:
* handle onTimeout()

Modified:
    geronimo/samples/trunk/samples/async-http/http-local-app/src/main/java/org/apache/geronimo/AsyncServlet.java
    geronimo/samples/trunk/samples/async-http/http-local-app/src/main/java/org/apache/geronimo/Callback.java

Modified: geronimo/samples/trunk/samples/async-http/http-local-app/src/main/java/org/apache/geronimo/AsyncServlet.java
URL: http://svn.apache.org/viewvc/geronimo/samples/trunk/samples/async-http/http-local-app/src/main/java/org/apache/geronimo/AsyncServlet.java?rev=574676&r1=574675&r2=574676&view=diff
==============================================================================
--- geronimo/samples/trunk/samples/async-http/http-local-app/src/main/java/org/apache/geronimo/AsyncServlet.java
(original)
+++ geronimo/samples/trunk/samples/async-http/http-local-app/src/main/java/org/apache/geronimo/AsyncServlet.java
Tue Sep 11 12:36:22 2007
@@ -67,16 +67,17 @@
 			if (remoteUri.endsWith("page")) {
 				Integer[] params = generateRandomParams();
 				msgRequest.setParameter("sessionId", cometId);
-				msgRequest.setParameter("delay", params[0].toString());
-				msgRequest.setParameter("code", params[1].toString());
-				System.out.println("sessionId:" + cometId + "; delay:"
+				msgRequest.setParameter("delay", params[0].toString());				
+   			    msgRequest.setParameter("code", params[1].toString());
+								
+                System.out.println("sessionId:" + cometId + "; delay:"
 						+ params[0] + "; code:" + params[1]);
 			}
 			msgRequest.setRequestMethod(HttpRequestMessage.REQUEST_GET);
 
 			URL url_connect = new URL(remoteUrl);
 
-			AsyncHttpClient ahc = new AsyncHttpClient(url_connect, callback);
+			AsyncHttpClient ahc = new AsyncHttpClient(url_connect, callback, 1000, 1000);
 			try {
 				ahc.connect();
 				ahc.sendRequest(msgRequest);

Modified: geronimo/samples/trunk/samples/async-http/http-local-app/src/main/java/org/apache/geronimo/Callback.java
URL: http://svn.apache.org/viewvc/geronimo/samples/trunk/samples/async-http/http-local-app/src/main/java/org/apache/geronimo/Callback.java?rev=574676&r1=574675&r2=574676&view=diff
==============================================================================
--- geronimo/samples/trunk/samples/async-http/http-local-app/src/main/java/org/apache/geronimo/Callback.java
(original)
+++ geronimo/samples/trunk/samples/async-http/http-local-app/src/main/java/org/apache/geronimo/Callback.java
Tue Sep 11 12:36:22 2007
@@ -5,6 +5,8 @@
 
 import java.io.IOException;
 import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.util.Date;
 
 import javax.servlet.http.HttpServletResponse;
 
@@ -26,6 +28,7 @@
 	}
 
 	public void onResponse(HttpResponseMessage message) {
+		System.out.println("callback response");
 		this.message = message;
 
 		HttpServletResponse response = event.getHttpServletResponse();
@@ -47,21 +50,29 @@
 	}
 
 	public void onException(Throwable cause) {
+		System.out.println("callback exception");
 		throwable = cause;
-		exception = true;		
+		exception = true;
 		// closeEvent();
 	}
 
 	public void onClosed() {
-		closed = true;		
+		System.out.println("callback closed");
+		closed = true;
 		closeEvent();
 	}
 
 	public void onTimeout() {
+		System.out.println("callback timedout");
 		timeout = true;
 		HttpServletResponse response = event.getHttpServletResponse();
 		try {
-			response.sendError(HttpServletResponse.SC_REQUEST_TIMEOUT);
+			response.setContentType("text/plain");
+			response.setStatus(HttpServletResponse.SC_REQUEST_TIMEOUT);
+			PrintWriter out = response.getWriter();
+			out.println("Request Timed out!");
+			out.println(new Date().toString());
+			out.close();
 		} catch (IOException e) {
 			// TODO Auto-generated catch block
 			e.printStackTrace();



Mime
View raw message