You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2016/04/20 14:53:48 UTC

[1/7] camel git commit: CAMEL-9890: Migrate Camel-websocket to Jetty9

Repository: camel
Updated Branches:
  refs/heads/master b3a800e85 -> 5356ab0d8


CAMEL-9890: Migrate Camel-websocket to Jetty9


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/51ca71eb
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/51ca71eb
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/51ca71eb

Branch: refs/heads/master
Commit: 51ca71eb72604965ad70b5c65d82e91705ebc6af
Parents: b3a800e
Author: Andrea Cosentino <an...@gmail.com>
Authored: Wed Apr 20 13:18:58 2016 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Wed Apr 20 13:18:58 2016 +0200

----------------------------------------------------------------------
 components/camel-websocket/pom.xml              |  22 +++-
 .../component/websocket/DefaultWebsocket.java   |  35 +++---
 .../component/websocket/WebsocketComponent.java | 113 +++++++------------
 .../websocket/WebsocketComponentServlet.java    |  12 +-
 .../component/websocket/WebsocketProducer.java  |   8 +-
 .../websocket/DefaultWebsocketTest.java         |  30 ++---
 6 files changed, 102 insertions(+), 118 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/51ca71eb/components/camel-websocket/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-websocket/pom.xml b/components/camel-websocket/pom.xml
index 954115d..eb09fa7 100644
--- a/components/camel-websocket/pom.xml
+++ b/components/camel-websocket/pom.xml
@@ -52,24 +52,34 @@
         </dependency>
         <!-- Jetty -->
         <dependency>
-            <groupId>org.eclipse.jetty</groupId>
-            <artifactId>jetty-websocket</artifactId>
-            <version>${jetty8-version}</version>
+            <groupId>org.eclipse.jetty.websocket</groupId>
+            <artifactId>websocket-server</artifactId>
+            <version>${jetty9-version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty.websocket</groupId>
+            <artifactId>websocket-client</artifactId>
+            <version>${jetty9-version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty.websocket</groupId>
+            <artifactId>websocket-api</artifactId>
+            <version>${jetty9-version}</version>
         </dependency>
         <dependency>
             <groupId>org.eclipse.jetty</groupId>
             <artifactId>jetty-servlet</artifactId>
-            <version>${jetty8-version}</version>
+            <version>${jetty9-version}</version>
         </dependency>
         <dependency>
             <groupId>org.eclipse.jetty</groupId>
             <artifactId>jetty-servlets</artifactId>
-            <version>${jetty8-version}</version>
+            <version>${jetty9-version}</version>
         </dependency>
         <dependency>
             <groupId>org.eclipse.jetty</groupId>
             <artifactId>jetty-jmx</artifactId>
-            <version>${jetty8-version}</version>
+            <version>${jetty9-version}</version>
         </dependency>
         
         <!-- test dependencies -->

http://git-wip-us.apache.org/repos/asf/camel/blob/51ca71eb/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/DefaultWebsocket.java
----------------------------------------------------------------------
diff --git a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/DefaultWebsocket.java b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/DefaultWebsocket.java
index 60dbec3..8cf91a1 100644
--- a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/DefaultWebsocket.java
+++ b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/DefaultWebsocket.java
@@ -19,19 +19,22 @@ package org.apache.camel.component.websocket;
 import java.io.Serializable;
 import java.util.UUID;
 
-import org.eclipse.jetty.websocket.WebSocket;
-import org.eclipse.jetty.websocket.WebSocket.OnBinaryMessage;
-import org.eclipse.jetty.websocket.WebSocket.OnTextMessage;
+import org.eclipse.jetty.websocket.api.Session;
+import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose;
+import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect;
+import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage;
+import org.eclipse.jetty.websocket.api.annotations.WebSocket;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class DefaultWebsocket implements WebSocket, OnTextMessage, OnBinaryMessage, Serializable {
+@WebSocket
+public class DefaultWebsocket implements Serializable {
     private static final long serialVersionUID = 1L;
     private static final Logger LOG = LoggerFactory.getLogger(DefaultWebsocket.class);
 
     private final WebsocketConsumer consumer;
     private final NodeSynchronization sync;
-    private Connection connection;
+    private Session session;
     private String connectionKey;
 
     public DefaultWebsocket(NodeSynchronization sync, WebsocketConsumer consumer) {
@@ -39,21 +42,21 @@ public class DefaultWebsocket implements WebSocket, OnTextMessage, OnBinaryMessa
         this.consumer = consumer;
     }
 
-    @Override
+    @OnWebSocketClose
     public void onClose(int closeCode, String message) {
         LOG.trace("onClose {} {}", closeCode, message);
         sync.removeSocket(this);
     }
 
-    @Override
-    public void onOpen(Connection connection) {
-        LOG.trace("onOpen {}", connection);
-        this.connection = connection;
+    @OnWebSocketConnect
+    public void onConnect(Session session) {
+        LOG.trace("onConnect {}", session);
+        this.session = session;
         this.connectionKey = UUID.randomUUID().toString();
         sync.addSocket(this);
     }
 
-    @Override
+    @OnWebSocketMessage
     public void onMessage(String message) {
         LOG.debug("onMessage: {}", message);
         if (this.consumer != null) {
@@ -64,7 +67,7 @@ public class DefaultWebsocket implements WebSocket, OnTextMessage, OnBinaryMessa
     }
 
 
-    @Override
+    @OnWebSocketMessage
     public void onMessage(byte[] data, int offset, int length) {
         LOG.debug("onMessage: byte[]");
         if (this.consumer != null) {
@@ -76,12 +79,12 @@ public class DefaultWebsocket implements WebSocket, OnTextMessage, OnBinaryMessa
         }
     }
 
-    public Connection getConnection() {
-        return connection;
+    public Session getSession() {
+        return session;
     }
 
-    public void setConnection(Connection connection) {
-        this.connection = connection;
+    public void setSession(Session session) {
+        this.session = session;
     }
 
     public String getConnectionKey() {

http://git-wip-us.apache.org/repos/asf/camel/blob/51ca71eb/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponent.java b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponent.java
index dee57b0..71c4191 100644
--- a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponent.java
+++ b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponent.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.websocket;
 
+import java.lang.management.ManagementFactory;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.net.URL;
@@ -23,36 +24,33 @@ import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import javax.management.MBeanServer;
 import javax.servlet.DispatcherType;
 
 import org.apache.camel.Endpoint;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.impl.UriEndpointComponent;
-import org.apache.camel.spi.ManagementAgent;
-import org.apache.camel.spi.ManagementStrategy;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.jsse.SSLContextParameters;
-import org.eclipse.jetty.http.ssl.SslContextFactory;
 import org.eclipse.jetty.jmx.MBeanContainer;
 import org.eclipse.jetty.server.Connector;
 import org.eclipse.jetty.server.Handler;
+import org.eclipse.jetty.server.HttpConfiguration;
+import org.eclipse.jetty.server.HttpConnectionFactory;
 import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.ServerConnector;
 import org.eclipse.jetty.server.SessionManager;
 import org.eclipse.jetty.server.handler.ContextHandlerCollection;
 import org.eclipse.jetty.server.handler.HandlerCollection;
 import org.eclipse.jetty.server.handler.HandlerWrapper;
-import org.eclipse.jetty.server.nio.SelectChannelConnector;
 import org.eclipse.jetty.server.session.HashSessionManager;
 import org.eclipse.jetty.server.session.SessionHandler;
-import org.eclipse.jetty.server.ssl.SslConnector;
-import org.eclipse.jetty.server.ssl.SslSelectChannelConnector;
 import org.eclipse.jetty.servlet.DefaultServlet;
 import org.eclipse.jetty.servlet.FilterHolder;
 import org.eclipse.jetty.servlet.ServletContextHandler;
 import org.eclipse.jetty.servlet.ServletHolder;
 import org.eclipse.jetty.servlets.CrossOriginFilter;
 import org.eclipse.jetty.util.resource.Resource;
+import org.eclipse.jetty.util.ssl.SslContextFactory;
 import org.eclipse.jetty.util.thread.QueuedThreadPool;
 import org.eclipse.jetty.util.thread.ThreadPool;
 import org.slf4j.Logger;
@@ -88,12 +86,12 @@ public class WebsocketComponent extends UriEndpointComponent {
 
     class ConnectorRef {
         Server server;
-        Connector connector;
+        ServerConnector connector;
         WebsocketComponentServlet servlet;
         MemoryWebsocketStore memoryStore;
         int refCount;
 
-        public ConnectorRef(Server server, Connector connector, WebsocketComponentServlet servlet, MemoryWebsocketStore memoryStore) {
+        public ConnectorRef(Server server, ServerConnector connector, WebsocketComponentServlet servlet, MemoryWebsocketStore memoryStore) {
             this.server = server;
             this.connector = connector;
             this.servlet = servlet;
@@ -136,11 +134,16 @@ public class WebsocketComponent extends UriEndpointComponent {
         synchronized (CONNECTORS) {
             ConnectorRef connectorRef = CONNECTORS.get(connectorKey);
             if (connectorRef == null) {
-                Connector connector;
+                ServerConnector connector;
+                // Create Server and add connector
+                server = createServer();
+                if (endpoint.isEnableJmx()) {
+                    enableJmx(server);
+                }
                 if (endpoint.getSslContextParameters() != null) {
-                    connector = getSslSocketConnector(endpoint.getSslContextParameters());
+                    connector = getSslSocketConnector(server, endpoint.getSslContextParameters());
                 } else {
-                    connector = new SelectChannelConnector();
+                    connector = new ServerConnector(server);
                 }
 
                 if (endpoint.getPort() != null) {
@@ -155,11 +158,6 @@ public class WebsocketComponent extends UriEndpointComponent {
                     connector.setHost(host);
                 }
 
-                // Create Server and add connector
-                server = createServer();
-                if (endpoint.isEnableJmx()) {
-                    enableJmx(server);
-                }
                 server.addConnector(connector);
                 LOG.trace("Jetty Connector added: {}", connector.getName());
 
@@ -246,8 +244,8 @@ public class WebsocketComponent extends UriEndpointComponent {
                     // Camel controls the lifecycle of these entities so remove the
                     // registered MBeans when Camel is done with the managed objects.
                     if (mbContainer != null) {
-                        mbContainer.removeBean(connectorRef.server);
-                        mbContainer.removeBean(connectorRef.connector);
+                        mbContainer.beanRemoved(null, connectorRef.server);
+                        mbContainer.beanRemoved(null,connectorRef.connector);
                     }
                 }
                 if (prodcon instanceof WebsocketConsumer) {
@@ -263,20 +261,7 @@ public class WebsocketComponent extends UriEndpointComponent {
     public synchronized MBeanContainer getMbContainer() {
         // If null, provide the default implementation.
         if (mbContainer == null) {
-            MBeanServer mbs = null;
-
-            final ManagementStrategy mStrategy = this.getCamelContext().getManagementStrategy();
-            final ManagementAgent mAgent = mStrategy.getManagementAgent();
-            if (mAgent != null) {
-                mbs = mAgent.getMBeanServer();
-            }
-
-            if (mbs != null) {
-                mbContainer = new MBeanContainer(mbs);
-                startMbContainer();
-            } else {
-                LOG.warn("JMX disabled in CamelContext. Jetty JMX extensions will remain disabled.");
-            }
+            mbContainer=new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
         }
 
         return this.mbContainer;
@@ -354,9 +339,7 @@ public class WebsocketComponent extends UriEndpointComponent {
     }
 
     protected Server createServer() throws Exception {
-        Server server = new Server();
-        ContextHandlerCollection collection = new ContextHandlerCollection();
-        server.setHandler(collection);
+        Server server = null;
 
         // configure thread pool if min/max given
         if (minThreads != null || maxThreads != null) {
@@ -377,11 +360,15 @@ public class WebsocketComponent extends UriEndpointComponent {
             } catch (Exception e) {
                 throw new RuntimeCamelException("Error starting JettyWebSocketServer thread pool: " + qtp, e);
             }
-            server.setThreadPool(qtp);
+            server = new Server(qtp);
+            ContextHandlerCollection collection = new ContextHandlerCollection();
+            server.setHandler(collection);
         }
 
         if (getThreadPool() != null) {
-            server.setThreadPool(getThreadPool());
+            server = new Server(getThreadPool());
+            ContextHandlerCollection collection = new ContextHandlerCollection();
+            server.setHandler(collection);
         }
 
         return server;
@@ -425,7 +412,8 @@ public class WebsocketComponent extends UriEndpointComponent {
 
     protected Server createStaticResourcesServer(ServletContextHandler context, String host, int port, String home) throws Exception {
         Server server = new Server();
-        Connector connector = new SelectChannelConnector();
+        HttpConfiguration http_config = new HttpConfiguration();
+        ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(http_config));
         connector.setHost(host);
         connector.setPort(port);
         server.addConnector(connector);
@@ -467,7 +455,7 @@ public class WebsocketComponent extends UriEndpointComponent {
 
     protected ServletContextHandler createContext(Server server, Connector connector, List<Handler> handlers) throws Exception {
         ServletContextHandler context = new ServletContextHandler(server, "/", ServletContextHandler.NO_SECURITY | ServletContextHandler.NO_SESSIONS);
-        context.setConnectorNames(new String[]{connector.getName()});
+        server.addConnector(connector);
 
         if (handlers != null && !handlers.isEmpty()) {
             for (Handler handler : handlers) {
@@ -486,24 +474,6 @@ public class WebsocketComponent extends UriEndpointComponent {
         return context;
     }
 
-    /**
-     * Starts {@link #mbContainer} and registers the container with itself as a managed bean
-     * logging an error if there is a problem starting the container.
-     * Does nothing if {@link #mbContainer} is {@code null}.
-     */
-    protected void startMbContainer() {
-        if (mbContainer != null && !mbContainer.isStarted()) {
-            try {
-                mbContainer.start();
-                // Publish the container itself for consistency with
-                // traditional embedded Jetty configurations.
-                mbContainer.addBean(mbContainer);
-            } catch (Throwable e) {
-                LOG.warn("Could not start JettyWebSocket MBeanContainer. Jetty JMX extensions will remain disabled.", e);
-            }
-        }
-    }
-
     private void enableSessionSupport(Server server, String connectorKey) throws Exception {
         ServletContextHandler context = server.getChildHandlerByClass(ServletContextHandler.class);
         if (context.getSessionHandler() == null) {
@@ -516,21 +486,20 @@ public class WebsocketComponent extends UriEndpointComponent {
         }
     }
 
-    private SslConnector getSslSocketConnector(SSLContextParameters sslContextParameters) throws Exception {
-        SslSelectChannelConnector sslSocketConnector = null;
+    private ServerConnector getSslSocketConnector(Server server, SSLContextParameters sslContextParameters) throws Exception {
+        ServerConnector sslSocketConnector = null;
         if (sslContextParameters != null) {
             SslContextFactory sslContextFactory = new WebSocketComponentSslContextFactory();
             sslContextFactory.setSslContext(sslContextParameters.createSSLContext());
-            sslSocketConnector = new SslSelectChannelConnector(sslContextFactory);
+            sslSocketConnector = new ServerConnector(server, sslContextFactory);
         } else {
-            sslSocketConnector = new SslSelectChannelConnector();
-            // with default null values, jetty ssl system properties
-            // and console will be read by jetty implementation
-            sslSocketConnector.getSslContextFactory().setKeyManagerPassword(sslPassword);
-            sslSocketConnector.getSslContextFactory().setKeyStorePassword(sslKeyPassword);
+            SslContextFactory sslContextFactory = new SslContextFactory();
+            sslContextFactory.setKeyStorePassword(sslKeyPassword);
+            sslContextFactory.setKeyManagerPassword(sslPassword);
             if (sslKeystore != null) {
-                sslSocketConnector.getSslContextFactory().setKeyStorePath(sslKeystore);
+            	sslContextFactory.setKeyStorePath(sslKeystore);
             }
+            sslSocketConnector = new ServerConnector(server, sslContextFactory);
 
         }
         return sslSocketConnector;
@@ -550,12 +519,6 @@ public class WebsocketComponent extends UriEndpointComponent {
                 return true;
             }
         }
-
-        // This method is for Jetty 7.5.x
-        @Override
-        public void checkKeyStore() {
-            // here we don't check the SslContext as it is already created
-        }
     }
 
     private static boolean checkSSLContextFactoryConfig(Object instance) {
@@ -615,7 +578,7 @@ public class WebsocketComponent extends UriEndpointComponent {
         MBeanContainer containerToRegister = getMbContainer();
         if (containerToRegister != null) {
             LOG.info("Jetty JMX Extensions is enabled");
-            server.getContainer().addEventListener(containerToRegister);
+            server.addEventListener(containerToRegister);
             // Since we may have many Servers running, don't tie the MBeanContainer
             // to a Server lifecycle or we end up closing it while it is still in use.
             //server.addBean(mbContainer);
@@ -798,7 +761,7 @@ public class WebsocketComponent extends UriEndpointComponent {
             ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
             staticResourcesServer = createStaticResourcesServer(context, host, port, staticResources);
             staticResourcesServer.start();
-            Connector connector = staticResourcesServer.getConnectors()[0];
+            ServerConnector connector = (ServerConnector) staticResourcesServer.getConnectors()[0];
 
             // must add static resource server to CONNECTORS in case the websocket producers/consumers
             // uses the same port number, and therefore we must be part of this

http://git-wip-us.apache.org/repos/asf/camel/blob/51ca71eb/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponentServlet.java
----------------------------------------------------------------------
diff --git a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponentServlet.java b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponentServlet.java
index 078c61a..91173b5 100644
--- a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponentServlet.java
+++ b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponentServlet.java
@@ -21,8 +21,9 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import javax.servlet.http.HttpServletRequest;
 
-import org.eclipse.jetty.websocket.WebSocket;
-import org.eclipse.jetty.websocket.WebSocketServlet;
+import org.eclipse.jetty.websocket.api.annotations.WebSocket;
+import org.eclipse.jetty.websocket.servlet.WebSocketServlet;
+import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -59,7 +60,6 @@ public class WebsocketComponentServlet extends WebSocketServlet {
         consumers.remove(consumer.getPath());
     }
 
-    @Override
     public WebSocket doWebSocketConnect(HttpServletRequest request, String protocol) {
         String protocolKey = protocol;
 
@@ -79,4 +79,10 @@ public class WebsocketComponentServlet extends WebSocketServlet {
     public void setSocketFactory(Map<String, WebSocketFactory> socketFactory) {
         this.socketFactory = socketFactory;
     }
+
+	@Override
+	public void configure(WebSocketServletFactory factory) {
+		// TODO Auto-generated method stub
+		
+	}
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/51ca71eb/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketProducer.java b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketProducer.java
index 91cfb5e..17ca06a 100644
--- a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketProducer.java
+++ b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketProducer.java
@@ -17,6 +17,7 @@
 package org.apache.camel.component.websocket;
 
 import java.io.IOException;
+import java.nio.ByteBuffer;
 import java.util.Collection;
 
 import org.apache.camel.CamelExchangeException;
@@ -101,12 +102,13 @@ public class WebsocketProducer extends DefaultProducer implements WebsocketProdu
 
     void sendMessage(DefaultWebsocket websocket, Object message) throws IOException {
         // in case there is web socket and socket connection is open - send message
-        if (websocket != null && websocket.getConnection().isOpen()) {
+        if (websocket != null && websocket.getSession().isOpen()) {
             log.trace("Sending to websocket {} -> {}", websocket.getConnectionKey(), message);
             if (message instanceof String) {
-                websocket.getConnection().sendMessage((String) message);
+                websocket.getSession().getRemote().sendString((String) message);
             } else if (message instanceof byte[]) {
-                websocket.getConnection().sendMessage((byte[]) message, 0, ((byte[]) message).length);
+            	ByteBuffer buf = ByteBuffer.wrap((byte[]) message);
+                websocket.getSession().getRemote().sendBytes(buf);
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/51ca71eb/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/DefaultWebsocketTest.java
----------------------------------------------------------------------
diff --git a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/DefaultWebsocketTest.java b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/DefaultWebsocketTest.java
index 0155036..f7a29f3 100644
--- a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/DefaultWebsocketTest.java
+++ b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/DefaultWebsocketTest.java
@@ -16,7 +16,7 @@
  */
 package org.apache.camel.component.websocket;
 
-import org.eclipse.jetty.websocket.WebSocket.Connection;
+import org.eclipse.jetty.websocket.api.Session;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -41,7 +41,7 @@ public class DefaultWebsocketTest {
     private static final String CONNECTION_KEY = "random-connection-key";
 
     @Mock
-    private Connection connection;
+    private Session session;
     @Mock
     private WebsocketConsumer consumer;
     @Mock
@@ -58,14 +58,14 @@ public class DefaultWebsocketTest {
     @Test
     public void testOnClose() {
         defaultWebsocket.onClose(CLOSE_CODE, MESSAGE);
-        InOrder inOrder = inOrder(connection, consumer, sync);
+        InOrder inOrder = inOrder(session, consumer, sync);
         inOrder.verify(sync, times(1)).removeSocket(defaultWebsocket);
         inOrder.verifyNoMoreInteractions();
     }
 
     @Test
     public void testOnOpen() {
-        defaultWebsocket.onOpen(connection);
+        defaultWebsocket.onConnect(session);
 
         /*
          * keyCaptor not functional anymore, because addSocket cannot be called with connectionKey
@@ -74,14 +74,14 @@ public class DefaultWebsocketTest {
          * times(1)).addSocket((eq(defaultWebsocket))); inOrder.verifyNoMoreInteractions();
          */
 
-        assertEquals(connection, defaultWebsocket.getConnection());
+        assertEquals(session, defaultWebsocket.getSession());
     }
 
     @Test
     public void testOnMessage() {
         defaultWebsocket.setConnectionKey(CONNECTION_KEY);
         defaultWebsocket.onMessage(MESSAGE);
-        InOrder inOrder = inOrder(connection, consumer, sync);
+        InOrder inOrder = inOrder(session, consumer, sync);
         inOrder.verify(consumer, times(1)).sendMessage(CONNECTION_KEY, MESSAGE);
         inOrder.verifyNoMoreInteractions();
     }
@@ -91,20 +91,20 @@ public class DefaultWebsocketTest {
         defaultWebsocket = new DefaultWebsocket(sync, null);
         defaultWebsocket.setConnectionKey(CONNECTION_KEY);
         defaultWebsocket.onMessage(MESSAGE);
-        InOrder inOrder = inOrder(connection, consumer, sync);
+        InOrder inOrder = inOrder(session, consumer, sync);
         inOrder.verify(consumer, times(0)).sendMessage(CONNECTION_KEY, MESSAGE);
         inOrder.verifyNoMoreInteractions();
     }
 
     @Test
     public void testGetConnection() {
-        assertNull(defaultWebsocket.getConnection());
-        defaultWebsocket.onOpen(connection);
-        assertEquals(connection, defaultWebsocket.getConnection());
-        defaultWebsocket.setConnection(null);
-        assertNull(defaultWebsocket.getConnection());
-        defaultWebsocket.setConnection(connection);
-        assertEquals(connection, defaultWebsocket.getConnection());
+        assertNull(defaultWebsocket.getSession());
+        defaultWebsocket.onConnect(session);
+        assertEquals(session, defaultWebsocket.getSession());
+        defaultWebsocket.setSession(null);
+        assertNull(defaultWebsocket.getSession());
+        defaultWebsocket.setSession(session);
+        assertEquals(session, defaultWebsocket.getSession());
     }
 
     @Test
@@ -116,7 +116,7 @@ public class DefaultWebsocketTest {
     public void testGetConnectionKey() {
         defaultWebsocket.setConnectionKey(null);
         assertNull(defaultWebsocket.getConnectionKey());
-        defaultWebsocket.onOpen(connection);
+        defaultWebsocket.onConnect(session);
         assertNotNull(defaultWebsocket.getConnectionKey());
         defaultWebsocket.setConnectionKey(CONNECTION_KEY);
         assertEquals(CONNECTION_KEY, defaultWebsocket.getConnectionKey());


[4/7] camel git commit: CAMEL-9890: Migrate Camel-websocket to Jetty9 - Use the correct version range for optional resolution

Posted by ac...@apache.org.
CAMEL-9890: Migrate Camel-websocket to Jetty9 - Use the correct version range for optional resolution


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/0e28a8b1
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0e28a8b1
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0e28a8b1

Branch: refs/heads/master
Commit: 0e28a8b1ef8afd1f1e699c2b991590be924601e6
Parents: 08ffb55
Author: Andrea Cosentino <an...@gmail.com>
Authored: Wed Apr 20 13:20:40 2016 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Wed Apr 20 13:20:40 2016 +0200

----------------------------------------------------------------------
 components/camel-websocket/pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/0e28a8b1/components/camel-websocket/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-websocket/pom.xml b/components/camel-websocket/pom.xml
index eb09fa7..9fd1bfb 100644
--- a/components/camel-websocket/pom.xml
+++ b/components/camel-websocket/pom.xml
@@ -36,7 +36,7 @@
         </camel.osgi.export.pkg>
         <camel.osgi.import.pkg>
             !org.apache.camel.component.websocket.*,
-            org.eclipse.jetty.util.ssl;version="[7.6,8.2)";resolution:=optional,
+            org.eclipse.jetty.util.ssl;version="[9,9.5)";resolution:=optional,
             ${camel.osgi.import.defaults},
             *
         </camel.osgi.import.pkg>


[2/7] camel git commit: CAMEL-9890: Migrate Camel-websocket to Jetty9 - Fixing Tests

Posted by ac...@apache.org.
CAMEL-9890: Migrate Camel-websocket to Jetty9 - Fixing Tests


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/15e1160a
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/15e1160a
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/15e1160a

Branch: refs/heads/master
Commit: 15e1160a6029b94f01ec99ab19204af2849da743
Parents: 51ca71e
Author: Andrea Cosentino <an...@gmail.com>
Authored: Wed Apr 20 13:19:45 2016 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Wed Apr 20 13:19:45 2016 +0200

----------------------------------------------------------------------
 .../component/websocket/DefaultWebsocket.java   |  40 +++-
 .../websocket/DefaultWebsocketFactory.java      |   5 +-
 .../websocket/JettyClassPathResource.java       |  22 ++-
 .../component/websocket/WebSocketFactory.java   |   5 +-
 .../component/websocket/WebsocketComponent.java |   3 +-
 .../websocket/WebsocketComponentServlet.java    |  16 +-
 .../WebscoketEndpointConfigurationTest.java     |   2 +
 .../WebsocketClientCamelRouteTest.java          |   2 +
 .../WebsocketComponentRouteExampleTest.java     |   2 +
 .../WebsocketComponentServletTest.java          |   5 +-
 .../websocket/WebsocketComponentTest.java       |  18 +-
 .../websocket/WebsocketConsumerRouteTest.java   |   2 +
 .../WebsocketProducerRouteExampleTest.java      |   3 +
 .../WebsocketProducerRouteRestartTest.java      |   3 +
 .../websocket/WebsocketProducerTest.java        | 188 ++++++++++---------
 .../websocket/WebsocketRouteExampleTest.java    |   2 +
 ...ebsocketSSLContextInUriRouteExampleTest.java |   4 +-
 .../websocket/WebsocketSSLRouteExampleTest.java |   2 +
 .../WebsocketTwoRoutesExampleTest.java          |   5 +-
 ...dividualAndBroadcastEndpointExampleTest.java |   5 +-
 ...ocketTwoRoutesToSameEndpointExampleTest.java |   5 +-
 21 files changed, 216 insertions(+), 123 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/15e1160a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/DefaultWebsocket.java
----------------------------------------------------------------------
diff --git a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/DefaultWebsocket.java b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/DefaultWebsocket.java
index 8cf91a1..aa1402a 100644
--- a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/DefaultWebsocket.java
+++ b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/DefaultWebsocket.java
@@ -17,8 +17,10 @@
 package org.apache.camel.component.websocket;
 
 import java.io.Serializable;
+import java.lang.annotation.Annotation;
 import java.util.UUID;
 
+import org.eclipse.jetty.websocket.api.BatchMode;
 import org.eclipse.jetty.websocket.api.Session;
 import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose;
 import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect;
@@ -28,7 +30,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 @WebSocket
-public class DefaultWebsocket implements Serializable {
+public class DefaultWebsocket implements Serializable, WebSocket {
     private static final long serialVersionUID = 1L;
     private static final Logger LOG = LoggerFactory.getLogger(DefaultWebsocket.class);
 
@@ -94,4 +96,40 @@ public class DefaultWebsocket implements Serializable {
     public void setConnectionKey(String connectionKey) {
         this.connectionKey = connectionKey;
     }
+
+	@Override
+	public Class<? extends Annotation> annotationType() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public int inputBufferSize() {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+	@Override
+	public int maxBinaryMessageSize() {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+	@Override
+	public int maxIdleTime() {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+	@Override
+	public int maxTextMessageSize() {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+	@Override
+	public BatchMode batchMode() {
+		// TODO Auto-generated method stub
+		return null;
+	}
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/15e1160a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/DefaultWebsocketFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/DefaultWebsocketFactory.java b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/DefaultWebsocketFactory.java
index 6fb0124..d37f288 100644
--- a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/DefaultWebsocketFactory.java
+++ b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/DefaultWebsocketFactory.java
@@ -18,7 +18,8 @@ package org.apache.camel.component.websocket;
 
 import javax.servlet.http.HttpServletRequest;
 
-import org.eclipse.jetty.websocket.WebSocket;
+import org.eclipse.jetty.websocket.api.annotations.WebSocket;
+import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest;
 
 /**
  * Default websocket factory.
@@ -27,7 +28,7 @@ import org.eclipse.jetty.websocket.WebSocket;
 public class DefaultWebsocketFactory implements WebSocketFactory {
 
     @Override
-    public WebSocket newInstance(HttpServletRequest request, String protocol, NodeSynchronization sync, WebsocketConsumer consumer) {
+    public DefaultWebsocket newInstance(ServletUpgradeRequest request, String protocol, NodeSynchronization sync, WebsocketConsumer consumer) {
         return new DefaultWebsocket(sync, consumer);
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/15e1160a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/JettyClassPathResource.java
----------------------------------------------------------------------
diff --git a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/JettyClassPathResource.java b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/JettyClassPathResource.java
index 9e4e876..69fa843 100644
--- a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/JettyClassPathResource.java
+++ b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/JettyClassPathResource.java
@@ -22,6 +22,7 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.nio.channels.ReadableByteChannel;
 
 import org.apache.camel.spi.ClassResolver;
 import org.apache.camel.util.IOHelper;
@@ -50,11 +51,6 @@ public class JettyClassPathResource extends Resource {
     }
 
     @Override
-    public void release() {
-        // noop
-    }
-
-    @Override
     public boolean exists() {
         InputStream is = resolver.loadResourceAsStream(path);
         if (is != null) {
@@ -103,11 +99,6 @@ public class JettyClassPathResource extends Resource {
     }
 
     @Override
-    public OutputStream getOutputStream() throws IOException, SecurityException {
-        return null;
-    }
-
-    @Override
     public boolean delete() throws SecurityException {
         return false;
     }
@@ -126,4 +117,15 @@ public class JettyClassPathResource extends Resource {
     public Resource addPath(String path) throws IOException, MalformedURLException {
         return new JettyClassPathResource(resolver, this.path + "/" + path);
     }
+
+	@Override
+	public void close() {
+		// noop
+		
+	}
+
+	@Override
+	public ReadableByteChannel getReadableByteChannel() throws IOException {
+		return null;
+	}
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/15e1160a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebSocketFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebSocketFactory.java b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebSocketFactory.java
index 6f06038..3e5e641 100644
--- a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebSocketFactory.java
+++ b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebSocketFactory.java
@@ -18,13 +18,14 @@ package org.apache.camel.component.websocket;
 
 import javax.servlet.http.HttpServletRequest;
 
-import org.eclipse.jetty.websocket.WebSocket;
+import org.eclipse.jetty.websocket.api.annotations.WebSocket;
+import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest;
 
 /**
  * Web socket factory interface.
  */
 public interface WebSocketFactory {
 
-    WebSocket newInstance(HttpServletRequest request, String protocol, NodeSynchronization sync, WebsocketConsumer consumer);
+    DefaultWebsocket newInstance(ServletUpgradeRequest request, String protocol, NodeSynchronization sync, WebsocketConsumer consumer);
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/15e1160a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponent.java b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponent.java
index 71c4191..d9ab59b 100644
--- a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponent.java
+++ b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponent.java
@@ -340,7 +340,6 @@ public class WebsocketComponent extends UriEndpointComponent {
 
     protected Server createServer() throws Exception {
         Server server = null;
-
         // configure thread pool if min/max given
         if (minThreads != null || maxThreads != null) {
             if (getThreadPool() != null) {
@@ -354,7 +353,7 @@ public class WebsocketComponent extends UriEndpointComponent {
                 qtp.setMaxThreads(maxThreads.intValue());
             }
             // let the thread names indicate they are from the server
-            qtp.setName("CamelJettyWebSocketServer(" + ObjectHelper.getIdentityHashCode(server) + ")");
+            qtp.setName("CamelJettyWebSocketServer(" + "test" + ")");
             try {
                 qtp.start();
             } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/camel/blob/15e1160a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponentServlet.java
----------------------------------------------------------------------
diff --git a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponentServlet.java b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponentServlet.java
index 91173b5..c675722 100644
--- a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponentServlet.java
+++ b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponentServlet.java
@@ -22,6 +22,9 @@ import java.util.concurrent.ConcurrentMap;
 import javax.servlet.http.HttpServletRequest;
 
 import org.eclipse.jetty.websocket.api.annotations.WebSocket;
+import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest;
+import org.eclipse.jetty.websocket.servlet.ServletUpgradeResponse;
+import org.eclipse.jetty.websocket.servlet.WebSocketCreator;
 import org.eclipse.jetty.websocket.servlet.WebSocketServlet;
 import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory;
 import org.slf4j.Logger;
@@ -60,7 +63,7 @@ public class WebsocketComponentServlet extends WebSocketServlet {
         consumers.remove(consumer.getPath());
     }
 
-    public WebSocket doWebSocketConnect(HttpServletRequest request, String protocol) {
+    public WebSocket doWebSocketConnect(ServletUpgradeRequest request, String protocol) {
         String protocolKey = protocol;
 
         if (protocol == null || !socketFactory.containsKey(protocol)) {
@@ -82,7 +85,14 @@ public class WebsocketComponentServlet extends WebSocketServlet {
 
 	@Override
 	public void configure(WebSocketServletFactory factory) {
-		// TODO Auto-generated method stub
-		
+		 factory.setCreator(new WebSocketCreator() {
+			    @Override
+			    public Object createWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp) {
+	             String protocolKey = "default";
+	
+	              WebSocketFactory factory = socketFactory.get(protocolKey);
+			      return factory.newInstance(req, protocolKey, sync, consumer);
+			    }
+	});
 	}
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/15e1160a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebscoketEndpointConfigurationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebscoketEndpointConfigurationTest.java b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebscoketEndpointConfigurationTest.java
index 91c1263..029529d 100644
--- a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebscoketEndpointConfigurationTest.java
+++ b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebscoketEndpointConfigurationTest.java
@@ -43,6 +43,8 @@ public class WebscoketEndpointConfigurationTest extends CamelTestSupport {
         String uri = "websocket://localhost:" + port + "/bar?bufferSize=65000&maxIdleTime=3000";
         WebsocketEndpoint websocketEndpoint = (WebsocketEndpoint)context.getEndpoint(uri);
         WebsocketComponent component = websocketEndpoint.getComponent();
+        component.setMinThreads(1);
+        component.setMaxThreads(11);
         Consumer consumer = websocketEndpoint.createConsumer(processor);
         component.connect((WebsocketProducerConsumer) consumer);
         

http://git-wip-us.apache.org/repos/asf/camel/blob/15e1160a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketClientCamelRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketClientCamelRouteTest.java b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketClientCamelRouteTest.java
index ca44a40..f226a27 100644
--- a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketClientCamelRouteTest.java
+++ b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketClientCamelRouteTest.java
@@ -96,6 +96,8 @@ public class WebsocketClientCamelRouteTest extends CamelTestSupport {
             public void configure() {
                 WebsocketComponent websocketComponent = getContext().getComponent("websocket", WebsocketComponent.class);
                 websocketComponent.setPort(port);
+                websocketComponent.setMinThreads(1);
+                websocketComponent.setMaxThreads(11);
 
                 from("websocket://test")
                         .log(">>> Message received from WebSocket Client : ${body}")

http://git-wip-us.apache.org/repos/asf/camel/blob/15e1160a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentRouteExampleTest.java
----------------------------------------------------------------------
diff --git a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentRouteExampleTest.java b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentRouteExampleTest.java
index 254e016..76b14a0 100644
--- a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentRouteExampleTest.java
+++ b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentRouteExampleTest.java
@@ -92,6 +92,8 @@ public class WebsocketComponentRouteExampleTest extends CamelTestSupport {
                 WebsocketComponent websocketComponent = getContext().getComponent("websocket", WebsocketComponent.class);
                 websocketComponent.setHost("localhost");
                 websocketComponent.setPort(port);
+                websocketComponent.setMaxThreads(11);
+                websocketComponent.setMinThreads(1);
 
                 from("websocket://echo")
                     .log(">>> Message received from WebSocket Client : ${body}")

http://git-wip-us.apache.org/repos/asf/camel/blob/15e1160a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentServletTest.java
----------------------------------------------------------------------
diff --git a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentServletTest.java b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentServletTest.java
index 2b24fa5..063d7ca 100644
--- a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentServletTest.java
+++ b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentServletTest.java
@@ -21,7 +21,8 @@ import java.util.Map;
 
 import javax.servlet.http.HttpServletRequest;
 
-import org.eclipse.jetty.websocket.WebSocket;
+import org.eclipse.jetty.websocket.api.annotations.WebSocket;
+import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -50,7 +51,7 @@ public class WebsocketComponentServletTest {
     @Mock
     private NodeSynchronization sync;
     @Mock
-    private HttpServletRequest request;
+    private ServletUpgradeRequest request;
 
     private WebsocketComponentServlet websocketComponentServlet;
 

http://git-wip-us.apache.org/repos/asf/camel/blob/15e1160a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentTest.java b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentTest.java
index 621eb9f..9966ab6 100644
--- a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentTest.java
+++ b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentTest.java
@@ -22,7 +22,7 @@ import org.apache.camel.Endpoint;
 import org.apache.camel.impl.DefaultCamelContext;
 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.servlet.ServletContextHandler;
 import org.eclipse.jetty.servlet.ServletHolder;
 import org.junit.Before;
@@ -73,12 +73,12 @@ public class WebsocketComponentTest {
     public void setUp() throws Exception {
         component = new WebsocketComponent();
         component.setCamelContext(new DefaultCamelContext());
-
-        Connector connector = new SelectChannelConnector();
+        System.out.println("Server : " + server.isStarted());
+        server = component.createServer();
+        System.out.println("Server : " + server.isStarted());
+        ServerConnector connector = new ServerConnector(server);
         connector.setHost("localhost");
         connector.setPort(1988);
-
-        server = component.createServer();
         server.addConnector(connector);
 
         WebsocketEndpoint endpoint = (WebsocketEndpoint) component.createEndpoint("websocket://x");
@@ -99,8 +99,8 @@ public class WebsocketComponentTest {
     public void testCreateServerWithoutStaticContent() throws Exception {
         ServletContextHandler handler = component.createContext(server, server.getConnectors()[0], null);
         assertEquals(1, server.getConnectors().length);
-        assertEquals("localhost", server.getConnectors()[0].getHost());
-        assertEquals(1988, server.getConnectors()[0].getPort());
+        assertEquals("localhost", ((ServerConnector) server.getConnectors()[0]).getHost());
+        assertEquals(1988,((ServerConnector) server.getConnectors()[0]).getPort());
         assertFalse(server.getConnectors()[0].isStarted());
         assertEquals(handler, server.getHandler());
         assertEquals(1, server.getHandlers().length);
@@ -116,8 +116,8 @@ public class WebsocketComponentTest {
         ServletContextHandler handler = component.createContext(server, server.getConnectors()[0], null);
         Server server = component.createStaticResourcesServer(handler, "localhost", 1988, "classpath:public");
         assertEquals(1, server.getConnectors().length);
-        assertEquals("localhost", server.getConnectors()[0].getHost());
-        assertEquals(1988, server.getConnectors()[0].getPort());
+        assertEquals("localhost", ((ServerConnector) server.getConnectors()[0]).getHost());
+        assertEquals(1988,((ServerConnector) server.getConnectors()[0]).getPort());
         assertFalse(server.getConnectors()[0].isStarted());
         assertEquals(handler, server.getHandler());
         assertEquals(1, server.getHandlers().length);

http://git-wip-us.apache.org/repos/asf/camel/blob/15e1160a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketConsumerRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketConsumerRouteTest.java b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketConsumerRouteTest.java
index 3f76c00..ea1874a 100644
--- a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketConsumerRouteTest.java
+++ b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketConsumerRouteTest.java
@@ -109,6 +109,8 @@ public class WebsocketConsumerRouteTest extends CamelTestSupport {
             public void configure() {
                 WebsocketComponent websocketComponent = (WebsocketComponent) context.getComponent("websocket");
                 websocketComponent.setPort(port);
+                websocketComponent.setMaxThreads(11);
+                websocketComponent.setMinThreads(1);
 
                 from("websocket://echo")
                     .log(">>> Message received from WebSocket Client : ${body}")

http://git-wip-us.apache.org/repos/asf/camel/blob/15e1160a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketProducerRouteExampleTest.java
----------------------------------------------------------------------
diff --git a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketProducerRouteExampleTest.java b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketProducerRouteExampleTest.java
index 50429d9..aea401a 100644
--- a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketProducerRouteExampleTest.java
+++ b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketProducerRouteExampleTest.java
@@ -145,6 +145,9 @@ public class WebsocketProducerRouteExampleTest extends CamelTestSupport {
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() {
+                WebsocketComponent websocketComponent = (WebsocketComponent) context.getComponent("websocket");
+                websocketComponent.setMaxThreads(11);
+                websocketComponent.setMinThreads(1);
                 from("direct:shop")
                     .log(">>> Message received from Shopping center : ${body}")
                     .to("websocket://localhost:" + port + "/shop");

http://git-wip-us.apache.org/repos/asf/camel/blob/15e1160a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketProducerRouteRestartTest.java
----------------------------------------------------------------------
diff --git a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketProducerRouteRestartTest.java b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketProducerRouteRestartTest.java
index b1b2ce2..3f9c4d2 100644
--- a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketProducerRouteRestartTest.java
+++ b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketProducerRouteRestartTest.java
@@ -120,6 +120,9 @@ public class WebsocketProducerRouteRestartTest extends CamelTestSupport {
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() {
+                WebsocketComponent websocketComponent = (WebsocketComponent) context.getComponent("websocket");
+                websocketComponent.setMaxThreads(11);
+                websocketComponent.setMinThreads(1);
                 from("direct:shop")
                     .id(ROUTE_ID)
                     .log(">>> Message received from Shopping center : ${body}")

http://git-wip-us.apache.org/repos/asf/camel/blob/15e1160a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketProducerTest.java b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketProducerTest.java
index a05f6d8..f518eaa 100644
--- a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketProducerTest.java
+++ b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketProducerTest.java
@@ -22,7 +22,8 @@ import java.util.Collection;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
-import org.eclipse.jetty.websocket.WebSocket.Connection;
+import org.eclipse.jetty.websocket.api.RemoteEndpoint;
+import org.eclipse.jetty.websocket.api.Session;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -55,7 +56,7 @@ public class WebsocketProducerTest {
     @Mock
     private WebsocketStore store;
     @Mock
-    private Connection connection;
+    private Session session;
     @Mock
     private DefaultWebsocket defaultWebsocket1;
     @Mock
@@ -64,6 +65,8 @@ public class WebsocketProducerTest {
     private Exchange exchange;
     @Mock
     private Message inMessage;
+    @Mock
+    private RemoteEndpoint remoteEndpoint;
 
     private IOException exception = new IOException("BAD NEWS EVERYONE!");
     private WebsocketProducer websocketProducer;
@@ -83,21 +86,22 @@ public class WebsocketProducerTest {
         when(inMessage.getHeader(WebsocketConstants.SEND_TO_ALL, false, Boolean.class)).thenReturn(false);
         when(inMessage.getHeader(WebsocketConstants.CONNECTION_KEY, String.class)).thenReturn(SESSION_KEY);
         when(store.get(SESSION_KEY)).thenReturn(defaultWebsocket1);
-        when(defaultWebsocket1.getConnection()).thenReturn(connection);
-        when(connection.isOpen()).thenReturn(true);
+        when(defaultWebsocket1.getSession()).thenReturn(session);
+        when(session.isOpen()).thenReturn(true);
+        when(session.getRemote()).thenReturn(remoteEndpoint);
 
         websocketProducer.process(exchange);
 
-        InOrder inOrder = inOrder(endpoint, store, connection, defaultWebsocket1, defaultWebsocket2, exchange, inMessage);
+        InOrder inOrder = inOrder(endpoint, store, session, defaultWebsocket1, defaultWebsocket2, exchange, inMessage, remoteEndpoint);
         inOrder.verify(exchange, times(1)).getIn();
         inOrder.verify(inMessage, times(1)).getMandatoryBody();
         inOrder.verify(inMessage, times(1)).getHeader(WebsocketConstants.SEND_TO_ALL, false, Boolean.class);
         inOrder.verify(inMessage, times(1)).getHeader(WebsocketConstants.CONNECTION_KEY, String.class);
         inOrder.verify(store, times(1)).get(SESSION_KEY);
-        inOrder.verify(defaultWebsocket1, times(1)).getConnection();
-        inOrder.verify(connection, times(1)).isOpen();
-        inOrder.verify(defaultWebsocket1, times(1)).getConnection();
-        inOrder.verify(connection, times(1)).sendMessage(MESSAGE);
+        inOrder.verify(defaultWebsocket1, times(1)).getSession();
+        inOrder.verify(session, times(1)).isOpen();
+        inOrder.verify(defaultWebsocket1, times(1)).getSession();
+        inOrder.verify(remoteEndpoint, times(1)).sendString(MESSAGE);
         inOrder.verifyNoMoreInteractions();
     }
 
@@ -108,9 +112,10 @@ public class WebsocketProducerTest {
         when(inMessage.getHeader(WebsocketConstants.SEND_TO_ALL, false, Boolean.class)).thenReturn(false);
         when(inMessage.getHeader(WebsocketConstants.CONNECTION_KEY, String.class)).thenReturn(SESSION_KEY);
         when(store.get(SESSION_KEY)).thenReturn(defaultWebsocket1);
-        when(defaultWebsocket1.getConnection()).thenReturn(connection);
-        when(connection.isOpen()).thenReturn(true);
-        doThrow(exception).when(connection).sendMessage(MESSAGE);
+        when(defaultWebsocket1.getSession()).thenReturn(session);
+        when(session.isOpen()).thenReturn(true);
+        when(session.getRemote()).thenReturn(remoteEndpoint);
+        doThrow(exception).when(remoteEndpoint).sendString(MESSAGE);
 
         try {
             websocketProducer.process(exchange);
@@ -119,16 +124,16 @@ public class WebsocketProducerTest {
             assertEquals(exception, ioe);
         }
 
-        InOrder inOrder = inOrder(endpoint, store, connection, defaultWebsocket1, defaultWebsocket2, exchange, inMessage);
+        InOrder inOrder = inOrder(endpoint, store, session, defaultWebsocket1, defaultWebsocket2, exchange, inMessage, remoteEndpoint);
         inOrder.verify(exchange, times(1)).getIn();
         inOrder.verify(inMessage, times(1)).getMandatoryBody();
         inOrder.verify(inMessage, times(1)).getHeader(WebsocketConstants.SEND_TO_ALL, false, Boolean.class);
         inOrder.verify(inMessage, times(1)).getHeader(WebsocketConstants.CONNECTION_KEY, String.class);
         inOrder.verify(store, times(1)).get(SESSION_KEY);
-        inOrder.verify(defaultWebsocket1, times(1)).getConnection();
-        inOrder.verify(connection, times(1)).isOpen();
-        inOrder.verify(defaultWebsocket1, times(1)).getConnection();
-        inOrder.verify(connection, times(1)).sendMessage(MESSAGE);
+        inOrder.verify(defaultWebsocket1, times(1)).getSession();
+        inOrder.verify(session, times(1)).isOpen();
+        inOrder.verify(defaultWebsocket1, times(1)).getSession();
+        inOrder.verify(remoteEndpoint, times(1)).sendString(MESSAGE);
         inOrder.verifyNoMoreInteractions();
     }
 
@@ -138,25 +143,26 @@ public class WebsocketProducerTest {
         when(inMessage.getMandatoryBody()).thenReturn(MESSAGE);
         when(inMessage.getHeader(WebsocketConstants.SEND_TO_ALL, false, Boolean.class)).thenReturn(true);
         when(store.getAll()).thenReturn(sockets);
-        when(defaultWebsocket1.getConnection()).thenReturn(connection);
-        when(defaultWebsocket2.getConnection()).thenReturn(connection);
-        when(connection.isOpen()).thenReturn(true);
+        when(defaultWebsocket1.getSession()).thenReturn(session);
+        when(defaultWebsocket2.getSession()).thenReturn(session);
+        when(session.isOpen()).thenReturn(true);
+        when(session.getRemote()).thenReturn(remoteEndpoint);
 
         websocketProducer.process(exchange);
 
-        InOrder inOrder = inOrder(endpoint, store, connection, defaultWebsocket1, defaultWebsocket2, exchange, inMessage);
+        InOrder inOrder = inOrder(endpoint, store, session, defaultWebsocket1, defaultWebsocket2, exchange, inMessage, remoteEndpoint);
         inOrder.verify(exchange, times(1)).getIn();
         inOrder.verify(inMessage, times(1)).getMandatoryBody();
         inOrder.verify(inMessage, times(1)).getHeader(WebsocketConstants.SEND_TO_ALL, false, Boolean.class);
         inOrder.verify(store, times(1)).getAll();
-        inOrder.verify(defaultWebsocket1, times(1)).getConnection();
-        inOrder.verify(connection, times(1)).isOpen();
-        inOrder.verify(defaultWebsocket1, times(1)).getConnection();
-        inOrder.verify(connection, times(1)).sendMessage(MESSAGE);
-        inOrder.verify(defaultWebsocket2, times(1)).getConnection();
-        inOrder.verify(connection, times(1)).isOpen();
-        inOrder.verify(defaultWebsocket2, times(1)).getConnection();
-        inOrder.verify(connection, times(1)).sendMessage(MESSAGE);
+        inOrder.verify(defaultWebsocket1, times(1)).getSession();
+        inOrder.verify(session, times(1)).isOpen();
+        inOrder.verify(defaultWebsocket1, times(1)).getSession();
+        inOrder.verify(remoteEndpoint, times(1)).sendString(MESSAGE);
+        inOrder.verify(defaultWebsocket2, times(1)).getSession();
+        inOrder.verify(session, times(1)).isOpen();
+        inOrder.verify(defaultWebsocket2, times(1)).getSession();
+        inOrder.verify(remoteEndpoint, times(1)).sendString(MESSAGE);
         inOrder.verifyNoMoreInteractions();
     }
 
@@ -166,10 +172,11 @@ public class WebsocketProducerTest {
         when(inMessage.getMandatoryBody()).thenReturn(MESSAGE);
         when(inMessage.getHeader(WebsocketConstants.SEND_TO_ALL, false, Boolean.class)).thenReturn(true);
         when(store.getAll()).thenReturn(sockets);
-        when(defaultWebsocket1.getConnection()).thenReturn(connection);
-        when(defaultWebsocket2.getConnection()).thenReturn(connection);
-        doThrow(exception).when(connection).sendMessage(MESSAGE);
-        when(connection.isOpen()).thenReturn(true);
+        when(defaultWebsocket1.getSession()).thenReturn(session);
+        when(defaultWebsocket2.getSession()).thenReturn(session);
+        when(session.getRemote()).thenReturn(remoteEndpoint);
+        doThrow(exception).when(remoteEndpoint).sendString(MESSAGE);
+        when(session.isOpen()).thenReturn(true);
 
         try {
             websocketProducer.process(exchange);
@@ -178,19 +185,19 @@ public class WebsocketProducerTest {
             assertEquals(exception, e.getCause());
         }
 
-        InOrder inOrder = inOrder(endpoint, store, connection, defaultWebsocket1, defaultWebsocket2, exchange, inMessage);
+        InOrder inOrder = inOrder(endpoint, store, session, defaultWebsocket1, defaultWebsocket2, exchange, inMessage, remoteEndpoint);
         inOrder.verify(exchange, times(1)).getIn();
         inOrder.verify(inMessage, times(1)).getMandatoryBody();
         inOrder.verify(inMessage, times(1)).getHeader(WebsocketConstants.SEND_TO_ALL, false, Boolean.class);
         inOrder.verify(store, times(1)).getAll();
-        inOrder.verify(defaultWebsocket1, times(1)).getConnection();
-        inOrder.verify(connection, times(1)).isOpen();
-        inOrder.verify(defaultWebsocket1, times(1)).getConnection();
-        inOrder.verify(connection, times(1)).sendMessage(MESSAGE);
-        inOrder.verify(defaultWebsocket2, times(1)).getConnection();
-        inOrder.verify(connection, times(1)).isOpen();
-        inOrder.verify(defaultWebsocket2, times(1)).getConnection();
-        inOrder.verify(connection, times(1)).sendMessage(MESSAGE);
+        inOrder.verify(defaultWebsocket1, times(1)).getSession();
+        inOrder.verify(session, times(1)).isOpen();
+        inOrder.verify(defaultWebsocket1, times(1)).getSession();
+        inOrder.verify(remoteEndpoint, times(1)).sendString(MESSAGE);
+        inOrder.verify(defaultWebsocket2, times(1)).getSession();
+        inOrder.verify(session, times(1)).isOpen();
+        inOrder.verify(defaultWebsocket2, times(1)).getSession();
+        inOrder.verify(remoteEndpoint, times(1)).sendString(MESSAGE);
         inOrder.verifyNoMoreInteractions();
     }
 
@@ -210,7 +217,7 @@ public class WebsocketProducerTest {
             assertNull(e.getCause());
         }
 
-        InOrder inOrder = inOrder(endpoint, store, connection, defaultWebsocket1, defaultWebsocket2, exchange, inMessage);
+        InOrder inOrder = inOrder(endpoint, store, session, defaultWebsocket1, defaultWebsocket2, exchange, inMessage);
         inOrder.verify(exchange, times(1)).getIn();
         inOrder.verify(inMessage, times(1)).getMandatoryBody();
         inOrder.verify(inMessage, times(1)).getHeader(WebsocketConstants.SEND_TO_ALL, false, Boolean.class);
@@ -220,37 +227,40 @@ public class WebsocketProducerTest {
 
     @Test
     public void testSendMessage() throws Exception {
-        when(defaultWebsocket1.getConnection()).thenReturn(connection);
-        when(connection.isOpen()).thenReturn(true);
+        when(defaultWebsocket1.getSession()).thenReturn(session);
+        when(session.isOpen()).thenReturn(true);
+        when(session.getRemote()).thenReturn(remoteEndpoint);
 
         websocketProducer.sendMessage(defaultWebsocket1, MESSAGE);
 
-        InOrder inOrder = inOrder(endpoint, store, connection, defaultWebsocket1, defaultWebsocket2, exchange, inMessage);
-        inOrder.verify(defaultWebsocket1, times(1)).getConnection();
-        inOrder.verify(connection, times(1)).isOpen();
-        inOrder.verify(defaultWebsocket1, times(1)).getConnection();
-        inOrder.verify(connection, times(1)).sendMessage(MESSAGE);
+        InOrder inOrder = inOrder(endpoint, store, session, defaultWebsocket1, defaultWebsocket2, exchange, inMessage,remoteEndpoint);
+        inOrder.verify(defaultWebsocket1, times(1)).getSession();
+        inOrder.verify(session, times(1)).isOpen();
+        inOrder.verify(defaultWebsocket1, times(1)).getSession();
+        inOrder.verify(remoteEndpoint, times(1)).sendString(MESSAGE);
         inOrder.verifyNoMoreInteractions();
     }
 
     @Test
     public void testSendMessageConnetionIsClosed() throws Exception {
-        when(defaultWebsocket1.getConnection()).thenReturn(connection);
-        when(connection.isOpen()).thenReturn(false);
+        when(defaultWebsocket1.getSession()).thenReturn(session);
+        when(session.isOpen()).thenReturn(false);
+        when(session.getRemote()).thenReturn(remoteEndpoint);
 
         websocketProducer.sendMessage(defaultWebsocket1, MESSAGE);
 
-        InOrder inOrder = inOrder(endpoint, store, connection, defaultWebsocket1, defaultWebsocket2, exchange, inMessage);
-        inOrder.verify(defaultWebsocket1, times(1)).getConnection();
-        inOrder.verify(connection, times(1)).isOpen();
+        InOrder inOrder = inOrder(endpoint, store, session, defaultWebsocket1, defaultWebsocket2, exchange, inMessage, remoteEndpoint);
+        inOrder.verify(defaultWebsocket1, times(1)).getSession();
+        inOrder.verify(session, times(1)).isOpen();
         inOrder.verifyNoMoreInteractions();
     }
 
     @Test
     public void testSendMessageWithException() throws Exception {
-        when(defaultWebsocket1.getConnection()).thenReturn(connection);
-        when(connection.isOpen()).thenReturn(true);
-        doThrow(exception).when(connection).sendMessage(MESSAGE);
+        when(defaultWebsocket1.getSession()).thenReturn(session);
+        when(session.isOpen()).thenReturn(true);
+        when(session.getRemote()).thenReturn(remoteEndpoint);
+        doThrow(exception).when(remoteEndpoint).sendString(MESSAGE);
 
         try {
             websocketProducer.sendMessage(defaultWebsocket1, MESSAGE);
@@ -259,11 +269,11 @@ public class WebsocketProducerTest {
             assertEquals(exception, ioe);
         }
 
-        InOrder inOrder = inOrder(endpoint, store, connection, defaultWebsocket1, defaultWebsocket2, exchange, inMessage);
-        inOrder.verify(defaultWebsocket1, times(1)).getConnection();
-        inOrder.verify(connection, times(1)).isOpen();
-        inOrder.verify(defaultWebsocket1, times(1)).getConnection();
-        inOrder.verify(connection, times(1)).sendMessage(MESSAGE);
+        InOrder inOrder = inOrder(endpoint, store, session, defaultWebsocket1, defaultWebsocket2, exchange, inMessage, remoteEndpoint);
+        inOrder.verify(defaultWebsocket1, times(1)).getSession();
+        inOrder.verify(session, times(1)).isOpen();
+        inOrder.verify(defaultWebsocket1, times(1)).getSession();
+        inOrder.verify(remoteEndpoint, times(1)).sendString(MESSAGE);
         inOrder.verifyNoMoreInteractions();
     }
 
@@ -289,32 +299,34 @@ public class WebsocketProducerTest {
     @Test
     public void testSendToAll() throws Exception {
         when(store.getAll()).thenReturn(sockets);
-        when(defaultWebsocket1.getConnection()).thenReturn(connection);
-        when(defaultWebsocket2.getConnection()).thenReturn(connection);
-        when(connection.isOpen()).thenReturn(true);
+        when(defaultWebsocket1.getSession()).thenReturn(session);
+        when(defaultWebsocket2.getSession()).thenReturn(session);
+        when(session.getRemote()).thenReturn(remoteEndpoint);
+        when(session.isOpen()).thenReturn(true);
 
         websocketProducer.sendToAll(store, MESSAGE, exchange);
 
-        InOrder inOrder = inOrder(store, connection, defaultWebsocket1, defaultWebsocket2);
+        InOrder inOrder = inOrder(store, session, defaultWebsocket1, defaultWebsocket2, remoteEndpoint);
         inOrder.verify(store, times(1)).getAll();
-        inOrder.verify(defaultWebsocket1, times(1)).getConnection();
-        inOrder.verify(connection, times(1)).isOpen();
-        inOrder.verify(defaultWebsocket1, times(1)).getConnection();
-        inOrder.verify(connection, times(1)).sendMessage(MESSAGE);
-        inOrder.verify(defaultWebsocket2, times(1)).getConnection();
-        inOrder.verify(connection, times(1)).isOpen();
-        inOrder.verify(defaultWebsocket2, times(1)).getConnection();
-        inOrder.verify(connection, times(1)).sendMessage(MESSAGE);
+        inOrder.verify(defaultWebsocket1, times(1)).getSession();
+        inOrder.verify(session, times(1)).isOpen();
+        inOrder.verify(defaultWebsocket1, times(1)).getSession();
+        inOrder.verify(remoteEndpoint, times(1)).sendString(MESSAGE);
+        inOrder.verify(defaultWebsocket2, times(1)).getSession();
+        inOrder.verify(session, times(1)).isOpen();
+        inOrder.verify(defaultWebsocket2, times(1)).getSession();
+        inOrder.verify(remoteEndpoint, times(1)).sendString(MESSAGE);
         inOrder.verifyNoMoreInteractions();
     }
 
     @Test
     public void testSendToAllWithExcpetion() throws Exception {
         when(store.getAll()).thenReturn(sockets);
-        when(defaultWebsocket1.getConnection()).thenReturn(connection);
-        when(defaultWebsocket2.getConnection()).thenReturn(connection);
-        doThrow(exception).when(connection).sendMessage(MESSAGE);
-        when(connection.isOpen()).thenReturn(true);
+        when(defaultWebsocket1.getSession()).thenReturn(session);
+        when(defaultWebsocket2.getSession()).thenReturn(session);
+        when(session.getRemote()).thenReturn(remoteEndpoint);
+        doThrow(exception).when(remoteEndpoint).sendString(MESSAGE);
+        when(session.isOpen()).thenReturn(true);
 
         try {
             websocketProducer.sendToAll(store, MESSAGE, exchange);
@@ -323,16 +335,16 @@ public class WebsocketProducerTest {
             assertEquals(exception, e.getCause());
         }
 
-        InOrder inOrder = inOrder(store, connection, defaultWebsocket1, defaultWebsocket2);
+        InOrder inOrder = inOrder(store, session, defaultWebsocket1, defaultWebsocket2, remoteEndpoint);
         inOrder.verify(store, times(1)).getAll();
-        inOrder.verify(defaultWebsocket1, times(1)).getConnection();
-        inOrder.verify(connection, times(1)).isOpen();
-        inOrder.verify(defaultWebsocket1, times(1)).getConnection();
-        inOrder.verify(connection, times(1)).sendMessage(MESSAGE);
-        inOrder.verify(defaultWebsocket2, times(1)).getConnection();
-        inOrder.verify(connection, times(1)).isOpen();
-        inOrder.verify(defaultWebsocket2, times(1)).getConnection();
-        inOrder.verify(connection, times(1)).sendMessage(MESSAGE);
+        inOrder.verify(defaultWebsocket1, times(1)).getSession();
+        inOrder.verify(session, times(1)).isOpen();
+        inOrder.verify(defaultWebsocket1, times(1)).getSession();
+        inOrder.verify(remoteEndpoint, times(1)).sendString(MESSAGE);
+        inOrder.verify(defaultWebsocket2, times(1)).getSession();
+        inOrder.verify(session, times(1)).isOpen();
+        inOrder.verify(defaultWebsocket2, times(1)).getSession();
+        inOrder.verify(remoteEndpoint, times(1)).sendString(MESSAGE);
         inOrder.verifyNoMoreInteractions();
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/15e1160a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketRouteExampleTest.java
----------------------------------------------------------------------
diff --git a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketRouteExampleTest.java b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketRouteExampleTest.java
index 52989c2..3606a27 100644
--- a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketRouteExampleTest.java
+++ b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketRouteExampleTest.java
@@ -88,6 +88,8 @@ public class WebsocketRouteExampleTest extends CamelTestSupport {
             public void configure() {
                 WebsocketComponent websocketComponent = (WebsocketComponent) context.getComponent("websocket");
                 websocketComponent.setPort(port);
+                websocketComponent.setMinThreads(1);
+                websocketComponent.setMaxThreads(11);
 
                 // START SNIPPET: e1
                 // expose a echo websocket client, that sends back an echo

http://git-wip-us.apache.org/repos/asf/camel/blob/15e1160a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketSSLContextInUriRouteExampleTest.java
----------------------------------------------------------------------
diff --git a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketSSLContextInUriRouteExampleTest.java b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketSSLContextInUriRouteExampleTest.java
index a12fadc..5f6e8d5 100644
--- a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketSSLContextInUriRouteExampleTest.java
+++ b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketSSLContextInUriRouteExampleTest.java
@@ -164,7 +164,9 @@ public class WebsocketSSLContextInUriRouteExampleTest extends CamelTestSupport {
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() {
-
+                WebsocketComponent websocketComponent = (WebsocketComponent) context.getComponent("websocket");
+                websocketComponent.setMinThreads(1);
+                websocketComponent.setMaxThreads(11);
                 from(uri)
                      .log(">>> Message received from WebSocket Client : ${body}")
                      .to("mock:client")

http://git-wip-us.apache.org/repos/asf/camel/blob/15e1160a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketSSLRouteExampleTest.java
----------------------------------------------------------------------
diff --git a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketSSLRouteExampleTest.java b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketSSLRouteExampleTest.java
index 13c42b4..251cccc 100644
--- a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketSSLRouteExampleTest.java
+++ b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketSSLRouteExampleTest.java
@@ -161,6 +161,8 @@ public class WebsocketSSLRouteExampleTest extends CamelTestSupport {
                 WebsocketComponent websocketComponent = (WebsocketComponent) context.getComponent("websocket");
                 websocketComponent.setSslContextParameters(defineSSLContextParameters());
                 websocketComponent.setPort(port);
+                websocketComponent.setMinThreads(1);
+                websocketComponent.setMaxThreads(11);
 
                 from("websocket://test")
                         .log(">>> Message received from WebSocket Client : ${body}")

http://git-wip-us.apache.org/repos/asf/camel/blob/15e1160a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketTwoRoutesExampleTest.java
----------------------------------------------------------------------
diff --git a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketTwoRoutesExampleTest.java b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketTwoRoutesExampleTest.java
index 0c18045..eb8d8f7 100644
--- a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketTwoRoutesExampleTest.java
+++ b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketTwoRoutesExampleTest.java
@@ -129,7 +129,10 @@ public class WebsocketTwoRoutesExampleTest extends CamelTestSupport {
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() {
-
+                WebsocketComponent websocketComponent = (WebsocketComponent) context.getComponent("websocket");
+                websocketComponent.setMinThreads(1);
+                websocketComponent.setMaxThreads(11);
+                
                 from("websocket://localhost:" + port + "/bar")
                     .log(">>> Message received from BAR WebSocket Client : ${body}")
                     .transform().simple("The bar has ${body}")

http://git-wip-us.apache.org/repos/asf/camel/blob/15e1160a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketTwoRoutesToSIndividualAndBroadcastEndpointExampleTest.java
----------------------------------------------------------------------
diff --git a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketTwoRoutesToSIndividualAndBroadcastEndpointExampleTest.java b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketTwoRoutesToSIndividualAndBroadcastEndpointExampleTest.java
index 20b5b36..d4aa92f 100644
--- a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketTwoRoutesToSIndividualAndBroadcastEndpointExampleTest.java
+++ b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketTwoRoutesToSIndividualAndBroadcastEndpointExampleTest.java
@@ -92,7 +92,10 @@ public class WebsocketTwoRoutesToSIndividualAndBroadcastEndpointExampleTest exte
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() {
-
+                WebsocketComponent websocketComponent = (WebsocketComponent) context.getComponent("websocket");
+                websocketComponent.setMinThreads(1);
+                websocketComponent.setMaxThreads(11);
+                
                 from("websocket://localhost:" + port + "/bar")
                         .log(">>> Message received from BAR WebSocket Client : ${body}")
                         .transform().simple("The bar has ${body}")

http://git-wip-us.apache.org/repos/asf/camel/blob/15e1160a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketTwoRoutesToSameEndpointExampleTest.java
----------------------------------------------------------------------
diff --git a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketTwoRoutesToSameEndpointExampleTest.java b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketTwoRoutesToSameEndpointExampleTest.java
index fd639a4..7c0b145 100644
--- a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketTwoRoutesToSameEndpointExampleTest.java
+++ b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketTwoRoutesToSameEndpointExampleTest.java
@@ -92,7 +92,10 @@ public class WebsocketTwoRoutesToSameEndpointExampleTest extends CamelTestSuppor
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() {
-
+                WebsocketComponent websocketComponent = (WebsocketComponent) context.getComponent("websocket");
+                websocketComponent.setMinThreads(1);
+                websocketComponent.setMaxThreads(11);
+                
                 from("websocket://localhost:" + port + "/bar")
                         .log(">>> Message received from BAR WebSocket Client : ${body}")
                         .transform().simple("The bar has ${body}")


[3/7] camel git commit: CAMEL-9890: Migrate Camel-websocket to Jetty9 - Switch to Jetty9 in Karaf feature

Posted by ac...@apache.org.
CAMEL-9890: Migrate Camel-websocket to Jetty9 - Switch to Jetty9 in Karaf feature


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/08ffb550
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/08ffb550
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/08ffb550

Branch: refs/heads/master
Commit: 08ffb550751f7224a7bfa0758a3c9a24a343c20d
Parents: 15e1160
Author: Andrea Cosentino <an...@gmail.com>
Authored: Wed Apr 20 13:20:14 2016 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Wed Apr 20 13:20:14 2016 +0200

----------------------------------------------------------------------
 platforms/karaf/features/src/main/resources/features.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/08ffb550/platforms/karaf/features/src/main/resources/features.xml
----------------------------------------------------------------------
diff --git a/platforms/karaf/features/src/main/resources/features.xml b/platforms/karaf/features/src/main/resources/features.xml
index 974725c..a20e8a6 100644
--- a/platforms/karaf/features/src/main/resources/features.xml
+++ b/platforms/karaf/features/src/main/resources/features.xml
@@ -1771,7 +1771,7 @@
   </feature>
   <feature name='camel-websocket' version='${project.version}' resolver='(obr)' start-level='50'>
     <details>camel-websocket currently requires jetty 8</details>
-    <feature version="[8,9)">jetty</feature>
+    <feature>jetty</feature>
     <feature version='${project.version}'>camel-core</feature>
     <bundle dependency='true'>mvn:javax.servlet/javax.servlet-api/${javax.servlet-api-version}</bundle>
     <bundle>mvn:org.apache.camel/camel-websocket/${project.version}</bundle>


[7/7] camel git commit: CAMEL-9890: Migrate Camel-websocket to Jetty9 - Remove feature detail camel-websocket need Jetty8

Posted by ac...@apache.org.
CAMEL-9890: Migrate Camel-websocket to Jetty9 - Remove feature detail camel-websocket need Jetty8


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/5356ab0d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/5356ab0d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/5356ab0d

Branch: refs/heads/master
Commit: 5356ab0d8bb7a5fb2e0f76faae1d826e39e921bb
Parents: b33b874
Author: Andrea Cosentino <an...@gmail.com>
Authored: Wed Apr 20 14:31:46 2016 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Wed Apr 20 14:31:46 2016 +0200

----------------------------------------------------------------------
 platforms/karaf/features/src/main/resources/features.xml | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/5356ab0d/platforms/karaf/features/src/main/resources/features.xml
----------------------------------------------------------------------
diff --git a/platforms/karaf/features/src/main/resources/features.xml b/platforms/karaf/features/src/main/resources/features.xml
index a20e8a6..a7d3ba0 100644
--- a/platforms/karaf/features/src/main/resources/features.xml
+++ b/platforms/karaf/features/src/main/resources/features.xml
@@ -1770,7 +1770,6 @@
     <bundle>mvn:org.apache.camel/camel-weather/${project.version}</bundle>
   </feature>
   <feature name='camel-websocket' version='${project.version}' resolver='(obr)' start-level='50'>
-    <details>camel-websocket currently requires jetty 8</details>
     <feature>jetty</feature>
     <feature version='${project.version}'>camel-core</feature>
     <bundle dependency='true'>mvn:javax.servlet/javax.servlet-api/${javax.servlet-api-version}</bundle>


[5/7] camel git commit: CAMEL-9890: Migrate Camel-websocket to Jetty9 - Fixed CS and minor fixes

Posted by ac...@apache.org.
CAMEL-9890: Migrate Camel-websocket to Jetty9 - Fixed CS and minor fixes


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/e3eb2c3c
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/e3eb2c3c
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/e3eb2c3c

Branch: refs/heads/master
Commit: e3eb2c3c4f1f85c40641bf0f3aa334629f904cff
Parents: 0e28a8b
Author: Andrea Cosentino <an...@gmail.com>
Authored: Wed Apr 20 13:59:37 2016 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Wed Apr 20 13:59:37 2016 +0200

----------------------------------------------------------------------
 .../component/websocket/DefaultWebsocket.java   | 38 +-------------------
 .../websocket/JettyClassPathResource.java       | 18 +++++-----
 .../component/websocket/WebsocketComponent.java | 10 +++---
 .../websocket/WebsocketComponentServlet.java    | 25 +++++++------
 .../component/websocket/WebsocketProducer.java  |  2 +-
 .../WebsocketComponentServletTest.java          |  4 +--
 .../websocket/WebsocketComponentTest.java       |  4 +--
 .../websocket/WebsocketProducerTest.java        |  2 +-
 8 files changed, 32 insertions(+), 71 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/e3eb2c3c/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/DefaultWebsocket.java
----------------------------------------------------------------------
diff --git a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/DefaultWebsocket.java b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/DefaultWebsocket.java
index aa1402a..422a2a1 100644
--- a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/DefaultWebsocket.java
+++ b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/DefaultWebsocket.java
@@ -30,7 +30,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 @WebSocket
-public class DefaultWebsocket implements Serializable, WebSocket {
+public class DefaultWebsocket implements Serializable {
     private static final long serialVersionUID = 1L;
     private static final Logger LOG = LoggerFactory.getLogger(DefaultWebsocket.class);
 
@@ -96,40 +96,4 @@ public class DefaultWebsocket implements Serializable, WebSocket {
     public void setConnectionKey(String connectionKey) {
         this.connectionKey = connectionKey;
     }
-
-	@Override
-	public Class<? extends Annotation> annotationType() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public int inputBufferSize() {
-		// TODO Auto-generated method stub
-		return 0;
-	}
-
-	@Override
-	public int maxBinaryMessageSize() {
-		// TODO Auto-generated method stub
-		return 0;
-	}
-
-	@Override
-	public int maxIdleTime() {
-		// TODO Auto-generated method stub
-		return 0;
-	}
-
-	@Override
-	public int maxTextMessageSize() {
-		// TODO Auto-generated method stub
-		return 0;
-	}
-
-	@Override
-	public BatchMode batchMode() {
-		// TODO Auto-generated method stub
-		return null;
-	}
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/e3eb2c3c/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/JettyClassPathResource.java
----------------------------------------------------------------------
diff --git a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/JettyClassPathResource.java b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/JettyClassPathResource.java
index 69fa843..1b6fa2a 100644
--- a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/JettyClassPathResource.java
+++ b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/JettyClassPathResource.java
@@ -19,7 +19,6 @@ package org.apache.camel.component.websocket;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.OutputStream;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.nio.channels.ReadableByteChannel;
@@ -118,14 +117,13 @@ public class JettyClassPathResource extends Resource {
         return new JettyClassPathResource(resolver, this.path + "/" + path);
     }
 
-	@Override
-	public void close() {
-		// noop
-		
-	}
+    @Override
+    public void close() {
+        // noop
+    }
 
-	@Override
-	public ReadableByteChannel getReadableByteChannel() throws IOException {
-		return null;
-	}
+    @Override
+    public ReadableByteChannel getReadableByteChannel() throws IOException {
+        return null;
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/e3eb2c3c/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponent.java b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponent.java
index d9ab59b..b786319 100644
--- a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponent.java
+++ b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponent.java
@@ -245,7 +245,7 @@ public class WebsocketComponent extends UriEndpointComponent {
                     // registered MBeans when Camel is done with the managed objects.
                     if (mbContainer != null) {
                         mbContainer.beanRemoved(null, connectorRef.server);
-                        mbContainer.beanRemoved(null,connectorRef.connector);
+                        mbContainer.beanRemoved(null, connectorRef.connector);
                     }
                 }
                 if (prodcon instanceof WebsocketConsumer) {
@@ -261,7 +261,7 @@ public class WebsocketComponent extends UriEndpointComponent {
     public synchronized MBeanContainer getMbContainer() {
         // If null, provide the default implementation.
         if (mbContainer == null) {
-            mbContainer=new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
+            mbContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
         }
 
         return this.mbContainer;
@@ -411,8 +411,8 @@ public class WebsocketComponent extends UriEndpointComponent {
 
     protected Server createStaticResourcesServer(ServletContextHandler context, String host, int port, String home) throws Exception {
         Server server = new Server();
-        HttpConfiguration http_config = new HttpConfiguration();
-        ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(http_config));
+        HttpConfiguration httpConfig = new HttpConfiguration();
+        ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(httpConfig));
         connector.setHost(host);
         connector.setPort(port);
         server.addConnector(connector);
@@ -496,7 +496,7 @@ public class WebsocketComponent extends UriEndpointComponent {
             sslContextFactory.setKeyStorePassword(sslKeyPassword);
             sslContextFactory.setKeyManagerPassword(sslPassword);
             if (sslKeystore != null) {
-            	sslContextFactory.setKeyStorePath(sslKeystore);
+                sslContextFactory.setKeyStorePath(sslKeystore);
             }
             sslSocketConnector = new ServerConnector(server, sslContextFactory);
 

http://git-wip-us.apache.org/repos/asf/camel/blob/e3eb2c3c/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponentServlet.java
----------------------------------------------------------------------
diff --git a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponentServlet.java b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponentServlet.java
index c675722..fdd4d7b 100644
--- a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponentServlet.java
+++ b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponentServlet.java
@@ -63,7 +63,7 @@ public class WebsocketComponentServlet extends WebSocketServlet {
         consumers.remove(consumer.getPath());
     }
 
-    public WebSocket doWebSocketConnect(ServletUpgradeRequest request, String protocol) {
+    public DefaultWebsocket doWebSocketConnect(ServletUpgradeRequest request, String protocol) {
         String protocolKey = protocol;
 
         if (protocol == null || !socketFactory.containsKey(protocol)) {
@@ -83,16 +83,15 @@ public class WebsocketComponentServlet extends WebSocketServlet {
         this.socketFactory = socketFactory;
     }
 
-	@Override
-	public void configure(WebSocketServletFactory factory) {
-		 factory.setCreator(new WebSocketCreator() {
-			    @Override
-			    public Object createWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp) {
-	             String protocolKey = "default";
-	
-	              WebSocketFactory factory = socketFactory.get(protocolKey);
-			      return factory.newInstance(req, protocolKey, sync, consumer);
-			    }
-	});
-	}
+    @Override
+    public void configure(WebSocketServletFactory factory) {
+        factory.setCreator(new WebSocketCreator() {
+            @Override
+            public Object createWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp) {
+                String protocolKey = "default";
+                WebSocketFactory factory = socketFactory.get(protocolKey);
+                return factory.newInstance(req, protocolKey, sync, consumer);
+            }
+        });
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/e3eb2c3c/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketProducer.java b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketProducer.java
index 17ca06a..18753a6 100644
--- a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketProducer.java
+++ b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketProducer.java
@@ -107,7 +107,7 @@ public class WebsocketProducer extends DefaultProducer implements WebsocketProdu
             if (message instanceof String) {
                 websocket.getSession().getRemote().sendString((String) message);
             } else if (message instanceof byte[]) {
-            	ByteBuffer buf = ByteBuffer.wrap((byte[]) message);
+                ByteBuffer buf = ByteBuffer.wrap((byte[]) message);
                 websocket.getSession().getRemote().sendBytes(buf);
             }
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/e3eb2c3c/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentServletTest.java
----------------------------------------------------------------------
diff --git a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentServletTest.java b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentServletTest.java
index 063d7ca..23250f4 100644
--- a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentServletTest.java
+++ b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentServletTest.java
@@ -81,7 +81,7 @@ public class WebsocketComponentServletTest {
     @Test
     public void testDoWebSocketConnect() {
         websocketComponentServlet.setConsumer(consumer);
-        WebSocket webSocket = websocketComponentServlet.doWebSocketConnect(request, PROTOCOL);
+        DefaultWebsocket webSocket = websocketComponentServlet.doWebSocketConnect(request, PROTOCOL);
         assertNotNull(webSocket);
         assertEquals(DefaultWebsocket.class, webSocket.getClass());
         DefaultWebsocket defaultWebsocket = (DefaultWebsocket) webSocket;
@@ -94,7 +94,7 @@ public class WebsocketComponentServletTest {
 
     @Test
     public void testDoWebSocketConnectConsumerIsNull() {
-        WebSocket webSocket = websocketComponentServlet.doWebSocketConnect(request, PROTOCOL);
+        DefaultWebsocket webSocket = websocketComponentServlet.doWebSocketConnect(request, PROTOCOL);
         assertNotNull(webSocket);
         assertEquals(DefaultWebsocket.class, webSocket.getClass());
         DefaultWebsocket defaultWebsocket = (DefaultWebsocket) webSocket;

http://git-wip-us.apache.org/repos/asf/camel/blob/e3eb2c3c/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentTest.java b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentTest.java
index 9966ab6..5376dc8 100644
--- a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentTest.java
+++ b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentTest.java
@@ -100,7 +100,7 @@ public class WebsocketComponentTest {
         ServletContextHandler handler = component.createContext(server, server.getConnectors()[0], null);
         assertEquals(1, server.getConnectors().length);
         assertEquals("localhost", ((ServerConnector) server.getConnectors()[0]).getHost());
-        assertEquals(1988,((ServerConnector) server.getConnectors()[0]).getPort());
+        assertEquals(1988, ((ServerConnector) server.getConnectors()[0]).getPort());
         assertFalse(server.getConnectors()[0].isStarted());
         assertEquals(handler, server.getHandler());
         assertEquals(1, server.getHandlers().length);
@@ -117,7 +117,7 @@ public class WebsocketComponentTest {
         Server server = component.createStaticResourcesServer(handler, "localhost", 1988, "classpath:public");
         assertEquals(1, server.getConnectors().length);
         assertEquals("localhost", ((ServerConnector) server.getConnectors()[0]).getHost());
-        assertEquals(1988,((ServerConnector) server.getConnectors()[0]).getPort());
+        assertEquals(1988, ((ServerConnector) server.getConnectors()[0]).getPort());
         assertFalse(server.getConnectors()[0].isStarted());
         assertEquals(handler, server.getHandler());
         assertEquals(1, server.getHandlers().length);

http://git-wip-us.apache.org/repos/asf/camel/blob/e3eb2c3c/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketProducerTest.java b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketProducerTest.java
index f518eaa..989ae0b 100644
--- a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketProducerTest.java
+++ b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketProducerTest.java
@@ -233,7 +233,7 @@ public class WebsocketProducerTest {
 
         websocketProducer.sendMessage(defaultWebsocket1, MESSAGE);
 
-        InOrder inOrder = inOrder(endpoint, store, session, defaultWebsocket1, defaultWebsocket2, exchange, inMessage,remoteEndpoint);
+        InOrder inOrder = inOrder(endpoint, store, session, defaultWebsocket1, defaultWebsocket2, exchange, inMessage, remoteEndpoint);
         inOrder.verify(defaultWebsocket1, times(1)).getSession();
         inOrder.verify(session, times(1)).isOpen();
         inOrder.verify(defaultWebsocket1, times(1)).getSession();


[6/7] camel git commit: Added camel-websocket docs to gitbook

Posted by ac...@apache.org.
Added camel-websocket docs to gitbook


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b33b8749
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b33b8749
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b33b8749

Branch: refs/heads/master
Commit: b33b8749db192172dc8057eee5b9f43dbdb8e25c
Parents: e3eb2c3
Author: Andrea Cosentino <an...@gmail.com>
Authored: Wed Apr 20 14:08:52 2016 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Wed Apr 20 14:09:09 2016 +0200

----------------------------------------------------------------------
 .../src/main/docs/websocket.adoc                | 236 +++++++++++++++++++
 docs/user-manual/en/SUMMARY.md                  |   1 +
 2 files changed, 237 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/b33b8749/components/camel-websocket/src/main/docs/websocket.adoc
----------------------------------------------------------------------
diff --git a/components/camel-websocket/src/main/docs/websocket.adoc b/components/camel-websocket/src/main/docs/websocket.adoc
new file mode 100644
index 0000000..ff0abcf
--- /dev/null
+++ b/components/camel-websocket/src/main/docs/websocket.adoc
@@ -0,0 +1,236 @@
+[[Websocket-WebsocketComponent]]
+Websocket Component
+~~~~~~~~~~~~~~~~~~~
+
+*Available as of Camel 2.10*
+
+The *websocket* component provides websocket
+link:endpoint.html[endpoints] for communicating with clients using
+websocket. The component uses Eclipse Jetty Server which implements the
+http://tools.ietf.org/html/rfc6455[IETF] specification (drafts and RFC
+6455). It supports the protocols ws:// and wss://. To use wss://
+protocol, the SSLContextParameters must be defined.
+
+
+*Version currently supported*
+
+Camel 2.18 uses Jetty 9
+
+[[Websocket-URIformat]]
+URI format
+^^^^^^^^^^
+
+[source,java]
+---------------------------------------------------
+websocket://hostname[:port][/resourceUri][?options]
+---------------------------------------------------
+
+You can append query options to the URI in the following format,
+`?option=value&option=value&...`
+
+[[Websocket-Options]]
+Websocket Options
+^^^^^^^^^^^^^^^^^
+
+
+// component options: START
+The Jetty Websocket component supports 12 options which are listed below.
+
+
+
+[width="100%",cols="2s,1m,8",options="header"]
+|=======================================================================
+| Name | Java Type | Description
+| staticResources | String | Set a resource path for static resources (such as .html files etc). The resources can be loaded from classpath if you prefix with classpath: otherwise the resources is loaded from file system or from JAR files. For example to load from root classpath use classpath:. or classpath:WEB-INF/static If not configured (eg null) then no static resource is in use.
+| host | String | The hostname. The default value is 0.0.0.0
+| port | Integer | The port number. The default value is 9292
+| sslKeyPassword | String | The password for the keystore when using SSL.
+| sslPassword | String | The password when using SSL.
+| sslKeystore | String | The path to the keystore.
+| enableJmx | boolean | If this option is true Jetty JMX support will be enabled for this endpoint. See Jetty JMX support for more details.
+| minThreads | Integer | To set a value for minimum number of threads in server thread pool.
+| maxThreads | Integer | To set a value for maximum number of threads in server thread pool.
+| threadPool | ThreadPool | To use a custom thread pool for the server.
+| sslContextParameters | SSLContextParameters | To configure security using SSLContextParameters
+| socketFactory | Map | To configure a map which contains custom WebSocketFactory for sub protocols. The key in the map is the sub protocol. The default key is reserved for the default implementation.
+|=======================================================================
+// component options: END
+
+
+
+
+// endpoint options: START
+The Jetty Websocket component supports 20 endpoint options which are listed below:
+
+[width="100%",cols="2s,1,1m,1m,5",options="header"]
+|=======================================================================
+| Name | Group | Default | Java Type | Description
+| host | common | 0.0.0.0 | String | The hostname. The default value is 0.0.0.0. Setting this option on the component will use the component configured value as default.
+| port | common | 9292 | Integer | The port number. The default value is 9292. Setting this option on the component will use the component configured value as default.
+| resourceUri | common |  | String | *Required* Name of the websocket channel to use
+| allowedOrigins | common |  | String | The CORS allowed origins. Use to allow all.
+| bufferSize | common | 8192 | Integer | Set the buffer size of the websocketServlet which is also the max frame byte size (default 8192)
+| crossOriginFilterOn | common | false | boolean | Whether to enable CORS
+| enableJmx | common | false | boolean | If this option is true Jetty JMX support will be enabled for this endpoint. See Jetty JMX support for more details.
+| filterPath | common |  | String | Context path for filtering CORS
+| maxBinaryMessageSize | common | -1 | Integer | Can be used to set the size in bytes that the websocket created by the websocketServlet may be accept before closing. (Default is -1 - or unlimited)
+| maxIdleTime | common | 300000 | Integer | Set the time in ms that the websocket created by the websocketServlet may be idle before closing. (default is 300000)
+| maxTextMessageSize | common |  | Integer | Can be used to set the size in characters that the websocket created by the websocketServlet may be accept before closing.
+| minVersion | common | 13 | Integer | Can be used to set the minimum protocol version accepted for the websocketServlet. (Default 13 - the RFC6455 version)
+| sessionSupport | common | false | boolean | Whether to enable session support which enables HttpSession for each http request.
+| sslContextParameters | common |  | SSLContextParameters | To configure security using SSLContextParameters
+| staticResources | common |  | String | Set a resource path for static resources (such as .html files etc). The resources can be loaded from classpath if you prefix with classpath: otherwise the resources is loaded from file system or from JAR files. For example to load from root classpath use classpath:. or classpath:WEB-INF/static If not configured (eg null) then no static resource is in use.
+| bridgeErrorHandler | consumer | false | boolean | Allows for bridging the consumer to the Camel routing Error Handler which mean any exceptions occurred while the consumer is trying to pickup incoming messages or the likes will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions that will be logged at WARN/ERROR level and ignored.
+| exceptionHandler | consumer (advanced) |  | ExceptionHandler | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options is not in use. By default the consumer will deal with exceptions that will be logged at WARN/ERROR level and ignored.
+| sendToAll | producer |  | Boolean | To send to all websocket subscribers. Can be used to configure on endpoint level instead of having to use the WebsocketConstants.SEND_TO_ALL header on the message.
+| exchangePattern | advanced | InOnly | ExchangePattern | Sets the default exchange pattern when creating an exchange
+| synchronous | advanced | false | boolean | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported).
+|=======================================================================
+// endpoint options: END
+
+ 
+
+[[Websocket-MessageHeaders]]
+Message Headers
+^^^^^^^^^^^^^^^
+
+The websocket component uses 2 headers to indicate to either send
+messages back to a single/current client, or to all clients.
+
+[width="100%",cols="10%,90%",options="header",]
+|=======================================================================
+
+|`WebsocketConstants.SEND_TO_ALL` |Sends the message to all clients which are currently connected. You can
+use the `sendToAll` option on the endpoint instead of using this header.
+
+|`WebsocketConstants.CONNECTION_KEY` |Sends the message to the client with the given connection key.
+|=======================================================================
+
+[[Websocket-Usage]]
+Usage
+^^^^^
+
+In this example we let Camel exposes a websocket server which clients
+can communicate with. The websocket server uses the default host and
+port, which would be `0.0.0.0:9292`. +
+ The example will send back an echo of the input. To send back a
+message, we need to send the transformed message to the same endpoint
+`"websocket://echo"`. This is needed +
+ because by default the messaging is InOnly.
+
+This example is part of an unit test, which you can find
+https://svn.apache.org/repos/asf/camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketRouteExampleTest.java[here].
+As a client we use the link:ahc.html[AHC] library which offers support
+for web socket as well.
+
+Here is another example where webapp resources location have been
+defined to allow the Jetty Application Server to not only register the
+WebSocket servlet but also to expose web resources for the browser.
+Resources should be defined under the webapp directory.
+
+[source,java]
+-----------------------------------------------------------------------------------------------
+from("activemq:topic:newsTopic")
+   .routeId("fromJMStoWebSocket")
+   .to("websocket://localhost:8443/newsTopic?sendToAll=true&staticResources=classpath:webapp");
+-----------------------------------------------------------------------------------------------
+
+[[Websocket-SettingupSSLforWebSocketComponent]]
+Setting up SSL for WebSocket Component
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+[[Websocket-UsingtheJSSEConfigurationUtility]]
+Using the JSSE Configuration Utility
+++++++++++++++++++++++++++++++++++++
+
+As of Camel 2.10, the WebSocket component supports SSL/TLS configuration
+through the link:camel-configuration-utilities.html[Camel JSSE
+Configuration Utility].  This utility greatly decreases the amount of
+component specific code you need to write and is configurable at the
+endpoint and component levels.  The following examples demonstrate how
+to use the utility with the Cometd component.
+
+[[Websocket-Programmaticconfigurationofthecomponent]]
+Programmatic configuration of the component
+
+[source,java]
+-----------------------------------------------------------------------------------------------
+KeyStoreParameters ksp = new KeyStoreParameters();
+ksp.setResource("/users/home/server/keystore.jks");
+ksp.setPassword("keystorePassword");
+
+KeyManagersParameters kmp = new KeyManagersParameters();
+kmp.setKeyStore(ksp);
+kmp.setKeyPassword("keyPassword");
+
+TrustManagersParameters tmp = new TrustManagersParameters();
+tmp.setKeyStore(ksp);
+
+SSLContextParameters scp = new SSLContextParameters();
+scp.setKeyManagers(kmp);
+scp.setTrustManagers(tmp);
+
+CometdComponent commetdComponent = getContext().getComponent("cometds", CometdComponent.class);
+commetdComponent.setSslContextParameters(scp);
+-----------------------------------------------------------------------------------------------
+
+[[Websocket-SpringDSLbasedconfigurationofendpoint]]
+Spring DSL based configuration of endpoint
+
+[source,xml]
+-------------------------------------------------------------------------------------------
+...
+  <camel:sslContextParameters
+      id="sslContextParameters">
+    <camel:keyManagers
+        keyPassword="keyPassword">
+      <camel:keyStore
+          resource="/users/home/server/keystore.jks"
+          password="keystorePassword"/>
+    </camel:keyManagers>
+    <camel:trustManagers>
+      <camel:keyStore
+          resource="/users/home/server/keystore.jks"
+          password="keystorePassword"/>
+    </camel:trustManagers>
+  </camel:sslContextParameters>...
+...
+  <to uri="websocket://127.0.0.1:8443/test?sslContextParameters=#sslContextParameters"/>...
+-------------------------------------------------------------------------------------------
+
+[[Websocket-JavaDSLbasedconfigurationofendpoint]]
+Java DSL based configuration of endpoint
+
+[source,java]
+----------------------------------------------------------------------------------------------------------
+...
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() {
+                
+                String uri = "websocket://127.0.0.1:8443/test?sslContextParameters=#sslContextParameters";
+                
+                from(uri)
+                     .log(">>> Message received from WebSocket Client : ${body}")
+                     .to("mock:client")
+                     .loop(10)
+                         .setBody().constant(">> Welcome on board!")
+                         .to(uri);
+...
+----------------------------------------------------------------------------------------------------------
+
+[[Websocket-SeeAlso]]
+See Also
+^^^^^^^^
+
+* link:configuring-camel.html[Configuring Camel]
+* link:component.html[Component]
+* link:endpoint.html[Endpoint]
+* link:getting-started.html[Getting Started]
+
+* link:ahc.html[AHC]
+* link:jetty.html[Jetty]
+* link:twitter-websocket-example.html[Twitter Websocket Example]
+demonstrates how to poll a constant feed of twitter searches and publish
+results in real time using web socket to a web page.
+

http://git-wip-us.apache.org/repos/asf/camel/blob/b33b8749/docs/user-manual/en/SUMMARY.md
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/SUMMARY.md b/docs/user-manual/en/SUMMARY.md
index 653b8cc..4c97057 100644
--- a/docs/user-manual/en/SUMMARY.md
+++ b/docs/user-manual/en/SUMMARY.md
@@ -171,6 +171,7 @@
     * [SJMS](sjms.adoc)
     * [SJMS Batch](sjms-batch.adoc)
     * [Twitter](twitter.adoc)
+    * [Websocket](websocket.adoc)
     * [XML Security](xmlsecurity.adoc)
     * [Yammer](yammer.adoc)
     * [ZooKeeper](zookeeper.adoc)