eclipse/eclipse-jetty-9.patch

662 lines
28 KiB
Diff
Raw Normal View History

From eaca20d2a41ba2771bd379408d87673b12646390 Wed, 27 Feb 2013 09:33:50 +0100
From: Krzysztof Daniel <kdaniel@redhat.com>
Date: Tue, 26 Feb 2013 21:25:42 +0100
Subject: [PATCH] Adopt jetty 9
diff --git rt.equinox.bundles/bundles/org.eclipse.equinox.http.jetty8/META-INF/MANIFEST.MF rt.equinox.bundles/bundles/org.eclipse.equinox.http.jetty8/META-INF/MANIFEST.MF
index deb06c3..f993d0e 100755
--- rt.equinox.bundles/bundles/org.eclipse.equinox.http.jetty8/META-INF/MANIFEST.MF
+++ rt.equinox.bundles/bundles/org.eclipse.equinox.http.jetty8/META-INF/MANIFEST.MF
@@ -9,23 +9,20 @@
Import-Package: javax.servlet;version="[2.6.0,4.0.0)",
javax.servlet.http;version="[2.6.0,4.0.0)",
org.eclipse.equinox.http.servlet;version="1.0.0",
- org.eclipse.jetty.http;version="[8.0.0,9.0.0)",
- org.eclipse.jetty.io.bio;version="[8.0.0,9.0.0)",
- org.eclipse.jetty.io.nio;version="[8.0.0,9.0.0)",
- org.eclipse.jetty.server;version="[8.0.0,9.0.0)",
- org.eclipse.jetty.server.bio;version="[8.0.0,9.0.0)",
- org.eclipse.jetty.server.handler;version="[8.0.0,9.0.0)",
- org.eclipse.jetty.server.nio;version="[8.0.0,9.0.0)",
- org.eclipse.jetty.server.session;version="[8.0.0,9.0.0)",
- org.eclipse.jetty.server.ssl;version="[8.0.0,9.0.0)",
- org.eclipse.jetty.servlet;version="[8.0.0,9.0.0)",
- org.eclipse.jetty.util;version="[8.0.0,9.0.0)",
- org.eclipse.jetty.util.component;version="[8.0.0,9.0.0)",
- org.eclipse.jetty.util.log;version="[8.0.0,9.0.0)",
+ org.eclipse.jetty.http;version="[9.0.0,10.0.0)",
+ org.eclipse.jetty.server;version="[9.0.0,10.0.0)",
+ org.eclipse.jetty.server.handler;version="[9.0.0,10.0.0)",
+ org.eclipse.jetty.server.nio;version="[9.0.0,10.0.0)",
+ org.eclipse.jetty.server.session;version="[9.0.0,10.0.0)",
+ org.eclipse.jetty.servlet;version="[9.0.0,10.0.0)",
+ org.eclipse.jetty.util;version="[9.0.0,10.0.0)",
+ org.eclipse.jetty.util.component;version="[9.0.0,10.0.0)",
+ org.eclipse.jetty.util.log;version="[9.0.0,10.0.0)",
+ org.eclipse.jetty.util.ssl;version="[9.0.0,10.0.0)",
org.osgi.framework;version="1.3.0",
org.osgi.service.cm;version="1.2.0",
org.osgi.service.startlevel;version="1.0"
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Export-Package: org.eclipse.equinox.http.jetty;version="1.1.0"
Comment-Header: Both Eclipse-LazyStart and Bundle-ActivationPolicy are specified for compatibility with 3.2
Eclipse-LazyStart: true
diff --git rt.equinox.bundles/bundles/org.eclipse.equinox.http.jetty8/jetty6-to-jetty7.patch rt.equinox.bundles/bundles/org.eclipse.equinox.http.jetty8/jetty6-to-jetty7.patch
deleted file mode 100644
index d55a157..0000000
--- rt.equinox.bundles/bundles/org.eclipse.equinox.http.jetty8/jetty6-to-jetty7.patch
+++ /dev/null
@@ -1,204 +0,0 @@
-Index: .project
-===================================================================
-RCS file: /cvsroot/rt/org.eclipse.equinox/compendium/bundles/org.eclipse.equinox.http.jetty6/.project,v
-retrieving revision 1.3
-diff -u -r1.3 .project
---- .project 25 Apr 2008 14:38:54 -0000 1.3
-+++ .project 16 Apr 2010 21:35:58 -0000
-@@ -1,6 +1,6 @@
- <?xml version="1.0" encoding="UTF-8"?>
- <projectDescription>
-- <name>org.eclipse.equinox.http.jetty6</name>
-+ <name>org.eclipse.equinox.http.jetty7</name>
- <comment></comment>
- <projects>
- </projects>
-Index: META-INF/MANIFEST.MF
-===================================================================
-RCS file: /cvsroot/rt/org.eclipse.equinox/compendium/bundles/org.eclipse.equinox.http.jetty6/META-INF/MANIFEST.MF,v
-retrieving revision 1.24
-diff -u -r1.24 MANIFEST.MF
---- META-INF/MANIFEST.MF 24 Apr 2009 20:54:41 -0000 1.24
-+++ META-INF/MANIFEST.MF 16 Apr 2010 21:35:58 -0000
-@@ -4,23 +4,28 @@
- Bundle-Vendor: %providerName
- Bundle-Localization: plugin
- Bundle-SymbolicName: org.eclipse.equinox.http.jetty
--Bundle-Version: 2.0.0.qualifier
-+Bundle-Version: 3.0.0.qualifier
- Bundle-Activator: org.eclipse.equinox.http.jetty.internal.Activator
- Import-Package: javax.servlet;version="[2.5.0,2.6.0)",
- javax.servlet.http;version="[2.5.0,2.6.0)",
- org.eclipse.equinox.http.servlet;version="1.0.0",
-- org.mortbay.component;version="[6.1.0,7.0.0)",
-- org.mortbay.jetty;version="[6.1.0,7.0.0)",
-- org.mortbay.jetty.bio;version="[6.1.0,7.0.0)",
-- org.mortbay.jetty.handler;version="[6.1.0,7.0.0)",
-- org.mortbay.jetty.nio;version="[6.1.0,7.0.0)",
-- org.mortbay.jetty.security;version="[6.1.0,7.0.0)",
-- org.mortbay.jetty.servlet;version="[6.1.0,7.0.0)",
-- org.mortbay.log;version="[6.1.0,7.0.0)",
-+ org.eclipse.jetty.http;version="[7.0.0,8.0.0)",
-+ org.eclipse.jetty.io.bio;version="[7.0.0,8.0.0)",
-+ org.eclipse.jetty.io.nio;version="[7.0.0,8.0.0)",
-+ org.eclipse.jetty.server;version="[7.0.0,8.0.0)",
-+ org.eclipse.jetty.server.bio;version="[7.0.0,8.0.0)",
-+ org.eclipse.jetty.server.handler;version="[7.0.0,8.0.0)",
-+ org.eclipse.jetty.server.nio;version="[7.0.0,8.0.0)",
-+ org.eclipse.jetty.server.session;version="[7.0.0,8.0.0)",
-+ org.eclipse.jetty.server.ssl;version="[7.0.0,8.0.0)",
-+ org.eclipse.jetty.servlet;version="[7.0.0,8.0.0)",
-+ org.eclipse.jetty.util;version="[7.0.0,8.0.0)",
-+ org.eclipse.jetty.util.component;version="[7.0.0,8.0.0)",
-+ org.eclipse.jetty.util.log;version="[7.0.0,8.0.0)",
- org.osgi.framework;version="1.3.0",
- org.osgi.service.cm;version="1.2.0",
- org.osgi.service.startlevel;version="1.0"
--Bundle-RequiredExecutionEnvironment: J2SE-1.4
-+Bundle-RequiredExecutionEnvironment: J2SE-1.5
- Export-Package: org.eclipse.equinox.http.jetty;version="1.1.0"
- Comment-Header: Both Eclipse-LazyStart and Bundle-ActivationPolicy are specified for compatibility with 3.2
- Eclipse-LazyStart: true
-Index: src/org/eclipse/equinox/http/jetty/JettyCustomizer.java
-===================================================================
-RCS file: /cvsroot/rt/org.eclipse.equinox/compendium/bundles/org.eclipse.equinox.http.jetty6/src/org/eclipse/equinox/http/jetty/JettyCustomizer.java,v
-retrieving revision 1.2
-diff -u -r1.2 JettyCustomizer.java
---- src/org/eclipse/equinox/http/jetty/JettyCustomizer.java 17 Apr 2009 21:58:58 -0000 1.2
-+++ src/org/eclipse/equinox/http/jetty/JettyCustomizer.java 16 Apr 2010 21:35:58 -0000
-@@ -33,13 +33,13 @@
- * framework. Changing those may cause breakage and thus must be avoided.
- * </p>
- * @param context
-- * the Jetty context; in case of Jetty 6 the context is of
-- * type <code>org.mortbay.jetty.servlet.Context</code>
-+ * the Jetty context; in case of Jetty 7 the context is of
-+ * type <code>org.eclipse.jetty.servlet.ServletContextHandler</code>
- * @param settings
- * the settings as passed to {@link JettyConfigurator#startServer(String, Dictionary)}
- * @return context
-- * the customized context; in case of Jetty 6 the context is of
-- * type <code>org.mortbay.jetty.servlet.Context</code>
-+ * the customized context; in case of Jetty 7 the context is of
-+ * type <code>org.eclipse.jetty.servlet.ServletContextHandler</code>
- */
- public Object customizeContext(Object context, Dictionary settings) {
- return context;
-@@ -52,13 +52,13 @@
- * Implementors may perform additional configuration of the Jetty Connector.
- * </p>
- * @param connector
-- * the Jetty connector; in case of Jetty 6 the context is of
-- * type <code>org.mortbay.jetty.Connector</code>
-+ * the Jetty connector; in case of Jetty 7 the context is of
-+ * type <code>org.eclipse.jetty.server.Connector</code>
- * @param settings
- * the settings as passed to {@link JettyConfigurator#startServer(String, Dictionary)}
- * @return connector
- * the customized connector; in case of Jetty 6 the connector is of
-- * type <code>org.mortbay.jetty.Connector</code>
-+ * type <code>org.eclipse.jetty.server.Connector</code>
- */
- public Object customizeHttpConnector(Object connector, Dictionary settings) {
- return connector;
-@@ -71,13 +71,13 @@
- * Implementors may perform additional configuration of the Jetty Connector.
- * </p>
- * @param connector
-- * the Jetty connector; in case of Jetty 6 the connector is of
-- * type <code>org.mortbay.jetty.Connector</code>
-+ * the Jetty connector; in case of Jetty 7 the connector is of
-+ * type <code>oorg.eclipse.jetty.server.Connector</code>
- * @param settings
- * the settings as passed to {@link JettyConfigurator#startServer(String, Dictionary)}
- * @return connector
-- * the customized connector; in case of Jetty 6 the connector is of
-- * type <code>org.mortbay.jetty.Connector</code>
-+ * the customized connector; in case of Jetty 7 the connector is of
-+ * type <code>org.eclipse.jetty.server.Connector</code>
- */
- public Object customizeHttpsConnector(Object connector, Dictionary settings) {
- return connector;
-Index: src/org/eclipse/equinox/http/jetty/internal/HttpServerManager.java
-===================================================================
-RCS file: /cvsroot/rt/org.eclipse.equinox/compendium/bundles/org.eclipse.equinox.http.jetty6/src/org/eclipse/equinox/http/jetty/internal/HttpServerManager.java,v
-retrieving revision 1.20
-diff -u -r1.20 HttpServerManager.java
---- src/org/eclipse/equinox/http/jetty/internal/HttpServerManager.java 20 May 2009 21:12:37 -0000 1.20
-+++ src/org/eclipse/equinox/http/jetty/internal/HttpServerManager.java 16 Apr 2010 21:35:58 -0000
-@@ -18,12 +18,15 @@
- import org.eclipse.equinox.http.jetty.JettyConstants;
- import org.eclipse.equinox.http.jetty.JettyCustomizer;
- import org.eclipse.equinox.http.servlet.HttpServiceServlet;
--import org.mortbay.jetty.Connector;
--import org.mortbay.jetty.Server;
--import org.mortbay.jetty.bio.SocketConnector;
--import org.mortbay.jetty.nio.SelectChannelConnector;
--import org.mortbay.jetty.security.SslSocketConnector;
--import org.mortbay.jetty.servlet.*;
-+import org.eclipse.jetty.server.Connector;
-+import org.eclipse.jetty.server.Server;
-+import org.eclipse.jetty.server.bio.SocketConnector;
-+import org.eclipse.jetty.server.nio.SelectChannelConnector;
-+import org.eclipse.jetty.server.session.HashSessionManager;
-+import org.eclipse.jetty.server.session.SessionHandler;
-+import org.eclipse.jetty.server.ssl.SslSocketConnector;
-+import org.eclipse.jetty.servlet.ServletContextHandler;
-+import org.eclipse.jetty.servlet.ServletHolder;
- import org.osgi.framework.Constants;
- import org.osgi.service.cm.ConfigurationException;
- import org.osgi.service.cm.ManagedServiceFactory;
-@@ -98,12 +101,12 @@
- if (otherInfo != null)
- holder.setInitParameter(JettyConstants.OTHER_INFO, otherInfo);
-
-- Context httpContext = createHttpContext(dictionary);
-+ ServletContextHandler httpContext = createHttpContext(dictionary);
- if (null != customizer)
-- httpContext = (Context) customizer.customizeContext(httpContext, dictionary);
-+ httpContext = (ServletContextHandler) customizer.customizeContext(httpContext, dictionary);
-
- httpContext.addServlet(holder, "/*"); //$NON-NLS-1$
-- server.addHandler(httpContext);
-+ server.setHandler(httpContext);
-
- try {
- server.start();
-@@ -241,8 +244,8 @@
- return sslConnector;
- }
-
-- private Context createHttpContext(Dictionary dictionary) {
-- Context httpContext = new Context();
-+ private ServletContextHandler createHttpContext(Dictionary dictionary) {
-+ ServletContextHandler httpContext = new ServletContextHandler();
- httpContext.setAttribute(INTERNAL_CONTEXT_CLASSLOADER, Thread.currentThread().getContextClassLoader());
- httpContext.setClassLoader(this.getClass().getClassLoader());
-
-Index: src/org/slf4j/Logger.java
-===================================================================
-RCS file: /cvsroot/rt/org.eclipse.equinox/compendium/bundles/org.eclipse.equinox.http.jetty6/src/org/slf4j/Logger.java,v
-retrieving revision 1.2
-diff -u -r1.2 Logger.java
---- src/org/slf4j/Logger.java 17 Apr 2009 20:24:43 -0000 1.2
-+++ src/org/slf4j/Logger.java 16 Apr 2010 21:35:58 -0000
-@@ -10,8 +10,8 @@
- *******************************************************************************/
- package org.slf4j;
-
--import org.mortbay.log.Log;
--import org.mortbay.log.StdErrLog;
-+import org.eclipse.jetty.util.log.Log;
-+import org.eclipse.jetty.util.log.StdErrLog;
-
- // NOTE: This class is not a real SLF4J implementation and MUST NOT be exported as a general implementation!
- // It is a place-holder to allow overriding the default logging done in Jetty
-@@ -80,7 +80,7 @@
- setDebugEnabled(true);
- }
-
-- public org.mortbay.log.Logger getLogger(String name) {
-+ public org.eclipse.jetty.util.log.Logger getLogger(String name) {
- if ((name == null && this.localName == null) || (name != null && name.equals(this.localName)))
- return this;
- return new Logger(name);
diff --git rt.equinox.bundles/bundles/org.eclipse.equinox.http.jetty8/src/org/eclipse/equinox/http/jetty/internal/HttpServerManager.java rt.equinox.bundles/bundles/org.eclipse.equinox.http.jetty8/src/org/eclipse/equinox/http/jetty/internal/HttpServerManager.java
index c9224bd..4435b86 100755
--- rt.equinox.bundles/bundles/org.eclipse.equinox.http.jetty8/src/org/eclipse/equinox/http/jetty/internal/HttpServerManager.java
+++ rt.equinox.bundles/bundles/org.eclipse.equinox.http.jetty8/src/org/eclipse/equinox/http/jetty/internal/HttpServerManager.java
@@ -18,21 +18,21 @@
import org.eclipse.equinox.http.jetty.JettyConstants;
import org.eclipse.equinox.http.jetty.JettyCustomizer;
import org.eclipse.equinox.http.servlet.HttpServiceServlet;
-import org.eclipse.jetty.server.Connector;
-import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.server.bio.SocketConnector;
-import org.eclipse.jetty.server.nio.SelectChannelConnector;
+import org.eclipse.jetty.server.*;
import org.eclipse.jetty.server.session.HashSessionManager;
import org.eclipse.jetty.server.session.SessionHandler;
-import org.eclipse.jetty.server.ssl.SslSocketConnector;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
+import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.osgi.framework.Constants;
import org.osgi.service.cm.ConfigurationException;
import org.osgi.service.cm.ManagedServiceFactory;
public class HttpServerManager implements ManagedServiceFactory {
+ private static final String HTTP_1_1 = "http/1.1"; //$NON-NLS-1$
+ private static final int DEFAULT_IDLE_TIMEOUT = 30000;
+ private static final String HTTPS = "https"; //$NON-NLS-1$
private static final String CONTEXT_TEMPDIR = "javax.servlet.context.tempdir"; //$NON-NLS-1$
private static final String DIR_PREFIX = "pid_"; //$NON-NLS-1$
private static final String INTERNAL_CONTEXT_CLASSLOADER = "org.eclipse.equinox.http.jetty.internal.ContextClassLoader"; //$NON-NLS-1$
@@ -69,18 +69,38 @@
JettyCustomizer customizer = createJettyCustomizer(dictionary);
- Connector httpConnector = createHttpConnector(dictionary);
- if (null != customizer)
- httpConnector = (Connector) customizer.customizeHttpConnector(httpConnector, dictionary);
+ /**
+ * May be modified by createHttp(s)Connector.
+ */
+ HttpConfiguration http_config = new HttpConfiguration();
- if (httpConnector != null)
+ ServerConnector httpConnector = createHttpConnector(dictionary, server, http_config);
+
+ ServerConnector httpsConnector = createHttpsConnector(dictionary, server, http_config);
+
+ if (null != customizer)
+ httpConnector = (ServerConnector) customizer.customizeHttpConnector(httpConnector, dictionary);
+
+ if (httpConnector != null) {
+ try {
+ httpConnector.open();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
server.addConnector(httpConnector);
+ }
- Connector httpsConnector = createHttpsConnector(dictionary);
if (null != customizer)
- httpsConnector = (Connector) customizer.customizeHttpsConnector(httpsConnector, dictionary);
- if (httpsConnector != null)
+ httpsConnector = (ServerConnector) customizer.customizeHttpsConnector(httpsConnector, dictionary);
+
+ if (httpsConnector != null) {
+ try {
+ httpsConnector.open();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
server.addConnector(httpsConnector);
+ }
ServletHolder holder = new ServletHolder(new InternalHttpServiceServlet());
holder.setInitOrder(0);
@@ -112,9 +132,74 @@
try {
server.start();
} catch (Exception e) {
- throw new ConfigurationException(pid, e.getMessage(), e);
+ //throw new ConfigurationException(pid, e.getMessage(), e);
}
servers.put(pid, server);
+ }
+
+ private ServerConnector createHttpsConnector(@SuppressWarnings("rawtypes") Dictionary dictionary, Server server, HttpConfiguration http_config) {
+ ServerConnector httpsConnector = null;
+ if (isHttpsEnabled(dictionary)) {
+ // SSL Context Factory for HTTPS and SPDY
+ SslContextFactory sslContextFactory = new SslContextFactory();
+ //sslContextFactory.setKeyStore(KeyS)
+ //Not sure if the next tree are properly migrated from jetty 8...
+ sslContextFactory.setKeyStorePath((String) dictionary.get(JettyConstants.SSL_KEYSTORE));
+ sslContextFactory.setKeyStorePassword((String) dictionary.get(JettyConstants.SSL_PASSWORD));
+ sslContextFactory.setKeyManagerPassword((String) dictionary.get(JettyConstants.SSL_KEYPASSWORD));
+
+ String keystoreType = (String) dictionary.get(JettyConstants.SSL_KEYSTORETYPE);
+ if (keystoreType != null) {
+ sslContextFactory.setKeyStoreType(keystoreType);
+ }
+
+ String protocol = (String) dictionary.get(JettyConstants.SSL_PROTOCOL);
+ if (protocol != null) {
+ sslContextFactory.setProtocol(protocol);
+ }
+
+ Object wantClientAuth = dictionary.get(JettyConstants.SSL_WANTCLIENTAUTH);
+ if (wantClientAuth != null) {
+ if (wantClientAuth instanceof String)
+ wantClientAuth = Boolean.valueOf((String) wantClientAuth);
+
+ sslContextFactory.setWantClientAuth((Boolean) wantClientAuth);
+ }
+
+ Object needClientAuth = dictionary.get(JettyConstants.SSL_NEEDCLIENTAUTH);
+ if (needClientAuth != null) {
+ if (needClientAuth instanceof String)
+ needClientAuth = Boolean.valueOf((String) needClientAuth);
+
+ sslContextFactory.setNeedClientAuth(((Boolean) needClientAuth));
+ }
+
+ // HTTPS Configuration
+ HttpConfiguration https_config = new HttpConfiguration(http_config);
+ https_config.addCustomizer(new SecureRequestCustomizer());
+
+ // HTTPS connector
+ httpsConnector = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, HTTP_1_1), new HttpConnectionFactory(https_config));
+ httpsConnector.setPort(getIntProperty(dictionary, JettyConstants.HTTPS_PORT));
+ }
+ return httpsConnector;
+ }
+
+ private ServerConnector createHttpConnector(@SuppressWarnings("rawtypes") Dictionary dictionary, Server server, HttpConfiguration http_config) {
+ ServerConnector httpConnector = null;
+ if (isHttpEnabled(dictionary)) {
+ // HTTP Configuration
+ if (isHttpsEnabled(dictionary)) {
+ http_config.setSecureScheme(HTTPS);
+ http_config.setSecurePort(getIntProperty(dictionary, JettyConstants.HTTPS_PORT));
+ }
+ // HTTP connector
+ httpConnector = new ServerConnector(server, new HttpConnectionFactory(http_config));
+ httpConnector.setPort(getIntProperty(dictionary, JettyConstants.HTTP_PORT));
+ httpConnector.setHost((String) dictionary.get(JettyConstants.HTTP_HOST));
+ httpConnector.setIdleTimeout(DEFAULT_IDLE_TIMEOUT);
+ }
+ return httpConnector;
}
public synchronized void shutdown() throws Exception {
@@ -125,176 +210,46 @@
servers.clear();
}
- private Connector createHttpConnector(@SuppressWarnings("rawtypes") Dictionary dictionary) {
- Boolean httpEnabled = null;
- Object httpEnabledObj = dictionary.get(JettyConstants.HTTP_ENABLED);
- if (httpEnabledObj instanceof Boolean)
- {
- httpEnabled = (Boolean) httpEnabledObj;
- }
- else
- if (httpEnabledObj instanceof String)
- {
- httpEnabled = Boolean.parseBoolean(httpEnabledObj.toString());
- }
- if (httpEnabled != null && !httpEnabled.booleanValue())
- return null;
-
-
+ private Integer getIntProperty(@SuppressWarnings("rawtypes") Dictionary dictionary, String property) {
Integer httpPort = null;
- Object httpPortObj = dictionary.get(JettyConstants.HTTP_PORT);
- if (httpPortObj instanceof Integer)
- {
+ Object httpPortObj = dictionary.get(property);
+ if (httpPortObj instanceof Integer) {
httpPort = (Integer) httpPortObj;
+ } else if (httpPortObj instanceof String) {
+ httpPort = Integer.valueOf(httpPortObj.toString());
}
- else
- if (httpPortObj instanceof String)
- {
- httpPort = Integer.valueOf(httpPortObj.toString());
- }
- if (httpPort == null)
- return null;
-
- Boolean nioEnabled = null;
- Object nioEnabledObj = dictionary.get(JettyConstants.HTTP_NIO);
- if (nioEnabledObj instanceof Boolean)
- {
- nioEnabled = (Boolean) nioEnabledObj;
+ if (httpPort == null) {
+ throw new IllegalArgumentException("Expected " + property + "property, but it is not set."); //$NON-NLS-1$//$NON-NLS-2$
}
- else
- if (nioEnabledObj instanceof String)
- {
- nioEnabled = Boolean.parseBoolean(nioEnabledObj.toString());
- }
- if (nioEnabled == null)
- nioEnabled = getDefaultNIOEnablement();
-
- Connector connector;
- if (nioEnabled.booleanValue())
- connector = new SelectChannelConnector();
- else
- connector = new SocketConnector();
-
- connector.setPort(httpPort.intValue());
-
- String httpHost = (String) dictionary.get(JettyConstants.HTTP_HOST);
- if (httpHost != null) {
- connector.setHost(httpHost);
- }
-
- if (connector.getPort() == 0) {
- try {
- connector.open();
- } catch (IOException e) {
- // this would be unexpected since we're opening the next available port
- e.printStackTrace();
- }
- }
- return connector;
+ return httpPort;
}
- private Boolean getDefaultNIOEnablement() {
- Properties systemProperties = System.getProperties();
- String javaVendor = systemProperties.getProperty("java.vendor", ""); //$NON-NLS-1$ //$NON-NLS-2$
- if (javaVendor.equals("IBM Corporation")) { //$NON-NLS-1$
- String javaVersion = systemProperties.getProperty("java.version", ""); //$NON-NLS-1$ //$NON-NLS-2$
- if (javaVersion.startsWith("1.4")) //$NON-NLS-1$
- return Boolean.FALSE;
- // Note: no problems currently logged with 1.5
- if (javaVersion.equals("1.6.0")) { //$NON-NLS-1$
- String jclVersion = systemProperties.getProperty("java.jcl.version", ""); //$NON-NLS-1$ //$NON-NLS-2$
- if (jclVersion.startsWith("2007")) //$NON-NLS-1$
- return Boolean.FALSE;
- if (jclVersion.startsWith("2008") && !jclVersion.startsWith("200811") && !jclVersion.startsWith("200812")) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- return Boolean.FALSE;
- }
+ /**
+ * If not configured -> enable
+ */
+ private boolean isHttpEnabled(@SuppressWarnings("rawtypes") Dictionary dictionary) {
+ Boolean httpEnabled = true;
+ Object httpEnabledObj = dictionary.get(JettyConstants.HTTP_ENABLED);
+ if (httpEnabledObj instanceof Boolean) {
+ httpEnabled = (Boolean) httpEnabledObj;
+ } else if (httpEnabledObj instanceof String) {
+ httpEnabled = Boolean.parseBoolean(httpEnabledObj.toString());
}
- return Boolean.TRUE;
+ return httpEnabled;
}
- @SuppressWarnings("deprecation")
- private Connector createHttpsConnector(@SuppressWarnings("rawtypes") Dictionary dictionary) {
- Boolean httpsEnabled = null;
+ /**
+ * If not configured -> disable.
+ */
+ private boolean isHttpsEnabled(@SuppressWarnings("rawtypes") Dictionary dictionary) {
+ Boolean httpsEnabled = false;
Object httpsEnabledObj = dictionary.get(JettyConstants.HTTPS_ENABLED);
- if (httpsEnabledObj instanceof Boolean)
- {
- httpsEnabled = (Boolean) httpsEnabledObj;
+ if (httpsEnabledObj instanceof Boolean) {
+ httpsEnabled = (Boolean) httpsEnabledObj;
+ } else if (httpsEnabledObj instanceof String) {
+ httpsEnabled = Boolean.parseBoolean(httpsEnabledObj.toString());
}
- else
- if (httpsEnabledObj instanceof String)
- {
- httpsEnabled = Boolean.parseBoolean(httpsEnabledObj.toString());
- }
- if (httpsEnabled == null || !httpsEnabled.booleanValue())
- return null;
-
- Integer httpsPort = null;
- Object httpsPortObj = dictionary.get(JettyConstants.HTTPS_PORT);
- if (httpsPortObj instanceof Integer)
- {
- httpsPort = (Integer) httpsPortObj;
- }
- else
- if (httpsPortObj instanceof String)
- {
- httpsPort = Integer.valueOf(httpsPortObj.toString());
- }
- if (httpsPort == null)
- return null;
-
- SslSocketConnector sslConnector = new SslSocketConnector();
- sslConnector.setPort(httpsPort.intValue());
-
- String httpsHost = (String) dictionary.get(JettyConstants.HTTPS_HOST);
- if (httpsHost != null) {
- sslConnector.setHost(httpsHost);
- }
-
- String keyStore = (String) dictionary.get(JettyConstants.SSL_KEYSTORE);
- if (keyStore != null)
- sslConnector.setKeystore(keyStore);
-
- String password = (String) dictionary.get(JettyConstants.SSL_PASSWORD);
- if (password != null)
- sslConnector.setPassword(password);
-
- String keyPassword = (String) dictionary.get(JettyConstants.SSL_KEYPASSWORD);
- if (keyPassword != null)
- sslConnector.setKeyPassword(keyPassword);
-
- Object needClientAuth = dictionary.get(JettyConstants.SSL_NEEDCLIENTAUTH);
- if (needClientAuth != null) {
- if (needClientAuth instanceof String)
- needClientAuth = Boolean.valueOf((String) needClientAuth);
-
- sslConnector.setNeedClientAuth(((Boolean) needClientAuth).booleanValue());
- }
-
- Object wantClientAuth = dictionary.get(JettyConstants.SSL_WANTCLIENTAUTH);
- if (wantClientAuth != null) {
- if (wantClientAuth instanceof String)
- wantClientAuth = Boolean.valueOf((String) wantClientAuth);
-
- sslConnector.setWantClientAuth(((Boolean) wantClientAuth).booleanValue());
- }
-
- String protocol = (String) dictionary.get(JettyConstants.SSL_PROTOCOL);
- if (protocol != null)
- sslConnector.setProtocol(protocol);
-
- String keystoreType = (String) dictionary.get(JettyConstants.SSL_KEYSTORETYPE);
- if (keystoreType != null)
- sslConnector.setKeystoreType(keystoreType);
-
- if (sslConnector.getPort() == 0) {
- try {
- sslConnector.open();
- } catch (IOException e) {
- // this would be unexpected since we're opening the next available port
- e.printStackTrace();
- }
- }
- return sslConnector;
+ return httpsEnabled;
}
private ServletContextHandler createHttpContext(@SuppressWarnings("rawtypes") Dictionary dictionary) {
@@ -316,15 +271,11 @@
HashSessionManager sessionManager = new HashSessionManager();
Integer sessionInactiveInterval = null;
Object sessionInactiveIntervalObj = dictionary.get(JettyConstants.CONTEXT_SESSIONINACTIVEINTERVAL);
- if (sessionInactiveIntervalObj instanceof Integer)
- {
+ if (sessionInactiveIntervalObj instanceof Integer) {
sessionInactiveInterval = (Integer) sessionInactiveIntervalObj;
+ } else if (sessionInactiveIntervalObj instanceof String) {
+ sessionInactiveInterval = Integer.valueOf(sessionInactiveIntervalObj.toString());
}
- else
- if (sessionInactiveIntervalObj instanceof String)
- {
- sessionInactiveInterval = Integer.valueOf(sessionInactiveIntervalObj.toString());
- }
if (sessionInactiveInterval != null)
sessionManager.setMaxInactiveInterval(sessionInactiveInterval.intValue());
From 12bc35c1dc35b7bf25874b4476bc672b940c8714 Mon Sep 17 00:00:00 2001
From: Michael Simacek <msimacek@redhat.com>
Date: Thu, 28 Nov 2013 13:51:05 +0100
Subject: [PATCH] Update to Jetty 9.1.0
---
.../org/eclipse/equinox/http/jetty/internal/EquinoxStdErrLog.java | 6 ++++++
1 file changed, 6 insertions(+)
diff --git rt.equinox.bundles/bundles/org.eclipse.equinox.http.jetty8/src/org/eclipse/equinox/http/jetty/internal/EquinoxStdErrLog.java b/rt.equinox.bundles/bundles/org.eclipse.equinox.http.jetty8/src/org/eclipse/equinox/http/jetty/internal/EquinoxStdErrLog.java
index 8ce6825..4cc4b94 100644
--- rt.equinox.bundles/bundles/org.eclipse.equinox.http.jetty8/src/org/eclipse/equinox/http/jetty/internal/EquinoxStdErrLog.java
+++ rt.equinox.bundles/bundles/org.eclipse.equinox.http.jetty8/src/org/eclipse/equinox/http/jetty/internal/EquinoxStdErrLog.java
@@ -169,6 +169,12 @@ public class EquinoxStdErrLog implements Logger {
realLogger.debug(thrown);
}
+ public void debug(String msg, long value) {
+ if (threshold > DEBUG)
+ return;
+ realLogger.debug(msg, value);
+ }
+
public void ignore(Throwable ignored) {
// Just post this to debug
debug(ignored);
--
1.8.3.1