cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [3/3] git commit: Work toward getting Jetty9 based websocket stuff working.
Date Thu, 07 Aug 2014 18:43:01 GMT
Work toward getting Jetty9 based websocket stuff working.


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

Branch: refs/heads/master
Commit: 470bdcb40597dce5e5cf957000ab60b0b4c1fce4
Parents: a4315cb
Author: Daniel Kulp <dkulp@apache.org>
Authored: Thu Aug 7 14:42:07 2014 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Thu Aug 7 14:42:07 2014 -0400

----------------------------------------------------------------------
 parent/pom.xml                                  |  16 +-
 rt/transports/http-jetty/pom.xml                |  19 +-
 .../http_jetty/JettyHTTPDestination.java        |   2 +-
 .../JettyHTTPServerEngineFactory.java           |   5 +
 rt/transports/websocket/pom.xml                 |  42 ++-
 .../websocket/WebSocketDestinationFactory.java  |   6 +-
 .../WebSocketVirtualServletResponse.java        |   7 +-
 .../jetty9/Jetty9WebSocketDestination.java      | 283 +++++++++++++++++++
 .../websocket/jetty9/JettyWebSocketHandler.java |  59 ++++
 systests/jaxrs/pom.xml                          |  35 ++-
 .../systest/jaxrs/security/BookLoginModule.java |   6 +-
 .../systest/jaxrs/security/JettyJAASFilter.java |  12 +-
 systests/jaxws/pom.xml                          |  14 +-
 13 files changed, 477 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/470bdcb4/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 0be0cfe..8c455a7 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -864,16 +864,6 @@
                 <groupId>org.eclipse.jetty</groupId>
                 <artifactId>jetty-server</artifactId>
                 <version>${cxf.jetty.version}</version>
-                <exclusions>
-                    <exclusion>
-                        <groupId>javax.servlet</groupId>
-                        <artifactId>servlet-api</artifactId>
-                    </exclusion>
-                    <exclusion>
-                        <groupId>org.eclipse.jetty.orbit</groupId>
-                        <artifactId>javax.servlet</artifactId>
-                    </exclusion>
-                </exclusions>
             </dependency>
             <dependency>
                 <groupId>org.eclipse.jetty</groupId>
@@ -1713,6 +1703,12 @@
             </properties>
         </profile>
         <profile>
+            <id>jetty9</id>
+            <properties>
+                <cxf.jetty.version>${cxf.jetty9.version}</cxf.jetty.version>
+            </properties>
+        </profile>
+        <profile>
             <!-- Profile for testing with EclipseLink MOXy based JAXB implementation -->
             <id>eclipse.moxy</id>
             <properties>

http://git-wip-us.apache.org/repos/asf/cxf/blob/470bdcb4/rt/transports/http-jetty/pom.xml
----------------------------------------------------------------------
diff --git a/rt/transports/http-jetty/pom.xml b/rt/transports/http-jetty/pom.xml
index 0e3d1b1..8cd2204 100644
--- a/rt/transports/http-jetty/pom.xml
+++ b/rt/transports/http-jetty/pom.xml
@@ -94,6 +94,16 @@
         </dependency>
         <dependency>
             <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-util</artifactId>
+            <version>${cxf.jetty.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-io</artifactId>
+            <version>${cxf.jetty.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
             <artifactId>jetty-security</artifactId>
             <version>${cxf.jetty.version}</version>
         </dependency>
@@ -109,15 +119,16 @@
             <optional>true</optional>
         </dependency>
         <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-http</artifactId>
+            <version>${cxf.jetty.version}</version>
+        </dependency>
+        <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
             <scope>runtime</scope>
         </dependency>
         <dependency>
-            <groupId>${cxf.servlet-api.group}</groupId>
-            <artifactId>${cxf.servlet-api.artifact}</artifactId>
-        </dependency>
-        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/cxf/blob/470bdcb4/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
index eef3492..8b8f680 100644
--- a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
+++ b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
@@ -171,7 +171,7 @@ public class JettyHTTPDestination extends AbstractHTTPDestination {
         } catch (Exception e) {
             throw new Fault(e);
         }
-        // pick the handler supportig websocket if jetty-websocket is available otherwise
pick the default handler.
+        // pick the handler supporting websocket if jetty-websocket is available otherwise
pick the default handler.
         JettyHTTPHandler jhd = createJettyHTTPHandler(this, contextMatchOnExact());
         engine.addServant(url, jhd);
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/470bdcb4/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
index 85b128e..912885a 100644
--- a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
+++ b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
@@ -38,6 +38,7 @@ import org.apache.cxf.common.injection.NoJSR250Annotations;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.configuration.jsse.TLSServerParameters;
 import org.apache.cxf.management.InstrumentationManager;
+import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.util.component.Container;
 
 
@@ -125,6 +126,10 @@ public class JettyHTTPServerEngineFactory {
         }
         return ref;
     }
+    
+    public boolean isJetty8() {
+        return Server.getVersion().startsWith("8");
+    }
 
     
     /**

http://git-wip-us.apache.org/repos/asf/cxf/blob/470bdcb4/rt/transports/websocket/pom.xml
----------------------------------------------------------------------
diff --git a/rt/transports/websocket/pom.xml b/rt/transports/websocket/pom.xml
index 5654316..8d4336f 100644
--- a/rt/transports/websocket/pom.xml
+++ b/rt/transports/websocket/pom.xml
@@ -81,6 +81,16 @@
             <groupId>org.apache.cxf</groupId>
             <artifactId>cxf-rt-transports-http-jetty</artifactId>
             <version>${project.version}</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>javax.servlet</groupId>
+                    <artifactId>javax.servlet-api</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.eclipse.jetty.orbit</groupId>
+                    <artifactId>javax.servlet</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <groupId>org.springframework</groupId>
@@ -100,6 +110,16 @@
         <dependency>
             <groupId>org.eclipse.jetty</groupId>
             <artifactId>jetty-server</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>javax.servlet</groupId>
+                    <artifactId>javax.servlet-api</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.eclipse.jetty.orbit</groupId>
+                    <artifactId>javax.servlet</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <groupId>org.eclipse.jetty</groupId>
@@ -108,9 +128,8 @@
         </dependency>
         <dependency>
             <groupId>org.eclipse.jetty</groupId>
-            <artifactId>jetty-websocket</artifactId>
+            <artifactId>jetty-servlet</artifactId>
             <version>${cxf.jetty.version}</version>
-            <optional>true</optional>
         </dependency>
         <dependency>
             <groupId>org.eclipse.jetty</groupId>
@@ -118,6 +137,25 @@
             <version>${cxf.jetty.version}</version>
             <optional>true</optional>
         </dependency>
+        
+        <dependency>
+            <groupId>org.eclipse.jetty.websocket</groupId>
+            <artifactId>websocket-server</artifactId>
+            <version>${cxf.jetty9.version}</version>
+            <optional>true</optional>
+            <exclusions>
+                <exclusion>
+                    <groupId>javax.servlet</groupId>
+                    <artifactId>javax.servlet-api</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-websocket</artifactId>
+            <version>${cxf.jetty8.version}</version>
+            <optional>true</optional>
+        </dependency>
         <dependency>
             <groupId>org.atmosphere</groupId>
             <artifactId>atmosphere-runtime</artifactId>

http://git-wip-us.apache.org/repos/asf/cxf/blob/470bdcb4/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 14b5f8f..1d07a57 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
@@ -33,6 +33,7 @@ import org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory;
 import org.apache.cxf.transport.websocket.atmosphere.AtmosphereWebSocketServletDestination;
 import org.apache.cxf.transport.websocket.jetty.JettyWebSocketDestination;
 import org.apache.cxf.transport.websocket.jetty.JettyWebSocketServletDestination;
+import org.apache.cxf.transport.websocket.jetty9.Jetty9WebSocketDestination;
 
 @NoJSR250Annotations()
 public class WebSocketDestinationFactory implements HttpDestinationFactory {
@@ -53,7 +54,10 @@ public class WebSocketDestinationFactory implements HttpDestinationFactory
{
             // for the embedded mode, we stick with jetty. 
             JettyHTTPServerEngineFactory serverEngineFactory = bus
                 .getExtension(JettyHTTPServerEngineFactory.class);
-            return new JettyWebSocketDestination(bus, registry, endpointInfo, serverEngineFactory);
+            if (serverEngineFactory.isJetty8()) {
+                return new JettyWebSocketDestination(bus, registry, endpointInfo, serverEngineFactory);
+            }
+            return new Jetty9WebSocketDestination(bus, registry, endpointInfo, serverEngineFactory);
         } else {
             //REVISIT other way of getting the registry of http so that the plain cxf servlet
finds the destination?
             registry = getDestinationRegistry(bus);

http://git-wip-us.apache.org/repos/asf/cxf/blob/470bdcb4/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/WebSocketVirtualServletResponse.java
----------------------------------------------------------------------
diff --git a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/WebSocketVirtualServletResponse.java
b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/WebSocketVirtualServletResponse.java
index 5bd6e7c..07e2efb 100644
--- a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/WebSocketVirtualServletResponse.java
+++ b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/WebSocketVirtualServletResponse.java
@@ -53,6 +53,7 @@ public class WebSocketVirtualServletResponse implements HttpServletResponse
{
     @Override
     public void flushBuffer() throws IOException {
         LOG.log(Level.INFO, "flushBuffer()");
+        outputStream.flush();
     }
 
     @Override
@@ -248,6 +249,8 @@ public class WebSocketVirtualServletResponse implements HttpServletResponse
{
             LOG.log(Level.INFO, "sendError{0}", sc);
         }
         responseHeaders.put(WebSocketUtils.SC_KEY, Integer.toString(sc));
+        byte[] data = WebSocketUtils.buildResponse(responseHeaders, null, 0, 0);
+        webSocketHolder.write(data, 0, data.length);
     }
 
     @Override
@@ -257,6 +260,8 @@ public class WebSocketVirtualServletResponse implements HttpServletResponse
{
         }
         responseHeaders.put(WebSocketUtils.SC_KEY, Integer.toString(sc));
         responseHeaders.put(WebSocketUtils.SM_KEY, msg);
+        byte[] data = WebSocketUtils.buildResponse(responseHeaders, null, 0, 0);
+        webSocketHolder.write(data, 0, data.length);
     }
 
     @Override
@@ -342,8 +347,6 @@ public class WebSocketVirtualServletResponse implements HttpServletResponse
{
                     webSocketHolder.write(data, 0, data.length);
                 }
             }
-
-            @Override
             public void close() throws IOException {
                 if (responseHeaders.get(WebSocketUtils.FLUSHED_KEY) == null) {
                     byte[] data = WebSocketUtils.buildResponse(responseHeaders, buffer.getBytes(),
0, buffer.size());

http://git-wip-us.apache.org/repos/asf/cxf/blob/470bdcb4/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty9/Jetty9WebSocketDestination.java
----------------------------------------------------------------------
diff --git a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty9/Jetty9WebSocketDestination.java
b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty9/Jetty9WebSocketDestination.java
new file mode 100644
index 0000000..abdb582
--- /dev/null
+++ b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty9/Jetty9WebSocketDestination.java
@@ -0,0 +1,283 @@
+/**
+ * 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.jetty9;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URL;
+import java.nio.ByteBuffer;
+import java.security.Principal;
+import java.util.Enumeration;
+import java.util.Locale;
+import java.util.concurrent.Executor;
+
+import javax.servlet.DispatcherType;
+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.common.classloader.ClassLoaderUtils;
+import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.service.model.EndpointInfo;
+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.apache.cxf.transport.websocket.InvalidPathException;
+import org.apache.cxf.transport.websocket.WebSocketConstants;
+import org.apache.cxf.transport.websocket.WebSocketDestinationService;
+import org.apache.cxf.transport.websocket.WebSocketServletHolder;
+import org.apache.cxf.transport.websocket.WebSocketVirtualServletRequest;
+import org.apache.cxf.transport.websocket.WebSocketVirtualServletResponse;
+import org.apache.cxf.workqueue.WorkQueueManager;
+import org.eclipse.jetty.websocket.api.Session;
+import org.eclipse.jetty.websocket.api.WebSocketAdapter;
+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.WebSocketServletFactory;
+
+/**
+ * 
+ */
+public class Jetty9WebSocketDestination extends JettyHTTPDestination implements 
+    WebSocketDestinationService,  WebSocketCreator {
+
+    //REVISIT make these keys configurable
+    private String requestIdKey = WebSocketConstants.DEFAULT_REQUEST_ID_KEY;
+    private String responseIdKey = WebSocketConstants.DEFAULT_RESPONSE_ID_KEY;
+
+    private WebSocketServletFactory webSocketFactory;
+    private final Executor executor;
+
+    public Jetty9WebSocketDestination(Bus bus, DestinationRegistry registry, EndpointInfo
ei,
+                                     JettyHTTPServerEngineFactory serverEngineFactory) throws
IOException {
+        super(bus, registry, ei, serverEngineFactory);
+        try {
+            webSocketFactory = (WebSocketServletFactory)ClassLoaderUtils
+                .loadClass("org.eclipse.jetty.websocket.server.WebSocketServerFactory",
+                           WebSocketServletFactory.class).newInstance();
+        } catch (InstantiationException | IllegalAccessException | ClassNotFoundException
e) {
+            throw new RuntimeException(e);
+        }
+        webSocketFactory.setCreator(this);
+        executor = bus.getExtension(WorkQueueManager.class).getAutomaticWorkQueue();
+    }
+    
+    @Override
+    public void invokeInternal(ServletConfig config, ServletContext context, HttpServletRequest
req,
+                               HttpServletResponse resp) throws IOException {
+        super.invoke(config, context, req, resp);
+    }
+
+    @Override
+    protected String getAddress(EndpointInfo endpointInfo) {
+        String address = endpointInfo.getAddress();
+        if (address.startsWith("ws")) {
+            address = "http" + address.substring(2);
+        }
+        return address;
+    }
+
+
+    @Override
+    protected String getBasePath(String contextPath) throws IOException {
+        if (StringUtils.isEmpty(endpointInfo.getAddress())) {
+            return "";
+        }
+        return new URL(getAddress(endpointInfo)).getPath();
+    }
+    
+    @Override
+    protected JettyHTTPHandler createJettyHTTPHandler(JettyHTTPDestination jhd, boolean cmExact)
{
+        return new JettyWebSocketHandler(jhd, cmExact, webSocketFactory);
+    }
+    
+    @Override
+    public void shutdown() {
+        try {
+            webSocketFactory.cleanup();
+        } catch (Exception e) {
+            // ignore
+        } finally {
+            super.shutdown();
+        }
+    }
+    
+    @Override
+    public Object createWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp)
{
+        return new WebSocketAdapter() {
+            Session session;
+            @Override
+            public void onWebSocketConnect(Session session) {
+                this.session = session;
+            }
+            @Override
+            public void onWebSocketBinary(byte[] payload, int offset, int len) {
+                invoke(payload, offset, len, session);
+            }
+            @Override
+            public void onWebSocketText(String message) {
+                //TODO may want use string directly instead of converting it to byte[]
+                try {
+                    byte[] bdata = message.getBytes("utf-8");
+                    onWebSocketBinary(bdata, 0, bdata.length);
+                } catch (UnsupportedEncodingException e) {
+                    // TODO Auto-generated catch block
+                    e.printStackTrace();
+                }
+            }
+        };
+    }
+    private void invoke(final byte[] data, final int offset, final int length, final Session
session) {
+        // invoke the service asynchronously as the jetty websocket's onMessage is synchronously
blocked
+        // make sure the byte array passed to this method is immutable, as the websocket
framework
+        // may corrupt the byte array after this method is returned (i.e., before the data
is returned in
+        // the executor's thread.
+        executor.execute(new Runnable() {
+            @Override
+            public void run() {
+                HttpServletRequest request = null;
+                HttpServletResponse response = null;
+                try {
+                    WebSocketServletHolder holder = new Jetty9WebSocketHolder(session);
+                    response = createServletResponse(holder);
+                    request = createServletRequest(data, offset, length, holder);
+                    String reqid = request.getHeader(requestIdKey);
+                    if (reqid != null) {
+                        response.setHeader(responseIdKey, reqid);
+                    }
+                    invoke(null, null, request, response);
+                } catch (InvalidPathException ex) {
+                    ex.printStackTrace();
+                    reportErrorStatus(session, 400, response);
+                } catch (Exception e) {
+                    reportErrorStatus(session, 500, response);
+                    e.printStackTrace();
+                }
+            }
+
+        });
+    }
+    private void reportErrorStatus(Session session, int i, HttpServletResponse resp) {
+        try {
+            resp.sendError(i);
+        } catch (IOException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+    }
+    private WebSocketVirtualServletRequest createServletRequest(byte[] data, int offset,
int length,
+                                                                WebSocketServletHolder holder)

+        throws IOException {
+        return new WebSocketVirtualServletRequest(holder, new ByteArrayInputStream(data,
offset, length));
+    }
+
+    private WebSocketVirtualServletResponse createServletResponse(WebSocketServletHolder
holder) throws IOException {
+        return new WebSocketVirtualServletResponse(holder);
+    }
+    
+    class Jetty9WebSocketHolder implements WebSocketServletHolder {
+        final Session session;
+        public Jetty9WebSocketHolder(Session s) {
+            session = s;
+        }
+        public String getAuthType() {
+            return null;
+        }
+        public String getContextPath() {
+            return null;
+        }
+        public String getLocalAddr() {
+            return null;
+        }
+        public String getLocalName() {
+            return null;
+        }
+        public int getLocalPort() {
+            return 0;
+        }
+        public Locale getLocale() {
+            return null;
+        }
+        public Enumeration<Locale> getLocales() {
+            return null;
+        }
+        public String getProtocol() {
+            return null;
+        }
+        public String getRemoteAddr() {
+            return null;
+        }
+        public String getRemoteHost() {
+            return null;
+        }
+        public int getRemotePort() {
+            return 0;
+        }
+        public String getRequestURI() {
+            return session.getUpgradeRequest().getRequestURI().getPath();
+        }
+        public StringBuffer getRequestURL() {
+            return new StringBuffer(session.getUpgradeRequest().getRequestURI().toString());
+        }
+        public DispatcherType getDispatcherType() {
+            return null;
+        }
+        public boolean isSecure() {
+            return false;
+        }
+        public String getPathInfo() {
+            return session.getUpgradeRequest().getRequestURI().getPath();
+        }
+        public String getPathTranslated() {
+            return session.getUpgradeRequest().getRequestURI().getPath();
+        }
+        public String getScheme() {
+            return "ws";
+        }
+        public String getServerName() {
+            return null;
+        }
+        public String getServletPath() {
+            return "/";
+        }
+        public ServletContext getServletContext() {
+            return null;
+        }
+        public int getServerPort() {
+            return session.getLocalAddress().getPort();
+        }
+        public Principal getUserPrincipal() {
+            return null;
+        }
+        public Object getAttribute(String name) {
+            return session.getUpgradeRequest().getHeader(name);
+        }
+        @Override
+        public void write(byte[] data, int offset, int length) throws IOException {
+            session.getRemote().sendBytes(ByteBuffer.wrap(data,  offset, length));
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/470bdcb4/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty9/JettyWebSocketHandler.java
----------------------------------------------------------------------
diff --git a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty9/JettyWebSocketHandler.java
b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty9/JettyWebSocketHandler.java
new file mode 100644
index 0000000..3bb3e4a
--- /dev/null
+++ b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty9/JettyWebSocketHandler.java
@@ -0,0 +1,59 @@
+/**
+ * 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.jetty9;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+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.servlet.WebSocketServletFactory;
+
+/**
+ * The extended version of JettyHTTPHandler that can support websocket.
+ */
+class JettyWebSocketHandler extends JettyHTTPHandler { 
+    final WebSocketServletFactory webSocketFactory;
+    
+    public JettyWebSocketHandler(JettyHTTPDestination jhd, boolean cmExact, 
+                                 WebSocketServletFactory webSocketFactory) {
+        super(jhd, cmExact);
+        this.webSocketFactory = webSocketFactory;
+    }
+    
+    @Override
+    public void handle(String target, 
+                       Request baseRequest, 
+                       HttpServletRequest request, 
+                       HttpServletResponse response) 
+        throws IOException, ServletException {
+        
+        if (webSocketFactory.isUpgradeRequest(request, response)
+            && webSocketFactory.acceptWebSocket(request, response)) {
+            baseRequest.setHandled(true);
+            return;
+        }
+        super.handle(target, baseRequest, request, response);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/470bdcb4/systests/jaxrs/pom.xml
----------------------------------------------------------------------
diff --git a/systests/jaxrs/pom.xml b/systests/jaxrs/pom.xml
index e4ca906..0e4761e 100644
--- a/systests/jaxrs/pom.xml
+++ b/systests/jaxrs/pom.xml
@@ -108,6 +108,16 @@
         </dependency>
         <dependency>
             <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-io</artifactId>
+            <version>${cxf.jetty.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-security</artifactId>
+            <version>${cxf.jetty.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
             <artifactId>jetty-plus</artifactId>
             <version>${cxf.jetty.version}</version>
         </dependency>
@@ -122,11 +132,34 @@
         </dependency>
         <dependency>
             <groupId>org.eclipse.jetty</groupId>
-            <artifactId>jetty-websocket</artifactId>
+            <artifactId>jetty-util</artifactId>
             <version>${cxf.jetty.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty.websocket</groupId>
+            <artifactId>websocket-server</artifactId>
+            <version>${cxf.jetty9.version}</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>javax.servlet</groupId>
+                    <artifactId>javax.servlet-api</artifactId>
+                </exclusion>
+            </exclusions>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-websocket</artifactId>
+            <version>${cxf.jetty8.version}</version>
             <scope>test</scope>
         </dependency>
         <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-jaas</artifactId>
+            <version>${cxf.jetty9.version}</version>
+        </dependency>
+        
+        <dependency>
             <groupId>org.apache.cxf</groupId>
             <artifactId>cxf-core</artifactId>
             <version>${project.version}</version>

http://git-wip-us.apache.org/repos/asf/cxf/blob/470bdcb4/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/BookLoginModule.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/BookLoginModule.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/BookLoginModule.java
index 8f9f3ab..113a734 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/BookLoginModule.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/BookLoginModule.java
@@ -27,15 +27,13 @@ import javax.security.auth.callback.CallbackHandler;
 import javax.security.auth.login.LoginException;
 import javax.security.auth.spi.LoginModule;
 
-import org.eclipse.jetty.plus.jaas.spi.PropertyFileLoginModule;
-
 public class BookLoginModule implements LoginModule {
 
-    private PropertyFileLoginModule module;
+    private LoginModule module;
     private String fileResource;
     
     public BookLoginModule() {
-        module = new PropertyFileLoginModule();
+        module = new org.eclipse.jetty.jaas.spi.PropertyFileLoginModule();
         try {
             fileResource = getClass()
                 .getResource("/org/apache/cxf/systest/jaxrs/security/jetty-realm.properties")

http://git-wip-us.apache.org/repos/asf/cxf/blob/470bdcb4/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JettyJAASFilter.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JettyJAASFilter.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JettyJAASFilter.java
index 61f522d..64d21f6 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JettyJAASFilter.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JettyJAASFilter.java
@@ -18,20 +18,26 @@
  */
 package org.apache.cxf.systest.jaxrs.security;
 
+import java.lang.reflect.InvocationTargetException;
+
 import javax.security.auth.callback.Callback;
 import javax.security.auth.callback.CallbackHandler;
 
 import org.apache.cxf.interceptor.security.NamePasswordCallbackHandler;
 import org.apache.cxf.jaxrs.security.JAASAuthenticationFilter;
-import org.eclipse.jetty.plus.jaas.callback.ObjectCallback;
 
 public class JettyJAASFilter extends JAASAuthenticationFilter {
     @Override
     protected CallbackHandler getCallbackHandler(final String name, final String password)
{
         return new NamePasswordCallbackHandler(name, password) {
             protected boolean handleCallback(Callback c) {
-                if (c instanceof ObjectCallback) {
-                    ((ObjectCallback)c).setObject(password);
+                if ("ObjectCallback".equals(c.getClass().getSimpleName())) {
+                    try {
+                        c.getClass().getMethod("setObject", Object.class).invoke(c, password);
+                    } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
+                        | NoSuchMethodException | SecurityException e) {
+                        throw new RuntimeException(e);
+                    }
                     return true;
                 } else {
                     return false;

http://git-wip-us.apache.org/repos/asf/cxf/blob/470bdcb4/systests/jaxws/pom.xml
----------------------------------------------------------------------
diff --git a/systests/jaxws/pom.xml b/systests/jaxws/pom.xml
index 62f1bf9..7b6dc49 100644
--- a/systests/jaxws/pom.xml
+++ b/systests/jaxws/pom.xml
@@ -134,9 +134,21 @@
             <version>${project.version}</version>
         </dependency>
         <dependency>
+            <groupId>org.eclipse.jetty.websocket</groupId>
+            <artifactId>websocket-server</artifactId>
+            <version>${cxf.jetty9.version}</version>
+            <optional>true</optional>
+            <exclusions>
+                <exclusion>
+                    <groupId>javax.servlet</groupId>
+                    <artifactId>javax.servlet-api</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
             <groupId>org.eclipse.jetty</groupId>
             <artifactId>jetty-websocket</artifactId>
-            <version>${cxf.jetty.version}</version>
+            <version>${cxf.jetty8.version}</version>
             <scope>test</scope>
         </dependency>
         <dependency>


Mime
View raw message