camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject [5/7] camel git commit: CAMEL-9890: Migrate Camel-websocket to Jetty9 - Fixed CS and minor fixes
Date Wed, 20 Apr 2016 12:53:52 GMT
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 <ancosen@gmail.com>
Authored: Wed Apr 20 13:59:37 2016 +0200
Committer: Andrea Cosentino <ancosen@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();


Mime
View raw message