cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject git commit: remove custom websocket servlets (CXF-5339)
Date Tue, 11 Mar 2014 14:25:06 GMT
Repository: cxf
Updated Branches:
  refs/heads/master c70e021bc -> 2131c33de


remove custom websocket servlets (CXF-5339)


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

Branch: refs/heads/master
Commit: 2131c33de3421cc2da9a0820c93f99c8b51cc952
Parents: c70e021
Author: Akitoshi Yoshida <ay@apache.org>
Authored: Tue Mar 11 15:21:37 2014 +0100
Committer: Akitoshi Yoshida <ay@apache.org>
Committed: Tue Mar 11 15:24:26 2014 +0100

----------------------------------------------------------------------
 .../websocket/WebSocketDestinationFactory.java  |  24 +++-
 .../jetty/CXFJettyWebSocketServlet.java         | 109 ------------------
 .../jetty/CXFJettyWebSocketServletService.java  |  33 ------
 .../CXFNonSpringJettyWebSocketServlet.java      | 115 -------------------
 .../jetty/JettyWebSocketDestination.java        |  32 +++++-
 .../websocket/jetty/JettyWebSocketHandler.java  |  18 +--
 .../websocket/jetty/JettyWebSocketManager.java  |  40 +------
 .../jetty/JettyWebSocketServletDestination.java |  79 +++++++++++++
 .../jetty/JettyWebSocketManagerTest.java        |  22 ++--
 .../resources/jaxrs_websocket/WEB-INF/web.xml   |   8 +-
 10 files changed, 153 insertions(+), 327 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/2131c33d/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/WebSocketDestinationFactory.java
----------------------------------------------------------------------
diff --git a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/WebSocketDestinationFactory.java
b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/WebSocketDestinationFactory.java
index 1c539d6..4c6fdf1 100644
--- a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/WebSocketDestinationFactory.java
+++ b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/WebSocketDestinationFactory.java
@@ -23,12 +23,15 @@ import java.io.IOException;
 import org.apache.cxf.Bus;
 import org.apache.cxf.common.injection.NoJSR250Annotations;
 import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.DestinationFactory;
+import org.apache.cxf.transport.DestinationFactoryManager;
 import org.apache.cxf.transport.http.AbstractHTTPDestination;
 import org.apache.cxf.transport.http.DestinationRegistry;
+import org.apache.cxf.transport.http.HTTPTransportFactory;
 import org.apache.cxf.transport.http.HttpDestinationFactory;
 import org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory;
-import org.apache.cxf.transport.servlet.ServletDestination;
 import org.apache.cxf.transport.websocket.jetty.JettyWebSocketDestination;
+import org.apache.cxf.transport.websocket.jetty.JettyWebSocketServletDestination;
 
 @NoJSR250Annotations()
 public class WebSocketDestinationFactory implements HttpDestinationFactory {
@@ -42,8 +45,25 @@ public class WebSocketDestinationFactory implements HttpDestinationFactory
{
                 .getExtension(JettyHTTPServerEngineFactory.class);
             return new JettyWebSocketDestination(bus, registry, endpointInfo, serverEngineFactory);
         } else {
-            return new ServletDestination(bus, registry, endpointInfo, endpointInfo.getAddress());
+            //REVISIT other way of getting the registry of http so that the plain cxf servlet
finds the destination?
+            registry = getDestinationRegistry(bus);
+            return new JettyWebSocketServletDestination(bus, registry, endpointInfo, endpointInfo.getAddress());
         }
     }
 
+    private static DestinationRegistry getDestinationRegistry(Bus bus) {
+        DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
+        try {
+            DestinationFactory df = dfm
+                .getDestinationFactory("http://cxf.apache.org/transports/http/configuration");
+            if (df instanceof HTTPTransportFactory) {
+                HTTPTransportFactory transportFactory = (HTTPTransportFactory)df;
+                return transportFactory.getRegistry();
+            }
+        } catch (Exception e) {
+            // why are we throwing a busexception if the DF isn't found?
+        }
+        return null;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/2131c33d/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/CXFJettyWebSocketServlet.java
----------------------------------------------------------------------
diff --git a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/CXFJettyWebSocketServlet.java
b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/CXFJettyWebSocketServlet.java
deleted file mode 100644
index ed1bd0c..0000000
--- a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/CXFJettyWebSocketServlet.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.cxf.transport.websocket.jetty;
-
-import java.io.IOException;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.cxf.BusException;
-import org.apache.cxf.transport.DestinationFactory;
-import org.apache.cxf.transport.DestinationFactoryManager;
-import org.apache.cxf.transport.http.DestinationRegistry;
-import org.apache.cxf.transport.servlet.CXFServlet;
-import org.apache.cxf.transport.websocket.WebSocketTransportFactory;
-import org.eclipse.jetty.websocket.WebSocket;
-import org.eclipse.jetty.websocket.WebSocketFactory;
-
-/**
- * 
- */
-public class CXFJettyWebSocketServlet extends CXFServlet 
-    implements CXFJettyWebSocketServletService, WebSocketFactory.Acceptor {
-    private static final long serialVersionUID = 3955992016049976728L;
-    private JettyWebSocketManager websocketManager;
-    
-    public CXFJettyWebSocketServlet() {
-    }
-    
-    public WebSocket doWebSocketConnect(HttpServletRequest request, String protocol) {
-        return new JettyWebSocket(websocketManager, request, protocol);
-    }
-
-
-    public boolean checkOrigin(HttpServletRequest request, String origin) {
-        return true;
-    }
-
-    @Override
-    public void service(ServletRequest req, ServletResponse res) throws ServletException,
IOException {
-        if (websocketManager.acceptWebSocket(req, res)) {
-            return;
-        }
-        super.service(req, res);
-    }
-    
-    @Override
-    public void serviceInternal(ServletRequest req, ServletResponse resp) throws ServletException,
IOException {
-        super.service(req, resp);
-    }
-    
-    
-    @Override
-    public void init(ServletConfig sc) throws ServletException {
-        super.init(sc);
-        
-        websocketManager = new JettyWebSocketManager();
-        websocketManager.init(this, sc);
-    }
-    
-    @Override
-    protected DestinationRegistry getDestinationRegistryFromBus() {
-        DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
-        try {
-            DestinationFactory df = dfm
-                .getDestinationFactory("http://cxf.apache.org/transports/websocket/configuration");
-            if (df instanceof WebSocketTransportFactory) {
-                WebSocketTransportFactory transportFactory = (WebSocketTransportFactory)df;
-                return transportFactory.getRegistry();
-            }
-        } catch (BusException e) {
-            // why are we throwing a busexception if the DF isn't found?
-        }
-        return null;
-    }
-
-
-
-    @Override
-    public void destroy() {
-        try {
-            websocketManager.destroy();
-        } catch (Exception e) {
-            // ignore
-        } finally {
-            super.destroy();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/cxf/blob/2131c33d/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/CXFJettyWebSocketServletService.java
----------------------------------------------------------------------
diff --git a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/CXFJettyWebSocketServletService.java
b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/CXFJettyWebSocketServletService.java
deleted file mode 100644
index 89e18c2..0000000
--- a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/CXFJettyWebSocketServletService.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.cxf.transport.websocket.jetty;
-
-import java.io.IOException;
-
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-
-/**
- * 
- */
-interface CXFJettyWebSocketServletService {
-    void serviceInternal(ServletRequest req, ServletResponse resp) throws ServletException,
IOException;
-}

http://git-wip-us.apache.org/repos/asf/cxf/blob/2131c33d/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/CXFNonSpringJettyWebSocketServlet.java
----------------------------------------------------------------------
diff --git a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/CXFNonSpringJettyWebSocketServlet.java
b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/CXFNonSpringJettyWebSocketServlet.java
deleted file mode 100644
index eaa404e..0000000
--- a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/CXFNonSpringJettyWebSocketServlet.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.cxf.transport.websocket.jetty;
-
-import java.io.IOException;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.cxf.BusException;
-import org.apache.cxf.transport.DestinationFactory;
-import org.apache.cxf.transport.DestinationFactoryManager;
-import org.apache.cxf.transport.http.DestinationRegistry;
-import org.apache.cxf.transport.servlet.CXFNonSpringServlet;
-import org.apache.cxf.transport.websocket.WebSocketTransportFactory;
-import org.eclipse.jetty.websocket.WebSocket;
-import org.eclipse.jetty.websocket.WebSocketFactory;
-
-/**
- * 
- */
-public class CXFNonSpringJettyWebSocketServlet extends CXFNonSpringServlet 
-    implements CXFJettyWebSocketServletService, WebSocketFactory.Acceptor {
-    private static final long serialVersionUID = 6921073894009215482L;
-    private JettyWebSocketManager websocketManager;
-    
-    public CXFNonSpringJettyWebSocketServlet() {
-    }
-    
-    public CXFNonSpringJettyWebSocketServlet(DestinationRegistry destinationRegistry, boolean
loadBus) {
-        super(destinationRegistry, loadBus);
-    }
-
-    public CXFNonSpringJettyWebSocketServlet(DestinationRegistry destinationRegistry) {
-        super(destinationRegistry);
-    }
-
-    public WebSocket doWebSocketConnect(HttpServletRequest request, String protocol) {
-        return new JettyWebSocket(websocketManager, request, protocol);
-    }
-
-
-    public boolean checkOrigin(HttpServletRequest request, String origin) {
-        return true;
-    }
-
-    @Override
-    public void service(ServletRequest req, ServletResponse res) throws ServletException,
IOException {
-        if (websocketManager.acceptWebSocket(req, res)) {
-            return;
-        }
-        super.service(req, res);
-    }
-    
-    @Override
-    public void serviceInternal(ServletRequest req, ServletResponse resp) throws ServletException,
IOException {
-        super.service(req, resp);
-    }
-    
-    
-    @Override
-    public void init(ServletConfig sc) throws ServletException {
-        super.init(sc);
-        
-        websocketManager = new JettyWebSocketManager();
-        websocketManager.init(this, sc);
-    }
-
-    @Override
-    protected DestinationRegistry getDestinationRegistryFromBus() {
-        DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
-        try {
-            DestinationFactory df = dfm
-                .getDestinationFactory("http://cxf.apache.org/transports/websocket/configuration");
-            if (df instanceof WebSocketTransportFactory) {
-                WebSocketTransportFactory transportFactory = (WebSocketTransportFactory)df;
-                return transportFactory.getRegistry();
-            }
-        } catch (BusException e) {
-            // why are we throwing a busexception if the DF isn't found?
-        }
-        return null;
-    }
-
-    @Override
-    public void destroy() {
-        try {
-            websocketManager.destroy();
-        } catch (Exception e) {
-            // ignore
-        } finally {
-            super.destroy();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/cxf/blob/2131c33d/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/JettyWebSocketDestination.java
----------------------------------------------------------------------
diff --git a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/JettyWebSocketDestination.java
b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/JettyWebSocketDestination.java
index f849713..fabb0f6 100644
--- a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/JettyWebSocketDestination.java
+++ b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/JettyWebSocketDestination.java
@@ -22,6 +22,8 @@ package org.apache.cxf.transport.websocket.jetty;
 import java.io.IOException;
 import java.net.URL;
 
+import javax.servlet.http.HttpServletRequest;
+
 import org.apache.cxf.Bus;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.service.model.EndpointInfo;
@@ -29,15 +31,20 @@ import org.apache.cxf.transport.http.DestinationRegistry;
 import org.apache.cxf.transport.http_jetty.JettyHTTPDestination;
 import org.apache.cxf.transport.http_jetty.JettyHTTPHandler;
 import org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory;
+import org.eclipse.jetty.websocket.WebSocket;
+import org.eclipse.jetty.websocket.WebSocketFactory;
 
 /**
  * 
  */
-public class JettyWebSocketDestination extends JettyHTTPDestination {
+public class JettyWebSocketDestination extends JettyHTTPDestination implements WebSocketFactory.Acceptor
{
+    private JettyWebSocketManager webSocketManager;
 
     public JettyWebSocketDestination(Bus bus, DestinationRegistry registry, EndpointInfo
ei,
                                      JettyHTTPServerEngineFactory serverEngineFactory) throws
IOException {
         super(bus, registry, ei, serverEngineFactory);
+        webSocketManager = new JettyWebSocketManager();
+        webSocketManager.init(this);
     }
 
     @Override
@@ -60,7 +67,28 @@ public class JettyWebSocketDestination extends JettyHTTPDestination {
     
     @Override
     protected JettyHTTPHandler createJettyHTTPHandler(JettyHTTPDestination jhd, boolean cmExact)
{
-        return new JettyWebSocketHandler(jhd, cmExact);
+        return new JettyWebSocketHandler(jhd, cmExact, webSocketManager);
+    }
+
+    @Override
+    public boolean checkOrigin(HttpServletRequest arg0, String arg1) {
+        return true;
+    }
+
+    @Override
+    public WebSocket doWebSocketConnect(HttpServletRequest request, String protocol) {
+        return new JettyWebSocket(webSocketManager, request, protocol);
+    }
+
+    @Override
+    public void shutdown() {
+        try {
+            webSocketManager.destroy();
+        } catch (Exception e) {
+            // ignore
+        } finally {
+            super.shutdown();
+        }
     }
 
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/2131c33d/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/JettyWebSocketHandler.java
----------------------------------------------------------------------
diff --git a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/JettyWebSocketHandler.java
b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/JettyWebSocketHandler.java
index be09dce..685c441 100644
--- a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/JettyWebSocketHandler.java
+++ b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/JettyWebSocketHandler.java
@@ -27,23 +27,17 @@ import javax.servlet.http.HttpServletResponse;
 import org.apache.cxf.transport.http_jetty.JettyHTTPDestination;
 import org.apache.cxf.transport.http_jetty.JettyHTTPHandler;
 import org.eclipse.jetty.server.Request;
-import org.eclipse.jetty.websocket.WebSocket;
-import org.eclipse.jetty.websocket.WebSocketFactory;
 
 /**
  * The extended version of JettyHTTPHandler that can support websocket.
  */
-class JettyWebSocketHandler extends JettyHTTPHandler implements WebSocketFactory.Acceptor
{
+class JettyWebSocketHandler extends JettyHTTPHandler {
     private JettyWebSocketManager webSocketManager;
 
-    public JettyWebSocketHandler(JettyHTTPDestination jhd, boolean cmExact) {
+    public JettyWebSocketHandler(JettyHTTPDestination jhd, boolean cmExact,
+                                 JettyWebSocketManager webSocketManager) {
         super(jhd, cmExact);
-        webSocketManager = new JettyWebSocketManager();
-        webSocketManager.init(this, jhd);
-    }
-
-    public WebSocket doWebSocketConnect(HttpServletRequest request, String protocol) {
-        return new JettyWebSocket(webSocketManager, request, protocol);
+        this.webSocketManager = webSocketManager;
     }
     
     @Override
@@ -56,8 +50,4 @@ class JettyWebSocketHandler extends JettyHTTPHandler implements WebSocketFactory
             super.handle(target, baseRequest, request, response);
         }
     }
-
-    public boolean checkOrigin(HttpServletRequest request, String protocol) {
-        return true;
-    }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/2131c33d/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/JettyWebSocketManager.java
----------------------------------------------------------------------
diff --git a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/JettyWebSocketManager.java
b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/JettyWebSocketManager.java
index 139b1a6..e351747 100644
--- a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/JettyWebSocketManager.java
+++ b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/JettyWebSocketManager.java
@@ -21,7 +21,6 @@ package org.apache.cxf.transport.websocket.jetty;
 
 import java.io.IOException;
 
-import javax.servlet.ServletConfig;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 import javax.servlet.ServletRequest;
@@ -30,8 +29,6 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.cxf.transport.http.AbstractHTTPDestination;
-import org.apache.cxf.transport.http_jetty.JettyHTTPDestination;
-import org.apache.cxf.transport.servlet.CXFNonSpringServlet;
 import org.eclipse.jetty.websocket.WebSocketFactory;
 import org.eclipse.jetty.websocket.WebSocketFactory.Acceptor;
 
@@ -40,45 +37,16 @@ import org.eclipse.jetty.websocket.WebSocketFactory.Acceptor;
  */
 public class JettyWebSocketManager {
     private WebSocketFactory webSocketFactory;
-    
-    // either servlet is set or destination + servletContext are set
-    private CXFNonSpringServlet servlet;
     private AbstractHTTPDestination destination;
     private ServletContext servletContext;
 
-    public void init(JettyWebSocketHandler handler, JettyHTTPDestination dest) {
+    public void init(AbstractHTTPDestination dest) {
         this.destination = dest;
+
         //TODO customize websocket factory configuration options when using the destination.
-        
-        webSocketFactory = new WebSocketFactory((Acceptor)handler, 8192);
+        webSocketFactory = new WebSocketFactory((Acceptor)dest, 8192);
     }
 
-    public void init(CXFNonSpringServlet srvlt, ServletConfig sc) throws ServletException
{
-        this.servlet = srvlt;
-        try {
-            
-            String bs = srvlt.getInitParameter("bufferSize");
-            
-            webSocketFactory = new WebSocketFactory((Acceptor)srvlt, bs == null ? 8192 :
Integer.parseInt(bs));
-            webSocketFactory.start();
-        
-            String max = srvlt.getInitParameter("maxIdleTime");
-            if (max != null) {
-                webSocketFactory.setMaxIdleTime(Integer.parseInt(max));
-            }
-            max = srvlt.getInitParameter("maxTextMessageSize");
-            if (max != null) {
-                webSocketFactory.setMaxTextMessageSize(Integer.parseInt(max));
-            }
-            max = srvlt.getInitParameter("maxBinaryMessageSize");
-            if (max != null) {
-                webSocketFactory.setMaxBinaryMessageSize(Integer.parseInt(max));
-            }
-        } catch (Exception e) {
-            throw e instanceof ServletException ? (ServletException)e : new ServletException(e);
-        }
-    }
-    
     void setServletContext(ServletContext servletContext) {
         this.servletContext = servletContext;
     }
@@ -107,8 +75,6 @@ public class JettyWebSocketManager {
     public void service(HttpServletRequest request, HttpServletResponse response) throws
IOException, ServletException {
         if (destination != null) {
             destination.invoke(null, servletContext, request, response);
-        } else if (servlet != null) {
-            ((CXFJettyWebSocketServletService)servlet).serviceInternal(request, response);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/2131c33d/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/JettyWebSocketServletDestination.java
----------------------------------------------------------------------
diff --git a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/JettyWebSocketServletDestination.java
b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/JettyWebSocketServletDestination.java
new file mode 100644
index 0000000..1f7d751
--- /dev/null
+++ b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/JettyWebSocketServletDestination.java
@@ -0,0 +1,79 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.transport.websocket.jetty;
+
+import java.io.IOException;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.http.DestinationRegistry;
+import org.apache.cxf.transport.servlet.ServletDestination;
+import org.eclipse.jetty.websocket.WebSocket;
+import org.eclipse.jetty.websocket.WebSocketFactory;
+
+/**
+ * 
+ */
+public class JettyWebSocketServletDestination extends ServletDestination implements WebSocketFactory.Acceptor
{
+    private JettyWebSocketManager webSocketManager;
+
+    public JettyWebSocketServletDestination(Bus bus, DestinationRegistry registry, EndpointInfo
ei,
+                                            String path) throws IOException {
+        super(bus, registry, ei, ei.toString());
+        webSocketManager = new JettyWebSocketManager();
+        webSocketManager.init(this);
+    }
+
+    @Override
+    public void invoke(ServletConfig config, ServletContext context, HttpServletRequest req,
+                       HttpServletResponse resp) throws IOException {
+        if (webSocketManager.acceptWebSocket(req, resp)) {
+            return;
+        }
+
+        super.invoke(config, context, req, resp);
+    }
+
+    @Override
+    public boolean checkOrigin(HttpServletRequest arg0, String arg1) {
+        return true;
+    }
+
+    @Override
+    public WebSocket doWebSocketConnect(HttpServletRequest request, String protocol) {
+        return new JettyWebSocket(webSocketManager, request, protocol);
+    }
+
+    @Override
+    public void shutdown() {
+        try {
+            webSocketManager.destroy();
+        } catch (Exception e) {
+            // ignore
+        } finally {
+            super.shutdown();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/2131c33d/rt/transports/websocket/src/test/java/org/apache/cxf/transport/websocket/jetty/JettyWebSocketManagerTest.java
----------------------------------------------------------------------
diff --git a/rt/transports/websocket/src/test/java/org/apache/cxf/transport/websocket/jetty/JettyWebSocketManagerTest.java
b/rt/transports/websocket/src/test/java/org/apache/cxf/transport/websocket/jetty/JettyWebSocketManagerTest.java
index a74b1f1..6ad9274 100644
--- a/rt/transports/websocket/src/test/java/org/apache/cxf/transport/websocket/jetty/JettyWebSocketManagerTest.java
+++ b/rt/transports/websocket/src/test/java/org/apache/cxf/transport/websocket/jetty/JettyWebSocketManagerTest.java
@@ -25,6 +25,7 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.cxf.transport.http_jetty.JettyHTTPDestination;
+import org.apache.cxf.transport.servlet.ServletDestination;
 import org.easymock.EasyMock;
 import org.easymock.IMocksControl;
 
@@ -44,39 +45,38 @@ public class JettyWebSocketManagerTest extends Assert {
     }
     
     @Test
-    public void testServiceUsingDestination() throws Exception {
+    public void testServiceUsingJettyDestination() throws Exception {
         JettyWebSocketManager jwsm = new JettyWebSocketManager();
         
-        JettyWebSocketHandler handler = control.createMock(JettyWebSocketHandler.class);
-        JettyHTTPDestination dest = control.createMock(JettyHTTPDestination.class);
+        JettyHTTPDestination dest = control.createMock(JettyWebSocketDestination.class);
                 
         HttpServletRequest request = control.createMock(HttpServletRequest.class);
         HttpServletResponse response = control.createMock(HttpServletResponse.class);
         
-        dest.invoke(EasyMock.isNull(ServletConfig.class), EasyMock.isNull(ServletContext.class),

+        dest.invoke(EasyMock.isNull(ServletConfig.class), EasyMock.anyObject(ServletContext.class),

                     EasyMock.eq(request), EasyMock.eq(response));
         EasyMock.expectLastCall();
         control.replay();
-        jwsm.init(handler, dest);
+        jwsm.init(dest);
         
         jwsm.service(request, response);
         control.verify();
     }
 
     @Test
-    public void testServiceUsingServlet() throws Exception {
+    public void testServiceUsingServletDestination() throws Exception {
         JettyWebSocketManager jwsm = new JettyWebSocketManager();
         
+        ServletDestination dest = control.createMock(JettyWebSocketServletDestination.class);
+                
         HttpServletRequest request = control.createMock(HttpServletRequest.class);
         HttpServletResponse response = control.createMock(HttpServletResponse.class);
         
-        CXFNonSpringJettyWebSocketServlet srvlt = control.createMock(CXFNonSpringJettyWebSocketServlet.class);
-        ServletConfig sc = control.createMock(ServletConfig.class);
-
-        srvlt.serviceInternal(EasyMock.eq(request), EasyMock.eq(response));
+        dest.invoke(EasyMock.isNull(ServletConfig.class), EasyMock.anyObject(ServletContext.class),

+                    EasyMock.eq(request), EasyMock.eq(response));
         EasyMock.expectLastCall();
         control.replay();
-        jwsm.init(srvlt, sc);
+        jwsm.init(dest);
         
         jwsm.service(request, response);
         control.verify();

http://git-wip-us.apache.org/repos/asf/cxf/blob/2131c33d/systests/jaxrs/src/test/resources/jaxrs_websocket/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/resources/jaxrs_websocket/WEB-INF/web.xml b/systests/jaxrs/src/test/resources/jaxrs_websocket/WEB-INF/web.xml
index 7619cdf..76d7687 100644
--- a/systests/jaxrs/src/test/resources/jaxrs_websocket/WEB-INF/web.xml
+++ b/systests/jaxrs/src/test/resources/jaxrs_websocket/WEB-INF/web.xml
@@ -28,13 +28,13 @@
         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
     </listener>
     <servlet>
-        <servlet-name>CXFJettyWebSocketServlet</servlet-name>
-        <display-name>CXF JettyWebSocketServlet</display-name>
-        <servlet-class>org.apache.cxf.transport.websocket.jetty.CXFJettyWebSocketServlet</servlet-class>
+        <servlet-name>CXFServlet</servlet-name>
+        <display-name>CXF Servlet</display-name>
+        <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
         <load-on-startup>1</load-on-startup>
     </servlet>
     <servlet-mapping>
-        <servlet-name>CXFJettyWebSocketServlet</servlet-name>
+        <servlet-name>CXFServlet</servlet-name>
         <url-pattern>/*</url-pattern>
     </servlet-mapping>
 </web-app>


Mime
View raw message