geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pra...@apache.org
Subject svn commit: r574591 - /geronimo/samples/trunk/samples/async-http/http-local-app/src/main/java/org/apache/geronimo/AsyncServlet.java
Date Tue, 11 Sep 2007 13:23:41 GMT
Author: prasad
Date: Tue Sep 11 06:23:41 2007
New Revision: 574591

URL: http://svn.apache.org/viewvc?rev=574591&view=rev
Log:
* remoteUrl can be passed as a request param

Modified:
    geronimo/samples/trunk/samples/async-http/http-local-app/src/main/java/org/apache/geronimo/AsyncServlet.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=574591&r1=574590&r2=574591&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 06:23:41 2007
@@ -52,8 +52,18 @@
 
 			Callback callback = new Callback(event);
 
+			if (request.getParameter("remoteUrl") != null){
+				remoteUrl = request.getParameter("remoteUrl");
+			}
+			
 			String remoteUri = request.getParameter("remoteUri");
+			if ( remoteUri == null){
+				remoteUri =  "/remoteApp/page";
+			}
 			HttpRequestMessage msgRequest = new HttpRequestMessage(remoteUri);
+			
+			// If the file being served has other URIs in it, like say images, 
+			// subsequent calls are made to the remote app. We don't want to set new delay times and
status codes then.
 			if (remoteUri.endsWith("page")) {
 				Integer[] params = generateRandomParams();
 				msgRequest.setParameter("sessionId", cometId);
@@ -64,9 +74,7 @@
 			}
 			msgRequest.setRequestMethod(HttpRequestMessage.REQUEST_GET);
 
-			System.out.println(remoteUrl);
 			URL url_connect = new URL(remoteUrl);
-			//URL url_connect = new URL("http://puffyshirt:8080");
 
 			AsyncHttpClient ahc = new AsyncHttpClient(url_connect, callback);
 			try {
@@ -88,7 +96,7 @@
 		Random generator = new Random();
 
 		// generate a random delay between 10ms and 250 ms
-		int delay = generator.nextInt(240) + 10;
+		int delay = generator.nextInt(250) + 10;
 		params[0] = new Integer(delay);
 
 		// generate randomly one of http status codes.



Mime
View raw message