cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [1/4] cxf git commit: Update jetty session handling to support 9.4 (don't update to 9.4 due to atmosphere)
Date Wed, 15 Mar 2017 18:43:43 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes fdb31a753 -> addf51d4c


Update jetty session handling to support 9.4 (don't update to 9.4 due to atmosphere)

# Conflicts:
#	parent/pom.xml
#	rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java


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

Branch: refs/heads/3.1.x-fixes
Commit: 549a10c78ec602ce19ae965aee504a1d91fd3f93
Parents: fdb31a7
Author: Daniel Kulp <dkulp@apache.org>
Authored: Wed Mar 8 13:32:36 2017 -0500
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Wed Mar 15 14:03:04 2017 -0400

----------------------------------------------------------------------
 parent/pom.xml                                  |  5 ++-
 .../http_jetty/JettyHTTPServerEngine.java       | 38 +++++++++++++-------
 2 files changed, 30 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/549a10c7/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 692e15c..7ef8437 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -121,8 +121,11 @@
         <cxf.jettison.version>1.3.8</cxf.jettison.version>
         <cxf.jetty8.version>8.1.19.v20160209</cxf.jetty8.version>
         <cxf.jetty9.version>9.2.21.v20170120</cxf.jetty9.version>
+        <!-- Jetty 9.3.15+ and 9.4.x break atmosphere, don't upgrade until new version
of
+             atmosphere is available -->
+        <!--cxf.jetty9.version>9.3.16.v20170120</cxf.jetty9.version-->
         <cxf.jetty.version>${cxf.jetty9.version}</cxf.jetty.version>
-        <cxf.jetty.osgi.version>[8.1,9.4)</cxf.jetty.osgi.version>
+        <cxf.jetty.osgi.version>[8.1,9.5)</cxf.jetty.osgi.version>
         <cxf.jibx.version>1.2.6</cxf.jibx.version>
         <cxf.junit.version>4.12</cxf.junit.version>
         <cxf.hamcrest.version>1.3</cxf.hamcrest.version>

http://git-wip-us.apache.org/repos/asf/cxf/blob/549a10c7/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
index 3fa8607..4afcaf5 100644
--- a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
+++ b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
@@ -22,6 +22,7 @@ package org.apache.cxf.transport.http_jetty;
 import java.io.Closeable;
 import java.io.IOException;
 import java.io.Writer;
+import java.lang.reflect.Method;
 import java.net.URL;
 import java.security.GeneralSecurityException;
 import java.util.ArrayList;
@@ -44,6 +45,7 @@ import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.PropertyUtils;
+import org.apache.cxf.common.util.ReflectionUtil;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.common.util.SystemPropertyAction;
 import org.apache.cxf.configuration.jsse.SSLUtils;
@@ -59,14 +61,11 @@ import org.eclipse.jetty.server.Handler;
 import org.eclipse.jetty.server.Request;
 import org.eclipse.jetty.server.Response;
 import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.server.SessionManager;
 import org.eclipse.jetty.server.handler.ContextHandler;
 import org.eclipse.jetty.server.handler.ContextHandlerCollection;
 import org.eclipse.jetty.server.handler.DefaultHandler;
 import org.eclipse.jetty.server.handler.ErrorHandler;
 import org.eclipse.jetty.server.handler.HandlerCollection;
-import org.eclipse.jetty.server.session.HashSessionIdManager;
-import org.eclipse.jetty.server.session.HashSessionManager;
 import org.eclipse.jetty.server.session.SessionHandler;
 import org.eclipse.jetty.util.component.Container;
 import org.eclipse.jetty.util.ssl.SslContextFactory;
@@ -112,7 +111,7 @@ public class JettyHTTPServerEngine implements ServerEngine {
     private List<Handler> handlers;
     private ContextHandlerCollection contexts;
     private Container.Listener mBeanContainer;
-    private SessionManager sessionManager;
+    private SessionHandler sessionHandler;
     private ThreadPool threadPool;
     
     
@@ -496,19 +495,34 @@ public class JettyHTTPServerEngine implements ServerEngine {
         // bind the jetty http handler with the context handler
         if (isSessionSupport) {         
             // If we have sessions, we need two handlers.
-            if (sessionManager == null) {
-                sessionManager = new HashSessionManager();
-                HashSessionIdManager idManager = new HashSessionIdManager();
-                sessionManager.setSessionIdManager(idManager);
+            SessionHandler sh = null;
+            if (Server.getVersion().startsWith("9.2") 
+                || Server.getVersion().startsWith("9.3")) {
+                if (sessionHandler == null) {
+                    sessionHandler = new SessionHandler();
+                }
+                sh = new SessionHandler();
+                try {
+                    Method get = ReflectionUtil.getDeclaredMethod(SessionHandler.class, "getSessionManager");
+                    Method set = ReflectionUtil.getDeclaredMethod(SessionHandler.class, 
+                                                                  "setSessionManager", 
+                                                                  get.getReturnType());
+                    ReflectionUtil.setAccessible(set)
+                        .invoke(sh, ReflectionUtil.setAccessible(get).invoke(sessionHandler));
+                } catch (Throwable t) {
+                    //ignore, just use the new session manager
+                }
+            } else {
+                //9.4+ stores the session id handling and cache and everything on the server,
just need the handler
+                sh = new SessionHandler();
             }
-            SessionHandler sessionHandler = new SessionHandler(sessionManager);
             if (securityHandler != null) {
                 //use the securityHander which already wrap the jetty http handler
-                sessionHandler.setHandler(securityHandler);
+                sh.setHandler(securityHandler);
             } else {
-                sessionHandler.setHandler(handler);
+                sh.setHandler(handler);
             }
-            context.setHandler(sessionHandler);
+            context.setHandler(sh);
         } else {
             // otherwise, just the one.
             if (securityHandler != null) {


Mime
View raw message