diff options
Diffstat (limited to 'example-async-rest/async-rest-webapp')
3 files changed, 27 insertions, 11 deletions
diff --git a/example-async-rest/async-rest-webapp/src/main/webapp/WEB-INF/jetty-web.xml b/example-async-rest/async-rest-webapp/src/main/webapp/WEB-INF/jetty-web.xml new file mode 100644 index 0000000000..572942fd5c --- /dev/null +++ b/example-async-rest/async-rest-webapp/src/main/webapp/WEB-INF/jetty-web.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure.dtd"> + +<!-- +This is the jetty specific web application configuration file. When starting +a Web Application, the WEB-INF/jetty-web.xml file is looked for and if found, treated +as a org.eclipse.jetty.server.server.xml.XmlConfiguration file and is applied to the +org.eclipse.jetty.servlet.WebApplicationContext object +--> + +<Configure class="org.eclipse.jetty.webapp.WebAppContext"> + <Get class="org.eclipse.jetty.util.log.Log" name="rootLogger"> + <Call name="warn"><Arg>async-rest webapp is deployed. DO NOT USE IN PRODUCTION!</Arg></Call> + </Get> +</Configure> diff --git a/example-async-rest/async-rest-webapp/src/main/webapp/index.html b/example-async-rest/async-rest-webapp/src/main/webapp/index.html index f92f7f661d..e7f5d0a2c0 100644 --- a/example-async-rest/async-rest-webapp/src/main/webapp/index.html +++ b/example-async-rest/async-rest-webapp/src/main/webapp/index.html @@ -10,7 +10,7 @@ <p> This demo calls the EBay WS API both synchronously and asynchronously, to obtain items matching each of the keywords passed on the query -string. The time the request thread is head is displayed for both. +string. The time the request thread is held by the servlet is displayed in red for both. </p> <table width='100%'> @@ -34,5 +34,11 @@ string. The time the request thread is head is displayed for both. </tr> </table> +By the use of Asynchronous Servlets and the Jetty Asychronous client, the server is able to release the thread (green) while +waiting for the response from Ebay. This thread goes back into the thread pool and can service many other requests during the wait. +This greatly reduces the number of threads needed, which in turn greatly reduces the memory requirements of the server. +<p> +Press reload to see even better results after JIT and TCP/IP warmup! + </body> </html> diff --git a/example-async-rest/async-rest-webapp/src/test/java/org/eclipse/jetty/example/asyncrest/DemoServer.java b/example-async-rest/async-rest-webapp/src/test/java/org/eclipse/jetty/example/asyncrest/DemoServer.java index 667c14568d..91471d50da 100644 --- a/example-async-rest/async-rest-webapp/src/test/java/org/eclipse/jetty/example/asyncrest/DemoServer.java +++ b/example-async-rest/async-rest-webapp/src/test/java/org/eclipse/jetty/example/asyncrest/DemoServer.java @@ -18,9 +18,7 @@ package org.eclipse.jetty.example.asyncrest; -import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.server.nio.SelectChannelConnector; import org.eclipse.jetty.webapp.WebAppContext; public class DemoServer @@ -30,16 +28,13 @@ public class DemoServer { String jetty_home = System.getProperty("jetty.home","."); - Server server = new Server(); - - Connector connector=new SelectChannelConnector(); - connector.setPort(Integer.getInteger("jetty.port",8080).intValue()); - server.setConnectors(new Connector[]{connector}); - + Server server = new Server(Integer.getInteger("jetty.port",8080).intValue()); + WebAppContext webapp = new WebAppContext(); webapp.setContextPath("/"); - webapp.setWar(jetty_home+"/target/example-async-rest-webapp-8.0.0.M0-SNAPSHOT"); - + webapp.setWar(jetty_home+"/target/async-rest/"); + webapp.setParentLoaderPriority(true); + webapp.setServerClasses(new String[]{}); server.setHandler(webapp); server.start(); |