mirror of https://github.com/apache/activemq.git
Adding support for Jetty 9.3 by re-adding in the logic to dynamically load the correct GzipHandler depending on the version
This commit is contained in:
parent
4e766d92c5
commit
80f46a8056
|
@ -32,7 +32,6 @@ import org.eclipse.jetty.server.Handler;
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||||
import org.eclipse.jetty.servlet.ServletHolder;
|
import org.eclipse.jetty.servlet.ServletHolder;
|
||||||
import org.eclipse.jetty.servlets.gzip.GzipHandler;
|
|
||||||
|
|
||||||
public class HttpTransportServer extends WebTransportServerSupport {
|
public class HttpTransportServer extends WebTransportServerSupport {
|
||||||
|
|
||||||
|
@ -123,11 +122,34 @@ public class HttpTransportServer extends WebTransportServerSupport {
|
||||||
private int getConnectorLocalPort() throws Exception {
|
private int getConnectorLocalPort() throws Exception {
|
||||||
return (Integer)connector.getClass().getMethod("getLocalPort").invoke(connector);
|
return (Integer)connector.getClass().getMethod("getLocalPort").invoke(connector);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addGzipHandler(ServletContextHandler contextHandler) throws Exception {
|
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);
|
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
|
@Override
|
||||||
protected void doStop(ServiceStopper stopper) throws Exception {
|
protected void doStop(ServiceStopper stopper) throws Exception {
|
||||||
Server temp = server;
|
Server temp = server;
|
||||||
|
|
Loading…
Reference in New Issue