Repository: activemq
Updated Branches:
  refs/heads/master 505916b92 -> 0f492f3b4


http://git-wip-us.apache.org/repos/asf/activemq/blob/f44c3d20/activemq-web-demo/src/test/java/org/apache/activemq/web/AjaxTest.java
----------------------------------------------------------------------
diff --git 
a/activemq-web-demo/src/test/java/org/apache/activemq/web/AjaxTest.java 
b/activemq-web-demo/src/test/java/org/apache/activemq/web/AjaxTest.java
index 8763299..7af9fe5 100644
--- a/activemq-web-demo/src/test/java/org/apache/activemq/web/AjaxTest.java
+++ b/activemq-web-demo/src/test/java/org/apache/activemq/web/AjaxTest.java
@@ -16,9 +16,15 @@
  */
 package org.apache.activemq.web;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayInputStream;
 import java.net.SocketTimeoutException;
 import java.util.HashMap;
+import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import javax.jms.Message;
 import javax.jms.MessageProducer;
@@ -27,43 +33,20 @@ import org.apache.activemq.transport.stomp.Stomp;
 import org.apache.activemq.transport.stomp.StompConnection;
 import org.apache.activemq.transport.stomp.StompFrame;
 import org.apache.commons.lang.StringUtils;
-import org.eclipse.jetty.client.ContentExchange;
 import org.eclipse.jetty.client.HttpClient;
-import org.eclipse.jetty.io.Buffer;
-import org.eclipse.jetty.io.ByteArrayBuffer;
+import org.eclipse.jetty.client.api.Request;
+import org.eclipse.jetty.client.api.Result;
+import org.eclipse.jetty.client.util.BufferingResponseListener;
+import org.eclipse.jetty.client.util.InputStreamContentProvider;
+import org.eclipse.jetty.http.HttpHeader;
+import org.eclipse.jetty.http.HttpMethod;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.junit.Assert.*;
-
 public class AjaxTest extends JettyTestSupport {
     private static final Logger LOG = LoggerFactory.getLogger(AjaxTest.class);
 
-    private class AjaxTestContentExchange extends ContentExchange  {
-        private HashMap<String,String> headers;
-        private String responseContent;
-
-        AjaxTestContentExchange() {
-            super(true);
-            this.headers = new HashMap<String,String>();
-            this.responseContent = "";
-        }
-        protected void onResponseContent( Buffer content ) {
-            this.responseContent += content.toString();
-        }
-        protected void onResponseHeader( Buffer name, Buffer value ) {
-          headers.put( name.toString(), value.toString() );
-        }
-        public String getJsessionId() {
-            String cookie = headers.get( "Set-Cookie" );
-            String[] cookie_parts = cookie.split( ";" );
-            return cookie_parts[0];
-        }
-        public String getResponseContent() {
-            return responseContent;
-        }
-    }
 
     public void assertContains( String expected, String actual ) {
         assertTrue( "'"+actual+"' does not contain expected fragment 
'"+expected+"'", actual.indexOf( expected ) != -1 );
@@ -79,56 +62,37 @@ public class AjaxTest extends JettyTestSupport {
         int port = getPort();
 
         HttpClient httpClient = new HttpClient();
-        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
         httpClient.start();
 
         // client 1 subscribes to a queue
         LOG.debug( "SENDING LISTEN" );
-        AjaxTestContentExchange contentExchange = new 
AjaxTestContentExchange();
-        contentExchange.setMethod( "POST" );
-        contentExchange.setURL("http://localhost:"; + port + "/amq");
-        contentExchange.setRequestContent( new 
ByteArrayBuffer("destination=queue://test&type=listen&message=handler") );
-        contentExchange.setRequestContentType( 
"application/x-www-form-urlencoded; charset=UTF-8" );
-        httpClient.send(contentExchange);
-        contentExchange.waitForDone();
-        String jsessionid = contentExchange.getJsessionId();
+        String sessionId = subscribe(httpClient, port, 
"destination=queue://test&type=listen&message=handler");
 
         // client 1 polls for messages
         LOG.debug( "SENDING POLL" );
-        AjaxTestContentExchange poll = new AjaxTestContentExchange();
-        poll.setMethod( "GET" );
-        poll.setURL("http://localhost:"; + port + "/amq?timeout=5000");
-        poll.setRequestHeader( "Cookie", jsessionid );
-        httpClient.send( poll );
+        final StringBuffer buf = new StringBuffer();
+        final CountDownLatch latch =
+                asyncRequest(httpClient, "http://localhost:"; + port + 
"/amq?timeout=5000", buf, sessionId);
 
         // while client 1 is polling, client 2 sends messages to the queue
         LOG.debug( "SENDING MESSAGES" );
-        contentExchange = new AjaxTestContentExchange();
-        contentExchange.setMethod( "POST" );
-        contentExchange.setURL("http://localhost:"; + port + "/amq");
-        contentExchange.setRequestContent( new ByteArrayBuffer(
-            "destination=queue://test&type=send&message=msg1&"+
-            "d1=queue://test&t1=send&m1=msg2&"+
-            "d2=queue://test&t2=send&m2=msg3"
-        ) );
-        contentExchange.setRequestContentType( 
"application/x-www-form-urlencoded; charset=UTF-8" );
-        httpClient.send(contentExchange);
-        contentExchange.waitForDone();
+        sendMessages(httpClient, port, 
("destination=queue://test&type=send&message=msg1&"+
+                         "d1=queue://test&t1=send&m1=msg2&"+
+                         "d2=queue://test&t2=send&m2=msg3").getBytes());
+
         LOG.debug( "DONE POSTING MESSAGES" );
 
         // wait for poll to finish
-        poll.waitForDone();
-        String response = poll.getResponseContent();
+       latch.await();
+       String response = buf.toString();
 
         // messages might not all be delivered during the 1st poll.  We need 
to check again.
-        poll = new AjaxTestContentExchange();
-        poll.setMethod( "GET" );
-        poll.setURL("http://localhost:"; + port + "/amq?timeout=5000");
-        poll.setRequestHeader( "Cookie", jsessionid );
-        httpClient.send( poll );
-        poll.waitForDone();
-
-        String fullResponse = response + poll.getResponseContent();
+       final StringBuffer buf2 = new StringBuffer();
+       final CountDownLatch latch2 =
+               asyncRequest(httpClient, "http://localhost:"; + port + 
"/amq?timeout=5000", buf2, sessionId);
+       latch2.await();
+
+        String fullResponse = response + buf2.toString();
         LOG.debug( "full response : " + fullResponse );
         assertContains( "<response id='handler' destination='queue://test' 
>msg1</response>", fullResponse );
         assertContains( "<response id='handler' destination='queue://test' 
>msg2</response>", fullResponse );
@@ -144,56 +108,37 @@ public class AjaxTest extends JettyTestSupport {
         int port = getPort();
 
         HttpClient httpClient = new HttpClient();
-        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
         httpClient.start();
 
         // client 1 subscribes to a queue
         LOG.debug( "SENDING LISTEN" );
-        AjaxTestContentExchange contentExchange = new 
AjaxTestContentExchange();
-        contentExchange.setMethod( "POST" );
-        contentExchange.setURL("http://localhost:"; + port + "/amq");
-        contentExchange.setRequestContent( new 
ByteArrayBuffer("destination=topic://test&type=listen&message=handler") );
-        contentExchange.setRequestContentType( 
"application/x-www-form-urlencoded; charset=UTF-8" );
-        httpClient.send(contentExchange);
-        contentExchange.waitForDone();
-        String jsessionid = contentExchange.getJsessionId();
+        String sessionId = subscribe(httpClient, port, 
"destination=topic://test&type=listen&message=handler");
 
         // client 1 polls for messages
         LOG.debug( "SENDING POLL" );
-        AjaxTestContentExchange poll = new AjaxTestContentExchange();
-        poll.setMethod( "GET" );
-        poll.setURL("http://localhost:"; + port + "/amq?timeout=5000");
-        poll.setRequestHeader( "Cookie", jsessionid );
-        httpClient.send( poll );
+        final StringBuffer buf = new StringBuffer();
+        final CountDownLatch latch =
+                asyncRequest(httpClient, "http://localhost:"; + port + 
"/amq?timeout=5000", buf, sessionId);
 
         // while client 1 is polling, client 2 sends messages to the queue
         LOG.debug( "SENDING MESSAGES" );
-        contentExchange = new AjaxTestContentExchange();
-        contentExchange.setMethod( "POST" );
-        contentExchange.setURL("http://localhost:"; + port + "/amq");
-        contentExchange.setRequestContent( new ByteArrayBuffer(
-            "destination=topic://test&type=send&message=msg1&"+
-            "d1=topic://test&t1=send&m1=msg2&"+
-            "d2=topic://test&t2=send&m2=msg3"
-        ) );
-        contentExchange.setRequestContentType( 
"application/x-www-form-urlencoded; charset=UTF-8" );
-        httpClient.send(contentExchange);
-        contentExchange.waitForDone();
-        LOG.debug( "DONE POSTING MESSAGES" );
+        sendMessages(httpClient, port, 
("destination=topic://test&type=send&message=msg1&"+
+                "d1=topic://test&t1=send&m1=msg2&"+
+                "d2=topic://test&t2=send&m2=msg3").getBytes());
 
         // wait for poll to finish
-        poll.waitForDone();
-        String response = poll.getResponseContent();
+        latch.await();
+        String response = buf.toString();
+
+        // messages might not all be delivered during the 1st poll. We need to
+        // check again.
+        final StringBuffer buf2 = new StringBuffer();
+        final CountDownLatch latch2 = asyncRequest(httpClient,
+                "http://localhost:"; + port + "/amq?timeout=5000", buf2, 
sessionId);
+        latch2.await();
+
+        String fullResponse = response + buf2.toString();
 
-        // not all messages might be delivered during the 1st poll.  We need 
to check again.
-        poll = new AjaxTestContentExchange();
-        poll.setMethod( "GET" );
-        poll.setURL("http://localhost:"; + port + "/amq?timeout=5000");
-        poll.setRequestHeader( "Cookie", jsessionid );
-        httpClient.send( poll );
-        poll.waitForDone();
-
-        String fullResponse = response + poll.getResponseContent();
         LOG.debug( "full response : " + fullResponse );
 
         assertContains( "<response id='handler' destination='topic://test' 
>msg1</response>", fullResponse );
@@ -215,31 +160,21 @@ public class AjaxTest extends JettyTestSupport {
         producer.send( session.createTextMessage("test three") );
 
         HttpClient httpClient = new HttpClient();
-        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
         httpClient.start();
 
         // client 1 subscribes to queue
         LOG.debug( "SENDING LISTEN" );
-        AjaxTestContentExchange contentExchange = new 
AjaxTestContentExchange();
-        contentExchange.setMethod( "POST" );
-        contentExchange.setURL("http://localhost:"; + port + "/amq");
-        contentExchange.setRequestContent( new 
ByteArrayBuffer("destination=queue://test&type=listen&message=handler") );
-        contentExchange.setRequestContentType( 
"application/x-www-form-urlencoded; charset=UTF-8" );
-        httpClient.send(contentExchange);
-        contentExchange.waitForDone();
-        String jsessionid = contentExchange.getJsessionId();
+        String sessionId = subscribe(httpClient, port, 
"destination=queue://test&type=listen&message=handler");
 
         // client 1 polls for messages
         LOG.debug( "SENDING POLL" );
-        AjaxTestContentExchange poll = new AjaxTestContentExchange();
-        poll.setMethod( "GET" );
-        poll.setURL("http://localhost:"; + port + "/amq?timeout=5000");
-        poll.setRequestHeader( "Cookie", jsessionid );
-        httpClient.send( poll );
+        final StringBuffer buf = new StringBuffer();
+        final CountDownLatch latch =
+                asyncRequest(httpClient, "http://localhost:"; + port + 
"/amq?timeout=5000", buf, sessionId);
 
         // wait for poll to finish
-        poll.waitForDone();
-        String response = poll.getResponseContent();
+        latch.await();
+        String response = buf.toString();
 
         assertContains( "<response id='handler' destination='queue://test' 
>test one</response>", response );
         assertContains( "<response id='handler' destination='queue://test' 
>test two</response>", response );
@@ -255,27 +190,17 @@ public class AjaxTest extends JettyTestSupport {
         int port = getPort();
 
         HttpClient httpClient = new HttpClient();
-        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
         httpClient.start();
 
         // client 1 subscribes to a queue
         LOG.debug( "SENDING LISTEN" );
-        AjaxTestContentExchange contentExchange = new 
AjaxTestContentExchange();
-        contentExchange.setMethod( "POST" );
-        contentExchange.setURL("http://localhost:"; + port + "/amq");
-        contentExchange.setRequestContent( new 
ByteArrayBuffer("destination=queue://test&type=listen&message=handler") );
-        contentExchange.setRequestContentType( 
"application/x-www-form-urlencoded; charset=UTF-8" );
-        httpClient.send(contentExchange);
-        contentExchange.waitForDone();
-        String jsessionid = contentExchange.getJsessionId();
+        String sessionId = subscribe(httpClient, port, 
"destination=queue://test&type=listen&message=handler");
 
         // client 1 polls for messages
         LOG.debug( "SENDING POLL" );
-        AjaxTestContentExchange poll = new AjaxTestContentExchange();
-        poll.setMethod( "GET" );
-        poll.setURL("http://localhost:"; + port + "/amq?timeout=5000");
-        poll.setRequestHeader( "Cookie", jsessionid );
-        httpClient.send( poll );
+        final StringBuffer buf = new StringBuffer();
+        final CountDownLatch latch =
+                asyncRequest(httpClient, "http://localhost:"; + port + 
"/amq?timeout=5000", buf, sessionId);
 
         // stomp client queues some messages
         StompConnection connection = new StompConnection();
@@ -298,18 +223,16 @@ public class AjaxTest extends JettyTestSupport {
         connection.disconnect();
 
         // wait for poll to finish
-        poll.waitForDone();
-        String response = poll.getResponseContent();
+        latch.await();
+        String response = buf.toString();
 
         // not all messages might be delivered during the 1st poll.  We need 
to check again.
-        poll = new AjaxTestContentExchange();
-        poll.setMethod( "GET" );
-        poll.setURL("http://localhost:"; + port + "/amq?timeout=5000");
-        poll.setRequestHeader( "Cookie", jsessionid );
-        httpClient.send( poll );
-        poll.waitForDone();
+        final StringBuffer buf2 = new StringBuffer();
+        final CountDownLatch latch2 =
+                asyncRequest(httpClient, "http://localhost:"; + port + 
"/amq?timeout=5000", buf2, sessionId);
+        latch2.await();
 
-        String fullResponse = response + poll.getResponseContent();
+        String fullResponse = response + buf2.toString();
 
         assertContains( "<response id='handler' destination='queue://test' 
>message1</response>", fullResponse );
         assertContains( "<response id='handler' destination='queue://test' 
>message2</response>", fullResponse );
@@ -327,20 +250,12 @@ public class AjaxTest extends JettyTestSupport {
         int port = getPort();
 
         HttpClient httpClient = new HttpClient();
-        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
         httpClient.start();
 
-        AjaxTestContentExchange contentExchange = new 
AjaxTestContentExchange();
-        contentExchange.setMethod( "POST" );
-        contentExchange.setURL("http://localhost:"; + port + "/amq");
-        contentExchange.setRequestContent( new ByteArrayBuffer(
-            "destination=queue://test&type=send&message=msg1&"+
-            "d1=queue://test&t1=send&m1=msg2&"+
-            "d2=queue://test&t2=send&m2=msg3&"+
-            "d3=queue://test&t3=send&m3=msg4") );
-        contentExchange.setRequestContentType( 
"application/x-www-form-urlencoded; charset=UTF-8" );
-        httpClient.send(contentExchange);
-        contentExchange.waitForDone();
+        sendMessages(httpClient, port, 
("destination=queue://test&type=send&message=msg1&"+
+                "d1=queue://test&t1=send&m1=msg2&"+
+                "d2=queue://test&t2=send&m2=msg3&"+
+                "d3=queue://test&t3=send&m3=msg4").getBytes());
 
         StompConnection connection = new StompConnection();
         connection.open(stompUri.getHost(), stompUri.getPort());
@@ -371,6 +286,7 @@ public class AjaxTest extends JettyTestSupport {
         LOG.debug( "*** testAjaxClientMayUseSelectors ***" );
         int port = getPort();
 
+
         // send 2 messages to the same queue w/ different 'filter' values.
         Message msg = session.createTextMessage("test one");
         msg.setStringProperty( "filter", "one" );
@@ -380,35 +296,23 @@ public class AjaxTest extends JettyTestSupport {
         producer.send( msg );
 
         HttpClient httpClient = new HttpClient();
-        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
         httpClient.start();
 
         // client subscribes to queue
         LOG.debug( "SENDING LISTEN" );
-        AjaxTestContentExchange contentExchange = new 
AjaxTestContentExchange();
-        contentExchange.setMethod( "POST" );
-        contentExchange.setURL("http://localhost:"; + port + "/amq");
-        contentExchange.setRequestContent( new 
ByteArrayBuffer("destination=queue://test&type=listen&message=handler") );
-        contentExchange.setRequestContentType( 
"application/x-www-form-urlencoded; charset=UTF-8" );
-        // SELECTOR
-        contentExchange.setRequestHeader( "selector", "filter='two'" );
-        httpClient.send(contentExchange);
-        contentExchange.waitForDone();
-        String jsessionid = contentExchange.getJsessionId();
+        String sessionId = subscribe(httpClient, port, 
"destination=queue://test&type=listen&message=handler", "filter='two'", null);
 
         // client 1 polls for messages
         LOG.debug( "SENDING POLL" );
-        AjaxTestContentExchange poll = new AjaxTestContentExchange();
-        poll.setMethod( "GET" );
-        poll.setURL("http://localhost:"; + port + "/amq?timeout=5000");
-        poll.setRequestHeader( "Cookie", jsessionid );
-        httpClient.send( poll );
-        poll.waitForDone();
+        final StringBuffer buf = new StringBuffer();
+        final CountDownLatch latch =
+                asyncRequest(httpClient, "http://localhost:"; + port + 
"/amq?timeout=5000", buf, sessionId);
+        latch.await();
 
-        LOG.debug( poll.getResponseContent() );
+        LOG.debug( buf.toString() );
 
         String expected = "<response id='handler' destination='queue://test' 
>test two</response>";
-        assertContains( expected, poll.getResponseContent() );
+        assertContains( expected, buf.toString() );
 
         httpClient.stop();
     }
@@ -427,68 +331,39 @@ public class AjaxTest extends JettyTestSupport {
         producerB.send( session.createTextMessage("B2") );
 
         HttpClient httpClient = new HttpClient();
-        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
         httpClient.start();
 
         // clientA subscribes to /queue/testA
         LOG.debug( "SENDING LISTEN" );
-        AjaxTestContentExchange contentExchange = new 
AjaxTestContentExchange();
-        contentExchange.setMethod( "POST" );
-        contentExchange.setURL("http://localhost:"; + port + "/amq");
-        contentExchange.setRequestContent( new ByteArrayBuffer(
-            "destination=queue://testA&"+
-            "type=listen&"+
-            "message=handlerA&"+
-            "clientId=clientA"
-        ) );
-        contentExchange.setRequestContentType( 
"application/x-www-form-urlencoded; charset=UTF-8" );
-        httpClient.send(contentExchange);
-        contentExchange.waitForDone();
-        String jsessionid = contentExchange.getJsessionId();
+        String sessionId = subscribe(httpClient, port, 
"destination=queue://testA&type=listen&message=handlerA&clientId=clientA");
 
         // clientB subscribes to /queue/testB using the same JSESSIONID.
-        contentExchange = new AjaxTestContentExchange();
-        contentExchange.setMethod( "POST" );
-        contentExchange.setURL("http://localhost:"; + port + "/amq");
-        contentExchange.setRequestHeader( "Cookie", jsessionid );
-        contentExchange.setRequestContent( new ByteArrayBuffer(
-            "destination=queue://testB&"+
-            "type=listen&"+
-            "message=handlerB&"+
-            "clientId=clientB"
-        ) );
-        contentExchange.setRequestContentType( 
"application/x-www-form-urlencoded; charset=UTF-8" );
-        httpClient.send(contentExchange);
-        contentExchange.waitForDone();
+        subscribe(httpClient, port, 
"destination=queue://testB&type=listen&message=handlerB&clientId=clientB", 
null, sessionId);
 
         // clientA polls for messages
-        AjaxTestContentExchange poll = new AjaxTestContentExchange();
-        poll.setMethod( "GET" );
-        poll.setURL("http://localhost:"; + port + 
"/amq?timeout=5000&clientId=clientA");
-        poll.setRequestHeader( "Cookie", jsessionid );
-        httpClient.send( poll );
-        poll.waitForDone();
-
-        LOG.debug( "clientA response : " + poll.getResponseContent() );
+        final StringBuffer buf = new StringBuffer();
+        final CountDownLatch latch =
+                asyncRequest(httpClient, "http://localhost:"; + port + 
"/amq?timeout=5000&clientId=clientA", buf, sessionId);
+        latch.await();
+
+        LOG.debug( "clientA response : " + buf.toString() );
         String expected1 = "<response id='handlerA' 
destination='queue://testA' >A1</response>";
         String expected2 = "<response id='handlerA' 
destination='queue://testA' >A2</response>";
 
-        assertContains( expected1, poll.getResponseContent() );
-        assertContains( expected2, poll.getResponseContent() );
+        assertContains( expected1, buf.toString() );
+        assertContains( expected2, buf.toString() );
 
         // clientB polls for messages
-        poll = new AjaxTestContentExchange();
-        poll.setMethod( "GET" );
-        poll.setURL("http://localhost:"; + port + 
"/amq?timeout=5000&clientId=clientB");
-        poll.setRequestHeader( "Cookie", jsessionid );
-        httpClient.send( poll );
-        poll.waitForDone();
-
-        LOG.debug( "clientB response : " + poll.getResponseContent() );
+        final StringBuffer buf2 = new StringBuffer();
+        final CountDownLatch latch2 =
+                asyncRequest(httpClient, "http://localhost:"; + port + 
"/amq?timeout=5000&clientId=clientB", buf2, sessionId);
+        latch2.await();
+
+        LOG.debug( "clientB response : " + buf2.toString() );
         expected1 =  "<response id='handlerB' destination='queue://testB' 
>B1</response>";
         expected2 = "<response id='handlerB' destination='queue://testB' 
>B2</response>";
-        assertContains( expected1, poll.getResponseContent() );
-        assertContains( expected2, poll.getResponseContent() );
+        assertContains( expected1, buf2.toString() );
+        assertContains( expected2, buf2.toString() );
 
         httpClient.stop();
     }
@@ -499,66 +374,39 @@ public class AjaxTest extends JettyTestSupport {
         int port = getPort();
 
         HttpClient httpClient = new HttpClient();
-        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
         httpClient.start();
 
         LOG.debug( "SENDING LISTEN FOR /topic/topicA" );
-        AjaxTestContentExchange contentExchange = new 
AjaxTestContentExchange();
-        contentExchange.setMethod( "POST" );
-        contentExchange.setURL("http://localhost:"; + port + "/amq");
-        contentExchange.setRequestContent( new 
ByteArrayBuffer("destination=topic://topicA&type=listen&message=handlerA") );
-        contentExchange.setRequestContentType( 
"application/x-www-form-urlencoded; charset=UTF-8" );
-        httpClient.send(contentExchange);
-        contentExchange.waitForDone();
-        String jsessionid = contentExchange.getJsessionId();
+        String sessionId = subscribe(httpClient, port, 
"destination=topic://topicA&type=listen&message=handlerA");
+
 
         LOG.debug( "SENDING LISTEN FOR /topic/topicB" );
-        contentExchange = new AjaxTestContentExchange();
-        contentExchange.setMethod( "POST" );
-        contentExchange.setURL("http://localhost:"; + port + "/amq");
-        contentExchange.setRequestContent( new 
ByteArrayBuffer("destination=topic://topicB&type=listen&message=handlerB") );
-        contentExchange.setRequestContentType( 
"application/x-www-form-urlencoded; charset=UTF-8" );
-        contentExchange.setRequestHeader( "Cookie", jsessionid );
-        httpClient.send(contentExchange);
-        contentExchange.waitForDone();
+        subscribe(httpClient, port, 
"destination=topic://topicB&type=listen&message=handlerB", null, sessionId);
 
         // client 1 polls for messages
-        LOG.debug( "SENDING POLL" );
-        AjaxTestContentExchange poll = new AjaxTestContentExchange();
-        poll.setMethod( "GET" );
-        poll.setURL("http://localhost:"; + port + "/amq?timeout=5000");
-        poll.setRequestHeader( "Cookie", jsessionid );
-        httpClient.send( poll );
+        final StringBuffer buf = new StringBuffer();
+        final CountDownLatch latch =
+                asyncRequest(httpClient, "http://localhost:"; + port + 
"/amq?timeout=5000", buf, sessionId);
 
         // while client 1 is polling, client 2 sends messages to the topics
         LOG.debug( "SENDING MESSAGES" );
-        contentExchange = new AjaxTestContentExchange();
-        contentExchange.setMethod( "POST" );
-        contentExchange.setURL("http://localhost:"; + port + "/amq");
-        contentExchange.setRequestContent( new ByteArrayBuffer(
-            "destination=topic://topicA&type=send&message=A1&"+
-            "d1=topic://topicB&t1=send&m1=B1&"+
-            "d2=topic://topicA&t2=send&m2=A2&"+
-            "d3=topic://topicB&t3=send&m3=B2"
-        ) );
-        contentExchange.setRequestContentType( 
"application/x-www-form-urlencoded; charset=UTF-8" );
-        httpClient.send(contentExchange);
-        contentExchange.waitForDone();
+        sendMessages(httpClient, port, 
("destination=topic://topicA&type=send&message=A1&"+
+                "d1=topic://topicB&t1=send&m1=B1&"+
+                "d2=topic://topicA&t2=send&m2=A2&"+
+                "d3=topic://topicB&t3=send&m3=B2").getBytes());
         LOG.debug( "DONE POSTING MESSAGES" );
 
         // wait for poll to finish
-        poll.waitForDone();
-        String response = poll.getResponseContent();
+        latch.await();
+        String response = buf.toString();
 
         // not all messages might be delivered during the 1st poll.  We need 
to check again.
-        poll = new AjaxTestContentExchange();
-        poll.setMethod( "GET" );
-        poll.setURL("http://localhost:"; + port + "/amq?timeout=5000");
-        poll.setRequestHeader( "Cookie", jsessionid );
-        httpClient.send( poll );
-        poll.waitForDone();
-
-        String fullResponse = response + poll.getResponseContent();
+        final StringBuffer buf2 = new StringBuffer();
+        final CountDownLatch latch2 =
+                asyncRequest(httpClient, "http://localhost:"; + port + 
"/amq?timeout=5000", buf2, sessionId);
+        latch2.await();
+
+        String fullResponse = response + buf2.toString();
         LOG.debug( "full response " + fullResponse );
         assertContains( "<response id='handlerA' destination='topic://topicA' 
>A1</response>", fullResponse );
         assertContains( "<response id='handlerB' destination='topic://topicB' 
>B1</response>", fullResponse );
@@ -568,4 +416,87 @@ public class AjaxTest extends JettyTestSupport {
 
         httpClient.stop();
      }
+
+    protected void sendMessages(HttpClient httpClient, int port, byte[] 
content) throws InterruptedException {
+        final CountDownLatch latch = new CountDownLatch(1);
+        final StringBuffer buf = new StringBuffer();
+        httpClient
+                .newRequest("http://localhost:"; + port + "/amq")
+                .header("Content-Type", "application/x-www-form-urlencoded; 
charset=UTF-8")
+                .content(
+                        new InputStreamContentProvider(new 
ByteArrayInputStream(content)))
+                .method(HttpMethod.POST).send(new BufferingResponseListener() {
+                    @Override
+                    public void onComplete(Result result) {
+                        buf.append(getContentAsString());
+                        latch.countDown();
+                    }
+                });
+        latch.await();
+    }
+
+    protected String subscribe(HttpClient httpClient, int port, String 
content) throws InterruptedException {
+        return this.subscribe(httpClient, port, content, null, null);
+    }
+
+    protected String subscribe(HttpClient httpClient, int port, String 
content, String selector, String session) throws InterruptedException {
+        final CountDownLatch latch = new CountDownLatch(1);
+        final StringBuffer buf = new StringBuffer();
+        final StringBuffer sessionId = new StringBuffer();
+        Request request = httpClient.newRequest("http://localhost:"; + port + 
"/amq");
+        if (selector != null) {
+            request.header("selector", selector);
+        }
+        if (session != null) {
+            request.header(HttpHeader.COOKIE, session);
+        }
+        request.header("Content-Type","application/x-www-form-urlencoded; 
charset=UTF-8")
+           .content(new InputStreamContentProvider(new 
ByteArrayInputStream(content.getBytes())))
+           .method(HttpMethod.POST).send(new BufferingResponseListener() {
+            @Override
+            public void onComplete(Result result) {
+                buf.append(getContentAsString());
+                String cookie = 
result.getResponse().getHeaders().get(HttpHeader.SET_COOKIE);
+                if (cookie != null) {
+                    String[] cookieParts = cookie.split(";");
+                    sessionId.append(cookieParts[0]);
+                }
+                latch.countDown();
+            }
+        });
+        latch.await();
+
+        return sessionId.toString();
+    }
+
+    protected CountDownLatch asyncRequest(final HttpClient httpClient, final 
String url, final StringBuffer buffer,
+            final String sessionId) {
+        final CountDownLatch latch = new CountDownLatch(1);
+        Request request = httpClient.newRequest(url);
+        if (sessionId != null) {
+            request.header(HttpHeader.COOKIE, sessionId);
+        }
+        request.send(new BufferingResponseListener() {
+            @Override
+            public void onComplete(Result result) {
+                buffer.append(getContentAsString());
+                latch.countDown();
+            }
+        });
+        return latch;
+    }
+
+    protected CountDownLatch asyncRequest(final HttpClient httpClient, final 
String url, final StringBuffer buffer,
+            final AtomicInteger status) {
+        final CountDownLatch latch = new CountDownLatch(1);
+        httpClient.newRequest(url).send(new BufferingResponseListener() {
+            @Override
+            public void onComplete(Result result) {
+                status.getAndSet(result.getResponse().getStatus());
+                buffer.append(getContentAsString());
+                latch.countDown();
+            }
+        });
+        return latch;
+    }
 }

http://git-wip-us.apache.org/repos/asf/activemq/blob/f44c3d20/activemq-web-demo/src/test/java/org/apache/activemq/web/JettyServer.java
----------------------------------------------------------------------
diff --git 
a/activemq-web-demo/src/test/java/org/apache/activemq/web/JettyServer.java 
b/activemq-web-demo/src/test/java/org/apache/activemq/web/JettyServer.java
index 692df05..8069954 100644
--- a/activemq-web-demo/src/test/java/org/apache/activemq/web/JettyServer.java
+++ b/activemq-web-demo/src/test/java/org/apache/activemq/web/JettyServer.java
@@ -21,7 +21,7 @@ import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.demo.DefaultQueueSender;
 import org.eclipse.jetty.server.Connector;
 import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.server.nio.SelectChannelConnector;
+import org.eclipse.jetty.server.ServerConnector;
 import org.eclipse.jetty.webapp.WebAppContext;
 
 /**
@@ -46,7 +46,7 @@ public final class JettyServer {
         BrokerService broker = new BrokerService();
         broker.setPersistent(false);
         broker.setUseJmx(true);
-        broker.addConnector("tcp://localhost:0");
+        broker.addConnector("tcp://localhost:61616");
         broker.addConnector("stomp://localhost:0");
         broker.start();
 
@@ -63,9 +63,8 @@ public final class JettyServer {
         }
         System.out.println("Starting Web Server on port: " + port);
         Server server = new Server();
-        SelectChannelConnector connector = new SelectChannelConnector();
+        ServerConnector connector = new ServerConnector(server);
         connector.setPort(port);
-        connector.setServer(server);
         WebAppContext context = new WebAppContext();
 
         context.setResourceBase(WEBAPP_DIR);

http://git-wip-us.apache.org/repos/asf/activemq/blob/f44c3d20/activemq-web-demo/src/test/java/org/apache/activemq/web/JettyTestSupport.java
----------------------------------------------------------------------
diff --git 
a/activemq-web-demo/src/test/java/org/apache/activemq/web/JettyTestSupport.java 
b/activemq-web-demo/src/test/java/org/apache/activemq/web/JettyTestSupport.java
index 3581af4..3f95f8d 100644
--- 
a/activemq-web-demo/src/test/java/org/apache/activemq/web/JettyTestSupport.java
+++ 
b/activemq-web-demo/src/test/java/org/apache/activemq/web/JettyTestSupport.java
@@ -16,6 +16,8 @@
  */
 package org.apache.activemq.web;
 
+import static org.junit.Assert.assertTrue;
+
 import java.io.IOException;
 import java.net.ServerSocket;
 import java.net.Socket;
@@ -33,15 +35,13 @@ import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.util.Wait;
 import org.eclipse.jetty.server.Connector;
 import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.server.nio.SelectChannelConnector;
+import org.eclipse.jetty.server.ServerConnector;
 import org.eclipse.jetty.webapp.WebAppContext;
 import org.junit.After;
 import org.junit.Before;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.junit.Assert.assertTrue;
-
 public class JettyTestSupport {
     private static final Logger LOG = 
LoggerFactory.getLogger(JettyTestSupport.class);
 
@@ -74,9 +74,8 @@ public class JettyTestSupport {
 
         int port = getPort();
         server = new Server();
-        SelectChannelConnector connector = new SelectChannelConnector();
+        ServerConnector connector = new ServerConnector(server);
         connector.setPort(port);
-        connector.setServer(server);
         WebAppContext context = new WebAppContext();
 
         context.setResourceBase("src/main/webapp");
@@ -129,6 +128,7 @@ public class JettyTestSupport {
         final URL url = new URL(bindLocation);
         assertTrue("Jetty endpoint is available", Wait.waitFor(new 
Wait.Condition() {
 
+            @Override
             public boolean isSatisified() throws Exception {
                 boolean canConnect = false;
                 try {

http://git-wip-us.apache.org/repos/asf/activemq/blob/f44c3d20/activemq-web-demo/src/test/java/org/apache/activemq/web/RestPersistentTest.java
----------------------------------------------------------------------
diff --git 
a/activemq-web-demo/src/test/java/org/apache/activemq/web/RestPersistentTest.java
 
b/activemq-web-demo/src/test/java/org/apache/activemq/web/RestPersistentTest.java
index f971cd2..61345ea 100644
--- 
a/activemq-web-demo/src/test/java/org/apache/activemq/web/RestPersistentTest.java
+++ 
b/activemq-web-demo/src/test/java/org/apache/activemq/web/RestPersistentTest.java
@@ -16,16 +16,24 @@
  */
 package org.apache.activemq.web;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
 import java.io.ByteArrayInputStream;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicInteger;
 
-import org.eclipse.jetty.client.ContentExchange;
 import org.eclipse.jetty.client.HttpClient;
+import org.eclipse.jetty.client.api.Request;
+import org.eclipse.jetty.client.api.Result;
+import org.eclipse.jetty.client.util.BufferingResponseListener;
+import org.eclipse.jetty.client.util.InputStreamContentProvider;
+import org.eclipse.jetty.http.HttpMethod;
 import org.eclipse.jetty.http.HttpStatus;
 import org.junit.Ignore;
 import org.junit.Test;
 
-import static org.junit.Assert.*;
-
 public class RestPersistentTest extends JettyTestSupport {
 
     @Override
@@ -58,7 +66,6 @@ public class RestPersistentTest extends JettyTestSupport {
 
         HttpClient httpClient = new HttpClient();
         httpClient.start();
-        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
 
         //post first message
         // TODO: a problem with GET before POST
@@ -69,36 +76,56 @@ public class RestPersistentTest extends JettyTestSupport {
 
     private void postMessage(HttpClient httpClient, String url, String 
properties, String message) throws Exception
     {
-        ContentExchange contentExchange = new ContentExchange();
-        contentExchange.setMethod("POST");
-        contentExchange.setURL(url+"&"+properties);
-        //contentExchange.setRequestHeader("accept", "text/xml");
-        contentExchange.setRequestHeader("Content-Type","text/xml");
-        contentExchange.setRequestContentSource(new 
ByteArrayInputStream(message.getBytes("UTF-8")));
-
-        httpClient.send(contentExchange);
-        contentExchange.waitForDone();
-        assertTrue("success status", 
HttpStatus.isSuccess(contentExchange.getResponseStatus()));
+        final CountDownLatch latch = new CountDownLatch(1);
+        final StringBuffer buf = new StringBuffer();
+        final AtomicInteger status = new AtomicInteger();
+        httpClient.newRequest(url+"&"+properties)
+            .header("Content-Type","text/xml")
+           .content(new InputStreamContentProvider(new 
ByteArrayInputStream(message.getBytes("UTF-8"))))
+           .method(HttpMethod.POST).send(new BufferingResponseListener() {
+            @Override
+            public void onComplete(Result result) {
+                status.getAndSet(result.getResponse().getStatus());
+                buf.append(getContentAsString());
+                latch.countDown();
+            }
+        });
+
+        latch.await();
+        assertTrue("success status", HttpStatus.isSuccess(status.get()));
      }
 
     private void getMessage(HttpClient httpClient, String url, String 
selector, String expectedMessage) throws Exception
     {
-        ContentExchange contentExchange = new ContentExchange(true);
-        contentExchange.setURL(url);
-        contentExchange.setRequestHeader("accept", "text/xml");
-        contentExchange.setRequestHeader("Content-Type","text/xml");
+
+        final CountDownLatch latch = new CountDownLatch(1);
+        final StringBuffer buf = new StringBuffer();
+        final AtomicInteger status = new AtomicInteger();
+        Request request = httpClient.newRequest(url)
+            .header("accept", "text/xml")
+            .header("Content-Type","text/xml");
+
         if(selector!=null)
         {
-            contentExchange.setRequestHeader("selector", selector);
+            request.header("selector", selector);
         }
-        httpClient.send(contentExchange);
-        contentExchange.waitForDone();
-        assertTrue("success status", 
HttpStatus.isSuccess(contentExchange.getResponseStatus()));
+
+        request.method(HttpMethod.GET).send(new BufferingResponseListener() {
+            @Override
+            public void onComplete(Result result) {
+                status.getAndSet(result.getResponse().getStatus());
+                buf.append(getContentAsString());
+                latch.countDown();
+            }
+        });
+
+        latch.await();
+        assertTrue("success status", HttpStatus.isSuccess(status.get()));
 
         if(expectedMessage!=null)
         {
-            assertNotNull(contentExchange.getResponseContent());
-            assertEquals(expectedMessage, 
contentExchange.getResponseContent().trim());
+            assertNotNull(buf.toString());
+            assertEquals(expectedMessage, buf.toString().trim());
         }
      }
 }

http://git-wip-us.apache.org/repos/asf/activemq/blob/f44c3d20/activemq-web-demo/src/test/java/org/apache/activemq/web/RestTest.java
----------------------------------------------------------------------
diff --git 
a/activemq-web-demo/src/test/java/org/apache/activemq/web/RestTest.java 
b/activemq-web-demo/src/test/java/org/apache/activemq/web/RestTest.java
index 0057153..2ea0d0a 100644
--- a/activemq-web-demo/src/test/java/org/apache/activemq/web/RestTest.java
+++ b/activemq-web-demo/src/test/java/org/apache/activemq/web/RestTest.java
@@ -16,22 +16,28 @@
  */
 package org.apache.activemq.web;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
 import java.util.Set;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import javax.jms.TextMessage;
 import javax.management.ObjectName;
 
 import org.apache.commons.lang.RandomStringUtils;
-import org.eclipse.jetty.client.ContentExchange;
 import org.eclipse.jetty.client.HttpClient;
+import org.eclipse.jetty.client.api.Result;
+import org.eclipse.jetty.client.util.BufferingResponseListener;
 import org.eclipse.jetty.http.HttpFields;
+import org.eclipse.jetty.http.HttpMethod;
 import org.eclipse.jetty.http.HttpStatus;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.junit.Assert.*;
-
 public class RestTest extends JettyTestSupport {
     private static final Logger LOG = LoggerFactory.getLogger(RestTest.class);
 
@@ -44,12 +50,13 @@ public class RestTest extends JettyTestSupport {
 
         HttpClient httpClient = new HttpClient();
         httpClient.start();
-        ContentExchange contentExchange = new ContentExchange();
-        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
-        contentExchange.setURL("http://localhost:"; + port + 
"/message/test?readTimeout=1000&type=queue");
-        httpClient.send(contentExchange);
-        contentExchange.waitForDone();
-        assertEquals("test", contentExchange.getResponseContent());
+
+        final StringBuffer buf = new StringBuffer();
+        final CountDownLatch latch =
+                asyncRequest(httpClient, "http://localhost:"; + port + 
"/message/test?readTimeout=1000&type=queue", buf);
+
+        latch.await();
+        assertEquals("test", buf.toString());
     }
 
     @Test(timeout = 60 * 1000)
@@ -58,18 +65,17 @@ public class RestTest extends JettyTestSupport {
 
         HttpClient httpClient = new HttpClient();
         httpClient.start();
-        ContentExchange contentExchange = new ContentExchange();
-        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
-        contentExchange.setURL("http://localhost:"; + port + 
"/message/test?readTimeout=5000&type=queue");
-        httpClient.send(contentExchange);
 
-        Thread.sleep(1000);
+        final StringBuffer buf = new StringBuffer();
+        final CountDownLatch latch =
+                asyncRequest(httpClient, "http://localhost:"; + port + 
"/message/test?readTimeout=5000&type=queue", buf);
 
         producer.send(session.createTextMessage("test"));
         LOG.info("message sent");
 
-        contentExchange.waitForDone();
-        assertEquals("test", contentExchange.getResponseContent());
+        latch.await();
+        assertEquals("test", buf.toString());
+
     }
 
     @Test(timeout = 60 * 1000)
@@ -88,22 +94,28 @@ public class RestTest extends JettyTestSupport {
 
         HttpClient httpClient = new HttpClient();
         httpClient.start();
-        ContentExchange contentExchange = new ContentExchange();
-        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
-        contentExchange.setURL("http://localhost:"; + port + 
"/message/test?readTimeout=1000&type=queue");
-        contentExchange.setRequestHeader("selector", "test=2");
-        httpClient.send(contentExchange);
-        contentExchange.waitForDone();
-        assertEquals("test2", contentExchange.getResponseContent());
+
+        final StringBuffer buf = new StringBuffer();
+        final CountDownLatch latch = new CountDownLatch(1);
+        httpClient.newRequest("http://localhost:"; + port + 
"/message/test?readTimeout=1000&type=queue")
+            .header("selector", "test=2").send(new BufferingResponseListener() 
{
+            @Override
+            public void onComplete(Result result) {
+                buf.append(getContentAsString());
+                latch.countDown();
+            }
+        });
+        latch.await();
+        assertEquals("test2", buf.toString());
     }
 
+
     // test for https://issues.apache.org/activemq/browse/AMQ-2827
     @Test(timeout = 15 * 1000)
     public void testCorrelation() throws Exception {
         int port = getPort();
 
         HttpClient httpClient = new HttpClient();
-        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
         httpClient.start();
 
         for (int i = 0; i < 200; i++) {
@@ -116,13 +128,14 @@ public class RestTest extends JettyTestSupport {
             LOG.info("Sending: " + correlId);
             producer.send(message);
 
-            ContentExchange contentExchange = new ContentExchange();
-            contentExchange.setURL("http://localhost:"; + port + 
"/message/test?readTimeout=1000&type=queue&clientId=test");
-            httpClient.send(contentExchange);
-            contentExchange.waitForDone();
-            LOG.info("Received: [" + contentExchange.getResponseStatus() + "] 
" + contentExchange.getResponseContent());
-            assertEquals(200, contentExchange.getResponseStatus());
-            assertEquals(correlId, contentExchange.getResponseContent());
+            final StringBuffer buf = new StringBuffer();
+            final CountDownLatch latch =
+                    asyncRequest(httpClient, "http://localhost:"; + port + 
"/message/test?readTimeout=1000&type=queue&clientId=test", buf);
+
+            latch.await();
+            LOG.info("Received: " +  buf.toString());
+           // assertEquals(200, contentExchange.getResponseStatus());
+            assertEquals(correlId,  buf.toString());
         }
         httpClient.stop();
     }
@@ -134,19 +147,26 @@ public class RestTest extends JettyTestSupport {
         producer.send(session.createTextMessage("test"));
         HttpClient httpClient = new HttpClient();
         httpClient.start();
-        ContentExchange contentExchange = new ContentExchange();
-        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
-        contentExchange.setURL("http://localhost:"; + port + 
"/message/test?readTimeout=1000&type=queue&clientId=test");
-        httpClient.send(contentExchange);
-        contentExchange.waitForDone();
-        LOG.info("Received: [" + contentExchange.getResponseStatus() + "] " + 
contentExchange.getResponseContent());
-
-        contentExchange = new ContentExchange();
-        contentExchange.setMethod("POST");
-        contentExchange.setURL("http://localhost:"; + port + 
"/message/test?clientId=test&action=unsubscribe");
-        httpClient.send(contentExchange);
-        contentExchange.waitForDone();
 
+        final StringBuffer buf = new StringBuffer();
+        final CountDownLatch latch =
+                asyncRequest(httpClient, "http://localhost:"; + port + 
"/message/test?readTimeout=1000&type=queue&clientId=test", buf);
+
+        latch.await();
+        LOG.info("Received: " + buf.toString());
+
+        final StringBuffer buf2 = new StringBuffer();
+        final CountDownLatch latch2 = new CountDownLatch(1);
+        httpClient.newRequest("http://localhost:"; + port + 
"/message/test?clientId=test&action=unsubscribe")
+            .method(HttpMethod.POST).send(new BufferingResponseListener() {
+            @Override
+            public void onComplete(Result result) {
+                buf2.append(getContentAsString());
+                latch2.countDown();
+            }
+        });
+
+        latch2.await();
         httpClient.stop();
 
         ObjectName query = new 
ObjectName("org.apache.activemq:BrokerName=localhost,Type=Subscription,destinationType=Queue,destinationName=test,*");
@@ -160,20 +180,31 @@ public class RestTest extends JettyTestSupport {
 
         HttpClient httpClient = new HttpClient();
         httpClient.start();
-        ContentExchange contentExchange = new ContentExchange();
-        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
-        contentExchange.setMethod("POST");
-        contentExchange.setURL("http://localhost:"; + port + 
"/message/testPost?type=queue");
-        httpClient.send(contentExchange);
-
-        contentExchange.waitForDone();
-        assertTrue("success status", 
HttpStatus.isSuccess(contentExchange.getResponseStatus()));
-
-        ContentExchange contentExchange2 = new ContentExchange();
-        contentExchange2.setURL("http://localhost:"; + port + 
"/message/testPost?readTimeout=1000&type=Queue");
-        httpClient.send(contentExchange2);
-        contentExchange2.waitForDone();
-        assertTrue("success status", 
HttpStatus.isSuccess(contentExchange2.getResponseStatus()));
+
+        final CountDownLatch latch = new CountDownLatch(1);
+        final StringBuffer buf = new StringBuffer();
+        final AtomicInteger status = new AtomicInteger();
+        httpClient.newRequest("http://localhost:"; + port + 
"/message/testPost?type=queue")
+           .method(HttpMethod.POST).send(new BufferingResponseListener() {
+            @Override
+            public void onComplete(Result result) {
+                status.getAndSet(result.getResponse().getStatus());
+                buf.append(getContentAsString());
+                latch.countDown();
+            }
+        });
+
+
+        latch.await();
+        assertTrue("success status", HttpStatus.isSuccess(status.get()));
+
+        final StringBuffer buf2 = new StringBuffer();
+        final AtomicInteger status2 = new AtomicInteger();
+        final CountDownLatch latch2 =
+                asyncRequest(httpClient, "http://localhost:"; + port + 
"/message/testPost?readTimeout=1000&type=Queue", buf2, status2);
+
+        latch2.await();
+        assertTrue("success status", HttpStatus.isSuccess(status2.get()));
     }
 
     // test for https://issues.apache.org/activemq/browse/AMQ-3857
@@ -183,22 +214,42 @@ public class RestTest extends JettyTestSupport {
 
         HttpClient httpClient = new HttpClient();
         httpClient.start();
-        ContentExchange contentExchange = new ContentExchange();
-        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
-        contentExchange.setMethod("POST");
-        contentExchange.setURL("http://localhost:"; + port + 
"/message/testPost?type=queue&property=value");
-        httpClient.send(contentExchange);
-
-        contentExchange.waitForDone();
-        assertTrue("success status", 
HttpStatus.isSuccess(contentExchange.getResponseStatus()));
-
-        ContentExchange contentExchange2 = new ContentExchange(true);
-        contentExchange2.setURL("http://localhost:"; + port + 
"/message/testPost?readTimeout=1000&type=Queue");
-        httpClient.send(contentExchange2);
-        contentExchange2.waitForDone();
-        assertTrue("success status", 
HttpStatus.isSuccess(contentExchange2.getResponseStatus()));
-
-        HttpFields fields = contentExchange2.getResponseFields();
+
+        final CountDownLatch latch = new CountDownLatch(1);
+        final StringBuffer buf = new StringBuffer();
+        final AtomicInteger status = new AtomicInteger();
+        httpClient.newRequest("http://localhost:"; + port + 
"/message/testPost?type=queue&property=value")
+           .method(HttpMethod.POST).send(new BufferingResponseListener() {
+            @Override
+            public void onComplete(Result result) {
+                status.getAndSet(result.getResponse().getStatus());
+                buf.append(getContentAsString());
+                latch.countDown();
+            }
+        });
+
+        latch.await();
+        assertTrue("success status", HttpStatus.isSuccess(status.get()));
+
+        final CountDownLatch latch2 = new CountDownLatch(1);
+        final StringBuffer buf2 = new StringBuffer();
+        final AtomicInteger status2 = new AtomicInteger();
+        final HttpFields responseFields = new HttpFields();
+        httpClient.newRequest("http://localhost:"; + port + 
"/message/testPost?readTimeout=1000&type=Queue")
+           .method(HttpMethod.GET).send(new BufferingResponseListener() {
+            @Override
+            public void onComplete(Result result) {
+                responseFields.add(result.getResponse().getHeaders());
+                status2.getAndSet(result.getResponse().getStatus());
+                buf2.append(getContentAsString());
+                latch2.countDown();
+            }
+        });
+
+        latch2.await();
+        assertTrue("success status", HttpStatus.isSuccess(status2.get()));
+
+        HttpFields fields = responseFields;
         assertNotNull("Headers Exist", fields);
         assertEquals("header value", "value", 
fields.getStringField("property"));
     }
@@ -210,14 +261,49 @@ public class RestTest extends JettyTestSupport {
 
         HttpClient httpClient = new HttpClient();
         httpClient.start();
-        ContentExchange contentExchange = new ContentExchange();
-        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
-        contentExchange.setMethod("POST");
-        contentExchange.setURL("http://localhost:"; + port + 
"/message/testPost?type=queue");
-        contentExchange.setRequestHeader("Authorization", "Basic 
YWRtaW46YWRtaW4=");
-        httpClient.send(contentExchange);
-
-        contentExchange.waitForDone();
-        assertTrue("success status", 
HttpStatus.isSuccess(contentExchange.getResponseStatus()));
+
+        final CountDownLatch latch = new CountDownLatch(1);
+        final StringBuffer buf = new StringBuffer();
+        final AtomicInteger status = new AtomicInteger();
+        httpClient.newRequest("http://localhost:"; + port + 
"/message/testPost?type=queue")
+            .header("Authorization", "Basic YWRtaW46YWRtaW4=")
+           .method(HttpMethod.POST).send(new BufferingResponseListener() {
+            @Override
+            public void onComplete(Result result) {
+                status.getAndSet(result.getResponse().getStatus());
+                buf.append(getContentAsString());
+                latch.countDown();
+            }
+        });
+
+
+        latch.await();
+        assertTrue("success status", HttpStatus.isSuccess(status.get()));
+    }
+
+    protected CountDownLatch asyncRequest(final HttpClient httpClient, final 
String url, final StringBuffer buffer) {
+        final CountDownLatch latch = new CountDownLatch(1);
+        httpClient.newRequest(url).send(new BufferingResponseListener() {
+            @Override
+            public void onComplete(Result result) {
+                buffer.append(getContentAsString());
+                latch.countDown();
+            }
+        });
+        return latch;
+    }
+
+    protected CountDownLatch asyncRequest(final HttpClient httpClient, final 
String url, final StringBuffer buffer,
+            final AtomicInteger status) {
+        final CountDownLatch latch = new CountDownLatch(1);
+        httpClient.newRequest(url).send(new BufferingResponseListener() {
+            @Override
+            public void onComplete(Result result) {
+                status.getAndSet(result.getResponse().getStatus());
+                buffer.append(getContentAsString());
+                latch.countDown();
+            }
+        });
+        return latch;
     }
 }

http://git-wip-us.apache.org/repos/asf/activemq/blob/f44c3d20/activemq-web/pom.xml
----------------------------------------------------------------------
diff --git a/activemq-web/pom.xml b/activemq-web/pom.xml
index e349f9e..f4c3b04 100755
--- a/activemq-web/pom.xml
+++ b/activemq-web/pom.xml
@@ -68,20 +68,19 @@
     </dependency>
 
     <!-- web container -->
-    <dependency>
-      <groupId>org.apache.geronimo.specs</groupId>
-      <artifactId>geronimo-servlet_3.0_spec</artifactId>
-      <scope>provided</scope>
-    </dependency>
+       <dependency>
+       <groupId>org.apache.tomcat</groupId>
+       <artifactId>tomcat-servlet-api</artifactId>
+       <scope>provided</scope>
+      </dependency>
     <dependency>
       <groupId>org.eclipse.jetty.aggregate</groupId>
       <artifactId>jetty-all</artifactId>
-      <scope>test</scope>
+      <scope>provided</scope>
     </dependency>
     <dependency>
-      <groupId>org.eclipse.jetty</groupId>
-      <artifactId>jetty-websocket</artifactId>
-      <version>${jetty8-version}</version>
+      <groupId>org.eclipse.jetty.websocket</groupId>
+      <artifactId>websocket-server</artifactId>
     </dependency>
     <dependency>
       <groupId>org.eclipse.jetty</groupId>

http://git-wip-us.apache.org/repos/asf/activemq/blob/f44c3d20/activemq-web/src/main/java/org/apache/activemq/web/config/JspConfigurer.java
----------------------------------------------------------------------
diff --git 
a/activemq-web/src/main/java/org/apache/activemq/web/config/JspConfigurer.java 
b/activemq-web/src/main/java/org/apache/activemq/web/config/JspConfigurer.java
new file mode 100644
index 0000000..9c60ab2
--- /dev/null
+++ 
b/activemq-web/src/main/java/org/apache/activemq/web/config/JspConfigurer.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.web.config;
+
+import org.eclipse.jetty.server.Handler;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.handler.HandlerCollection;
+import org.eclipse.jetty.webapp.Configuration;
+import org.eclipse.jetty.webapp.WebAppContext;
+
+/**
+ *
+ *
+ */
+public class JspConfigurer {
+
+    public static void configureJetty(Server server, HandlerCollection 
collection) {
+        Configuration.ClassList classlist = Configuration.ClassList
+                .setServerDefault( server );
+        classlist.addBefore(
+                "org.eclipse.jetty.webapp.JettyWebXmlConfiguration",
+                "org.eclipse.jetty.annotations.AnnotationConfiguration" );
+
+        // Set the ContainerIncludeJarPattern so that jetty examines these
+        // container-path jars for tlds, web-fragments etc.
+        // If you omit the jar that contains the jstl .tlds, the jsp engine 
will
+        // scan for them instead.
+        for (Handler handler: collection.getHandlers()) {
+            if (handler instanceof WebAppContext){
+                ((WebAppContext) handler).setAttribute(
+                    
"org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",
+                    
".*/[^/]*servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/[^/]*taglibs.*\\.jar$"
 );
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/activemq/blob/f44c3d20/assembly/pom.xml
----------------------------------------------------------------------
diff --git a/assembly/pom.xml b/assembly/pom.xml
index d7aa25a..dfb3e28 100755
--- a/assembly/pom.xml
+++ b/assembly/pom.xml
@@ -258,10 +258,6 @@
     </dependency>
     <dependency>
       <groupId>org.apache.geronimo.specs</groupId>
-      <artifactId>geronimo-jsp_2.1_spec</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.geronimo.specs</groupId>
       <artifactId>geronimo-j2ee-connector_1.5_spec</artifactId>
     </dependency>
     <dependency>
@@ -272,10 +268,14 @@
       <groupId>org.apache.geronimo.specs</groupId>
       <artifactId>geronimo-j2ee-management_1.1_spec</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.apache.geronimo.specs</groupId>
-      <artifactId>geronimo-servlet_3.0_spec</artifactId>
-    </dependency>
+     <dependency>
+       <groupId>org.apache.tomcat</groupId>
+       <artifactId>tomcat-servlet-api</artifactId>
+     </dependency> 
+     <dependency>
+      <groupId>org.apache.tomcat</groupId>
+      <artifactId>tomcat-websocket-api</artifactId>
+     </dependency> 
     <dependency>
       <groupId>org.apache.geronimo.specs</groupId>
       <artifactId>geronimo-jta_1.0.1B_spec</artifactId>
@@ -357,17 +357,22 @@
         <artifactId>jcl-over-slf4j</artifactId>
     </dependency>
     <dependency>
-      <groupId>javax.servlet</groupId>
-      <artifactId>jstl</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>taglibs</groupId>
-      <artifactId>standard</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.mortbay.jetty</groupId>
-      <artifactId>jsp-2.1-glassfish</artifactId>
-    </dependency>
+        <groupId>org.apache.geronimo.specs</groupId>
+        <artifactId>geronimo-annotation_1.0_spec</artifactId>
+    </dependency>  
+    <dependency>
+               <groupId>org.ow2.asm</groupId>
+               <artifactId>asm</artifactId>
+       </dependency>
+       
+       <dependency>
+               <groupId>org.eclipse.jetty</groupId>
+               <artifactId>apache-jsp</artifactId>
+       </dependency>
+       <dependency>
+               <groupId>org.eclipse.jetty</groupId>
+               <artifactId>apache-jstl</artifactId>
+       </dependency>
     <dependency>
       <groupId>org.jasypt</groupId>
       <artifactId>jasypt</artifactId>

http://git-wip-us.apache.org/repos/asf/activemq/blob/f44c3d20/assembly/src/main/descriptors/common-bin.xml
----------------------------------------------------------------------
diff --git a/assembly/src/main/descriptors/common-bin.xml 
b/assembly/src/main/descriptors/common-bin.xml
index dd9f71d..8405b8b 100644
--- a/assembly/src/main/descriptors/common-bin.xml
+++ b/assembly/src/main/descriptors/common-bin.xml
@@ -247,12 +247,24 @@
         <include>org.springframework:spring-web</include>
         <include>org.springframework:spring-webmvc</include>
         <include>org.eclipse.jetty.aggregate:jetty-all</include>
-        <include>org.apache.geronimo.specs:geronimo-servlet_3.0_spec</include>
-
+        <include>org.apache.tomcat:tomcat-servlet-api</include>
+        <include>org.apache.tomcat:tomcat-websocket-api</include>
+        
         <!-- JSP support -->
-        <include>org.mortbay.jetty:jsp-2.1-glassfish</include>
-        <include>org.mortbay.jetty:jsp-api-2.1-glassfish</include>
-        <include>org.eclipse.jdt:core</include>
+        <!-- Jetty JSP api-->
+        <include>org.eclipse.jetty:apache-jsp</include>
+        <!-- Jetty JSP impl-->
+        <include>org.mortbay.jasper:apache-jsp</include>
+        <!-- jstl and el api -->
+        <include>org.eclipse.jetty:apache-jstl</include>
+        <include>org.apache.taglibs:taglibs-standard-spec</include>
+        <!-- jstl and el impl -->
+        <include>org.mortbay.jasper:apache-el</include>       
+        <include>org.apache.taglibs:taglibs-standard-impl</include>
+        
+               
<include>org.apache.geronimo.specs:geronimo-annotation_1.0_spec</include>
+        <include>org.ow2.asm:asm</include>
+        <include>org.eclipse.jetty.orbit:org.eclipse.jdt.core</include>
 
         <!-- Atom/RSS support -->
         <include>rome:rome</include>

http://git-wip-us.apache.org/repos/asf/activemq/blob/f44c3d20/assembly/src/release/conf/jetty.xml
----------------------------------------------------------------------
diff --git a/assembly/src/release/conf/jetty.xml 
b/assembly/src/release/conf/jetty.xml
index 12e104c..3ff04b6 100644
--- a/assembly/src/release/conf/jetty.xml
+++ b/assembly/src/release/conf/jetty.xml
@@ -45,6 +45,40 @@
         <property name="constraint" ref="adminSecurityConstraint" />
         <property name="pathSpec" value="*.action" />
     </bean>
+    
+       <bean id="secHandlerCollection" 
class="org.eclipse.jetty.server.handler.HandlerCollection">
+               <property name="handlers">
+                       <list>
+                               <bean 
class="org.eclipse.jetty.webapp.WebAppContext">
+                                       <property name="contextPath" 
value="/admin" />
+                                       <property name="resourceBase" 
value="${activemq.home}/webapps/admin" />
+                                       <property name="logUrlOnStart" 
value="true" />
+                               </bean>
+                               <!-- Enable embedded file server for Blob 
messages -->
+                               <!-- <bean 
class="org.eclipse.jetty.webapp.WebAppContext"> <property name="contextPath" 
+                                       value="/fileserver" /> <property 
name="resourceBase" value="${activemq.home}/webapps/fileserver" 
+                                       /> <property name="logUrlOnStart" 
value="true" /> <property name="parentLoaderPriority" 
+                                       value="true" /> </bean> -->
+                               <bean 
class="org.eclipse.jetty.webapp.WebAppContext">
+                                       <property name="contextPath" 
value="/api" />
+                                       <property name="resourceBase" 
value="${activemq.home}/webapps/api" />
+                                       <property name="logUrlOnStart" 
value="true" />
+                               </bean>
+                               <bean 
class="org.eclipse.jetty.server.handler.ResourceHandler">
+                                       <property name="directoriesListed" 
value="false" />
+                                       <property name="welcomeFiles">
+                                               <list>
+                                                       
<value>index.html</value>
+                                               </list>
+                                       </property>
+                                       <property name="resourceBase" 
value="${activemq.home}/webapps/" />
+                               </bean>
+                               <bean id="defaultHandler" 
class="org.eclipse.jetty.server.handler.DefaultHandler">
+                                       <property name="serveIcon" 
value="false" />
+                               </bean>
+                       </list>
+               </property>
+       </bean>    
     <bean id="securityHandler" 
class="org.eclipse.jetty.security.ConstraintSecurityHandler">
         <property name="loginService" ref="securityLoginService" />
         <property name="authenticator">
@@ -56,45 +90,7 @@
                 <ref bean="securityConstraintMapping" />
             </list>
         </property>
-        <property name="handler">
-            <bean id="sec" 
class="org.eclipse.jetty.server.handler.HandlerCollection">
-                <property name="handlers">
-                    <list>
-                        <bean class="org.eclipse.jetty.webapp.WebAppContext">
-                            <property name="contextPath" value="/admin" />
-                            <property name="resourceBase" 
value="${activemq.home}/webapps/admin" />
-                            <property name="logUrlOnStart" value="true" />
-                        </bean>
-                        <!-- Enable embedded file server for Blob messages -->
-                        <!--
-                        <bean class="org.eclipse.jetty.webapp.WebAppContext">
-                            <property name="contextPath" value="/fileserver" />
-                            <property name="resourceBase" 
value="${activemq.home}/webapps/fileserver" />
-                            <property name="logUrlOnStart" value="true" />
-                            <property name="parentLoaderPriority" value="true" 
/>
-                        </bean>
-                        -->
-                        <bean class="org.eclipse.jetty.webapp.WebAppContext">
-                            <property name="contextPath" value="/api" />
-                            <property name="resourceBase" 
value="${activemq.home}/webapps/api" />
-                            <property name="logUrlOnStart" value="true" />
-                        </bean>
-                        <bean 
class="org.eclipse.jetty.server.handler.ResourceHandler">
-                            <property name="directoriesListed" value="false" />
-                            <property name="welcomeFiles">
-                                <list>
-                                    <value>index.html</value>
-                                </list>
-                            </property>
-                            <property name="resourceBase" 
value="${activemq.home}/webapps/" />
-                        </bean>
-                        <bean id="defaultHandler" 
class="org.eclipse.jetty.server.handler.DefaultHandler">
-                            <property name="serveIcon" value="false" />
-                        </bean>
-                    </list>
-                </property>
-            </bean>
-        </property>
+        <property name="handler" ref="secHandlerCollection" />
     </bean>
 
     <bean id="contexts" 
class="org.eclipse.jetty.server.handler.ContextHandlerCollection">
@@ -106,29 +102,9 @@
         <property name="port" value="8161"/>
     </bean>
 
-    <bean id="Server" depends-on="jettyPort" 
class="org.eclipse.jetty.server.Server" init-method="start"
+    <bean id="Server" depends-on="jettyPort" 
class="org.eclipse.jetty.server.Server"
         destroy-method="stop">
 
-        <property name="connectors">
-            <list>
-                <bean id="Connector" 
class="org.eclipse.jetty.server.nio.SelectChannelConnector">
-                     <!-- see the jettyPort bean -->
-                    <property name="host" 
value="#{systemProperties['jetty.host']}" />
-                    <property name="port" 
value="#{systemProperties['jetty.port']}" />
-                </bean>
-                <!--
-                    Enable this connector if you wish to use https with web 
console
-                -->
-                <!--
-                <bean id="SecureConnector" 
class="org.eclipse.jetty.server.ssl.SslSelectChannelConnector">
-                    <property name="port" value="8162" />
-                    <property name="keystore" 
value="file:${activemq.conf}/broker.ks" />
-                    <property name="password" value="password" />
-                </bean>
-                -->
-            </list>
-        </property>
-
         <property name="handler">
             <bean id="handlers" 
class="org.eclipse.jetty.server.handler.HandlerCollection">
                 <property name="handlers">
@@ -142,4 +118,50 @@
 
     </bean>
 
+    <bean id="invokeConnectors" 
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
+       <property name="targetObject" ref="Server" />
+       <property name="targetMethod" value="setConnectors" />
+       <property name="arguments">
+       <list>
+               <bean id="Connector" 
class="org.eclipse.jetty.server.ServerConnector">
+                       <constructor-arg ref="Server" />
+                    <!-- see the jettyPort bean -->
+                   <property name="host" 
value="#{systemProperties['jetty.host']}" />
+                   <property name="port" 
value="#{systemProperties['jetty.port']}" />
+               </bean>
+                <!--
+                    Enable this connector if you wish to use https with web 
console
+                -->
+                <!-- bean id="SecureConnector" 
class="org.eclipse.jetty.server.ServerConnector">
+                                       <constructor-arg ref="Server" />
+                                       <constructor-arg>
+                                               <bean id="handlers" 
class="org.eclipse.jetty.util.ssl.SslContextFactory">
+                                               
+                                                       <property 
name="keyStorePath" value="${activemq.conf}/broker.ks" />
+                                                       <property 
name="keyStorePassword" value="password" />
+                                               </bean>
+                                       </constructor-arg>
+                                       <property name="port" value="8162" />
+                               </bean -->
+            </list>
+       </property>
+    </bean>
+
+       <bean id="configureJetty" 
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
+               <property name="staticMethod" 
value="org.apache.activemq.web.config.JspConfigurer.configureJetty" />
+               <property name="arguments">
+                       <list>
+                               <ref bean="Server" />
+                               <ref bean="secHandlerCollection" />
+                       </list>
+               </property>
+       </bean>
+    
+    <bean id="invokeStart" 
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean" 
+       depends-on="configureJetty, invokeConnectors">
+       <property name="targetObject" ref="Server" />
+       <property name="targetMethod" value="start" />          
+    </bean>
+    
+    
 </beans>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq/blob/f44c3d20/assembly/src/release/examples/conf/jetty-demo.xml
----------------------------------------------------------------------
diff --git a/assembly/src/release/examples/conf/jetty-demo.xml 
b/assembly/src/release/examples/conf/jetty-demo.xml
index f407187..04ca8dc 100644
--- a/assembly/src/release/examples/conf/jetty-demo.xml
+++ b/assembly/src/release/examples/conf/jetty-demo.xml
@@ -45,6 +45,47 @@
         <property name="constraint" ref="adminSecurityConstraint" />
         <property name="pathSpec" value="*.action" />
     </bean>
+
+       <bean id="secHandlerCollection" 
class="org.eclipse.jetty.server.handler.HandlerCollection">
+               <property name="handlers">
+                       <list>
+                               <bean 
class="org.eclipse.jetty.webapp.WebAppContext">
+                                       <property name="contextPath" 
value="/admin" />
+                                       <property name="resourceBase" 
value="${activemq.home}/webapps/admin" />
+                                       <property name="logUrlOnStart" 
value="true" />
+                               </bean>
+                               <bean 
class="org.eclipse.jetty.webapp.WebAppContext">
+                                       <property name="contextPath" 
value="/fileserver" />
+                                       <property name="resourceBase" 
value="${activemq.home}/webapps/fileserver" />
+                                       <property name="logUrlOnStart" 
value="true" />
+                                       <property name="parentLoaderPriority" 
value="true" />
+                               </bean>
+                               <bean 
class="org.eclipse.jetty.webapp.WebAppContext">
+                                       <property name="contextPath" 
value="/demo" />
+                                       <property name="resourceBase" 
value="${activemq.home}/webapps-demo/demo" />
+                                       <property name="logUrlOnStart" 
value="true" />
+                               </bean>
+                               <bean 
class="org.eclipse.jetty.webapp.WebAppContext">
+                                       <property name="contextPath" 
value="/api" />
+                                       <property name="resourceBase" 
value="${activemq.home}/webapps/api" />
+                                       <property name="logUrlOnStart" 
value="true" />
+                               </bean>
+                               <bean 
class="org.eclipse.jetty.server.handler.ResourceHandler">
+                                       <property name="directoriesListed" 
value="false" />
+                                       <property name="welcomeFiles">
+                                               <list>
+                                                       
<value>index.html</value>
+                                               </list>
+                                       </property>
+                                       <property name="resourceBase" 
value="${activemq.home}/webapps/" />
+                               </bean>
+                               <bean id="defaultHandler" 
class="org.eclipse.jetty.server.handler.DefaultHandler">
+                                       <property name="serveIcon" 
value="false" />
+                               </bean>
+                       </list>
+               </property>
+       </bean>    
+       
     <bean id="securityHandler" 
class="org.eclipse.jetty.security.ConstraintSecurityHandler">
         <property name="loginService" ref="securityLoginService" />
         <property name="authenticator">
@@ -56,49 +97,10 @@
                 <ref bean="securityConstraintMapping" />
             </list>
         </property>
-        <property name="handler">
-            <bean id="sec" 
class="org.eclipse.jetty.server.handler.HandlerCollection">
-                <property name="handlers">
-                    <list>
-                        <bean class="org.eclipse.jetty.webapp.WebAppContext">
-                            <property name="contextPath" value="/admin" />
-                            <property name="resourceBase" 
value="${activemq.home}/webapps/admin" />
-                            <property name="logUrlOnStart" value="true" />
-                        </bean>
-                        <bean class="org.eclipse.jetty.webapp.WebAppContext">
-                            <property name="contextPath" value="/fileserver" />
-                            <property name="resourceBase" 
value="${activemq.home}/webapps/fileserver" />
-                            <property name="logUrlOnStart" value="true" />
-                            <property name="parentLoaderPriority" value="true" 
/>
-                        </bean>
-                        <bean class="org.eclipse.jetty.webapp.WebAppContext">
-                            <property name="contextPath" value="/demo" />
-                            <property name="resourceBase" 
value="${activemq.home}/webapps-demo/demo" />
-                            <property name="logUrlOnStart" value="true" />
-                        </bean>
-                        <bean class="org.eclipse.jetty.webapp.WebAppContext">
-                            <property name="contextPath" value="/api" />
-                            <property name="resourceBase" 
value="${activemq.home}/webapps/api" />
-                            <property name="logUrlOnStart" value="true" />
-                        </bean>
-                        <bean 
class="org.eclipse.jetty.server.handler.ResourceHandler">
-                            <property name="directoriesListed" value="false" />
-                            <property name="welcomeFiles">
-                                <list>
-                                    <value>index.html</value>
-                                </list>
-                            </property>
-                            <property name="resourceBase" 
value="${activemq.home}/webapps/" />
-                        </bean>
-                        <bean id="defaultHandler" 
class="org.eclipse.jetty.server.handler.DefaultHandler">
-                            <property name="serveIcon" value="false" />
-                        </bean>
-                    </list>
-                </property>
-            </bean>
-        </property>
+        <property name="handler" ref="secHandlerCollection" />
     </bean>
 
+
     <bean id="contexts" 
class="org.eclipse.jetty.server.handler.ContextHandlerCollection">
     </bean>
 
@@ -106,29 +108,10 @@
              <!-- the default port number for the web console -->
         <property name="port" value="8161"/>
     </bean>
-
-    <bean id="Server" depends-on="jettyPort" 
class="org.eclipse.jetty.server.Server" init-method="start"
+    
+        <bean id="Server" depends-on="jettyPort" 
class="org.eclipse.jetty.server.Server"
         destroy-method="stop">
 
-        <property name="connectors">
-            <list>
-                <bean id="Connector" 
class="org.eclipse.jetty.server.nio.SelectChannelConnector">
-                     <!-- see the jettyPort bean -->
-                    <property name="port" 
value="#{systemProperties['jetty.port']}" />
-                </bean>
-                <!--
-                    Enable this connector if you wish to use https with web 
console
-                -->
-                <!--
-                <bean id="SecureConnector" 
class="org.eclipse.jetty.server.ssl.SslSelectChannelConnector">
-                    <property name="port" value="8162" />
-                    <property name="keystore" 
value="file:${activemq.conf}/broker.ks" />
-                    <property name="password" value="password" />
-                </bean>
-                -->
-            </list>
-        </property>
-
         <property name="handler">
             <bean id="handlers" 
class="org.eclipse.jetty.server.handler.HandlerCollection">
                 <property name="handlers">
@@ -142,4 +125,50 @@
 
     </bean>
 
+    <bean id="invokeConnectors" 
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
+       <property name="targetObject" ref="Server" />
+       <property name="targetMethod" value="setConnectors" />
+       <property name="arguments">
+       <list>
+               <bean id="Connector" 
class="org.eclipse.jetty.server.ServerConnector">
+                       <constructor-arg ref="Server" />
+                     <!-- see the jettyPort bean -->
+                    <property name="port" 
value="#{systemProperties['jetty.port']}" />
+                </bean>
+                <!--
+                    Enable this connector if you wish to use https with web 
console
+                -->
+                <!-- bean id="SecureConnector" 
class="org.eclipse.jetty.server.ServerConnector">
+                                       <constructor-arg ref="Server" />
+                                       <constructor-arg>
+                                               <bean id="handlers" 
class="org.eclipse.jetty.util.ssl.SslContextFactory">
+                                               
+                                                       <property 
name="keyStorePath" value="${activemq.conf}/broker.ks" />
+                                                       <property 
name="keyStorePassword" value="password" />
+                                               </bean>
+                                       </constructor-arg>
+                                       <property name="port" value="8162" />
+                               </bean -->
+            </list>
+       </property>
+    </bean>
+    
+    
+    <bean id="configureJetty" 
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
+               <property name="staticMethod" 
value="org.apache.activemq.web.config.JspConfigurer.configureJetty" />
+               <property name="arguments">
+                       <list>
+                               <ref bean="Server" />
+                               <ref bean="secHandlerCollection" />
+                       </list>
+               </property>
+       </bean>
+    
+    <bean id="invokeStart" 
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean" 
+       depends-on="configureJetty, invokeConnectors">
+       <property name="targetObject" ref="Server" />
+       <property name="targetMethod" value="start" />          
+    </bean>
+    
+
 </beans>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq/blob/f44c3d20/assembly/src/release/webapps/api/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/assembly/src/release/webapps/api/WEB-INF/web.xml 
b/assembly/src/release/webapps/api/WEB-INF/web.xml
index d887383..3c24ad5 100644
--- a/assembly/src/release/webapps/api/WEB-INF/web.xml
+++ b/assembly/src/release/webapps/api/WEB-INF/web.xml
@@ -15,11 +15,10 @@
     See the License for the specific language governing permissions and
     limitations under the License.
 -->
-<!DOCTYPE web-app
-        PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
-        "http://java.sun.com/dtd/web-app_2_3.dtd";>
-
-<web-app>
+<web-app xmlns="http://java.sun.com/xml/ns/javaee";
+      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd";
+      version="3.0"> 
 
     <display-name>Apache ActiveMQ REST API</display-name>
 
@@ -27,6 +26,7 @@
         <servlet-name>MessageServlet</servlet-name>
         <servlet-class>org.apache.activemq.web.MessageServlet</servlet-class>
         <load-on-startup>1</load-on-startup>
+        <async-supported>true</async-supported>
         <!--
         Uncomment this parameter if you plan to use multiple consumers over 
REST
         <init-param>
@@ -38,8 +38,7 @@
 
     <servlet>
         <servlet-name>jolokia-agent</servlet-name>
-        <servlet-class>org.jolokia.http.AgentServlet</servlet-class>
-        <load-on-startup>1</load-on-startup>     
+        <servlet-class>org.jolokia.http.AgentServlet</servlet-class>        
         <init-param>
           <param-name>discoveryEnabled</param-name>
           <param-value>false</param-value>
@@ -52,6 +51,7 @@
           <param-name>agentDescription</param-name>
           <param-value>Apache ActiveMQ</param-value>
         </init-param>
+        <load-on-startup>1</load-on-startup> 
     </servlet>
 
     <servlet-mapping>

http://git-wip-us.apache.org/repos/asf/activemq/blob/f44c3d20/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 1ba3c65..6dfc996 100755
--- a/pom.xml
+++ b/pom.xml
@@ -75,12 +75,10 @@
     <jasypt-version>1.9.2</jasypt-version>
     <jaxb-bundle-version>2.2.11_1</jaxb-bundle-version>
     <jdom-version>1.0</jdom-version>
-    <jetty9-version>9.2.6.v20141205</jetty9-version>
-    <jetty8-version>8.1.16.v20140903</jetty8-version>
-    <jetty-version>${jetty8-version}</jetty-version>
+    <jetty9-version>9.2.13.v20150730</jetty9-version>
+    <jetty-version>${jetty9-version}</jetty-version>
     <jmdns-version>3.4.1</jmdns-version>
-    <jsp-version>2.1.v20100127</jsp-version>
-    <jstl-version>1.1.2</jstl-version>
+    <tomcat-api-version>8.0.24</tomcat-api-version>
     <jettison-version>1.3.7</jettison-version>
     <jmock-version>2.5.1</jmock-version>
     <jolokia-version>1.3.1</jolokia-version>
@@ -539,17 +537,27 @@
         <artifactId>geronimo-j2ee-connector_1.5_spec</artifactId>
         <version>2.0.0</version>
       </dependency>
-
+               <dependency>
+                       <groupId>org.ow2.asm</groupId>
+                       <artifactId>asm</artifactId>
+                       <version>5.0.3</version>
+               </dependency>
+       
+      <!-- Servlet 3.1 and JSP -->
       <dependency>
-        <groupId>org.apache.geronimo.specs</groupId>
-        <artifactId>geronimo-jsp_2.1_spec</artifactId>
-        <version>1.0.1</version>
+       <groupId>org.apache.tomcat</groupId>
+       <artifactId>tomcat-jsp-api</artifactId>
+       <version>${tomcat-api-version}</version>
+      </dependency>
+       <dependency>
+       <groupId>org.apache.tomcat</groupId>
+       <artifactId>tomcat-servlet-api</artifactId>
+       <version>${tomcat-api-version}</version>
       </dependency>
-
       <dependency>
-        <groupId>org.apache.geronimo.specs</groupId>
-        <artifactId>geronimo-servlet_3.0_spec</artifactId>
-        <version>1.0</version>
+        <groupId>org.apache.tomcat</groupId>
+        <artifactId>tomcat-websocket-api</artifactId>
+        <version>${tomcat-api-version}</version>
       </dependency>
 
       <dependency>
@@ -923,19 +931,39 @@
         <artifactId>xpp3</artifactId>
         <version>${xpp3-version}</version>
       </dependency>
+      
 
       <dependency>
-        <groupId>org.mortbay.jetty</groupId>
-        <artifactId>jsp-2.1-glassfish</artifactId>
-        <version>${jsp-version}</version>
+        <groupId>org.eclipse.jetty</groupId>
+        <artifactId>apache-jsp</artifactId>
+        <version>${jetty-version}</version>
       </dependency>
-
       <dependency>
-        <groupId>org.eclipse.jetty.aggregate</groupId>
-        <artifactId>jetty-all</artifactId>
+        <groupId>org.eclipse.jetty</groupId>
+        <artifactId>apache-jstl</artifactId>
         <version>${jetty-version}</version>
       </dependency>
 
+    <dependency>
+      <groupId>org.eclipse.jetty.aggregate</groupId>
+      <artifactId>jetty-all</artifactId>
+      <version>${jetty-version}</version>
+      <exclusions>
+        <exclusion>
+          <groupId>javax.servlet</groupId>
+          <artifactId>javax.servlet-api</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>javax.websocket</groupId>
+          <artifactId>javax.websocket-api</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+       <dependency>
+               <groupId>org.eclipse.jetty.websocket</groupId>
+               <artifactId>websocket-server</artifactId>
+               <version>${jetty-version}</version>
+       </dependency>
       <dependency>
         <groupId>org.apache.httpcomponents</groupId>
         <artifactId>httpclient</artifactId>
@@ -996,7 +1024,7 @@
         <artifactId>jettison</artifactId>
         <version>${jettison-version}</version>
     </dependency>
-
+  
       <dependency>
         <groupId>annogen</groupId>
         <artifactId>annogen</artifactId>
@@ -1058,7 +1086,7 @@
         <artifactId>jcl-over-slf4j</artifactId>
         <version>${slf4j-version}</version>
       </dependency>
-      <dependency>
+      <!-- >dependency>
         <groupId>javax.servlet</groupId>
         <artifactId>jstl</artifactId>
         <version>${jstl-version}</version>
@@ -1067,7 +1095,7 @@
         <groupId>taglibs</groupId>
         <artifactId>standard</artifactId>
         <version>1.1.2</version>
-      </dependency>
+      </dependency -->
 
       <dependency>
         <groupId>org.apache.geronimo.components</groupId>
@@ -1191,7 +1219,7 @@
           <version>${apache-rat-plugin-version}</version>
         </plugin>
         <plugin>
-          <groupId>org.mortbay.jetty</groupId>
+          <groupId>org.eclipse.jetty</groupId>
           <artifactId>jetty-maven-plugin</artifactId>
           <version>${jetty-version}</version>
         </plugin>

Reply via email to