activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cshan...@apache.org
Subject activemq git commit: https://issues.apache.org/jira/browse/AMQ-6521
Date Tue, 29 Nov 2016 16:39:28 GMT
Repository: activemq
Updated Branches:
  refs/heads/activemq-5.14.x a50979e30 -> 4cdd188ef


https://issues.apache.org/jira/browse/AMQ-6521

Adding support for Jetty 9.3 by re-adding in the logic to dynamically
load the correct GzipHandler depending on the version

(cherry picked from commit 80f46a80560b2b2ed9fb418c33df75136bc3dc52)


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

Branch: refs/heads/activemq-5.14.x
Commit: 4cdd188ef22524391d8801e865a4c9eed8c8eb06
Parents: a50979e
Author: Christopher L. Shannon (cshannon) <christopher.l.shannon@gmail.com>
Authored: Tue Nov 29 11:20:27 2016 -0500
Committer: Christopher L. Shannon (cshannon) <christopher.l.shannon@gmail.com>
Committed: Tue Nov 29 11:39:17 2016 -0500

----------------------------------------------------------------------
 .../transport/http/HttpTransportServer.java     | 26 ++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/4cdd188e/activemq-http/src/main/java/org/apache/activemq/transport/http/HttpTransportServer.java
----------------------------------------------------------------------
diff --git a/activemq-http/src/main/java/org/apache/activemq/transport/http/HttpTransportServer.java
b/activemq-http/src/main/java/org/apache/activemq/transport/http/HttpTransportServer.java
index 02bf11f..f9774f3 100755
--- a/activemq-http/src/main/java/org/apache/activemq/transport/http/HttpTransportServer.java
+++ b/activemq-http/src/main/java/org/apache/activemq/transport/http/HttpTransportServer.java
@@ -32,7 +32,6 @@ import org.eclipse.jetty.server.Handler;
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.servlet.ServletContextHandler;
 import org.eclipse.jetty.servlet.ServletHolder;
-import org.eclipse.jetty.servlets.gzip.GzipHandler;
 
 public class HttpTransportServer extends WebTransportServerSupport {
 
@@ -123,11 +122,34 @@ public class HttpTransportServer extends WebTransportServerSupport {
     private int getConnectorLocalPort() throws Exception {
         return (Integer)connector.getClass().getMethod("getLocalPort").invoke(connector);
     }
+
     private void addGzipHandler(ServletContextHandler contextHandler) throws Exception {
-        Handler handler = new GzipHandler();
+        Handler handler = null;
+        try {
+            handler = (Handler) forName("org.eclipse.jetty.server.handler.GzipHandler").newInstance();
+        } catch (Throwable t) {
+            handler = (Handler) forName("org.eclipse.jetty.servlets.gzip.GzipHandler").newInstance();
+        }
         contextHandler.setHandler(handler);
     }
 
+    private Class<?> forName(String name) throws ClassNotFoundException {
+        Class<?> clazz = null;
+        ClassLoader loader = Thread.currentThread().getContextClassLoader();
+        if (loader != null) {
+            try {
+                clazz = loader.loadClass(name);
+            } catch (ClassNotFoundException e) {
+                // ignore
+            }
+        }
+        if (clazz == null) {
+            clazz = HttpTransportServer.class.getClassLoader().loadClass(name);
+        }
+
+        return clazz;
+    }
+
     @Override
     protected void doStop(ServiceStopper stopper) throws Exception {
         Server temp = server;


Mime
View raw message