FELIX-2292 Upgraded Jetty to Eclipse Jetty 7.6.3 and Cometd to 2.4.2. Fixed cometd sample project for the new cometd version.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1346763 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/http/jetty/pom.xml b/http/jetty/pom.xml
index e66face..45d9df3 100644
--- a/http/jetty/pom.xml
+++ b/http/jetty/pom.xml
@@ -49,7 +49,7 @@
<Private-Package>
org.apache.felix.http.base.*,
org.apache.felix.http.jetty.*,
- org.mortbay.*;-split-package:=merge-first
+ org.eclipse.*;-split-package:=merge-first
</Private-Package>
<Import-Package>
javax.net.ssl; javax.security.cert;
@@ -83,24 +83,29 @@
<artifactId>servlet-api</artifactId>
</dependency>
<dependency>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty</artifactId>
- <version>6.1.24</version>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-servlet</artifactId>
+ <version>7.6.3.v20120416</version>
</dependency>
<dependency>
- <groupId>org.mortbay.jetty</groupId>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-server</artifactId>
+ <version>7.6.3.v20120416</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
- <version>6.1.24</version>
+ <version>7.6.3.v20120416</version>
</dependency>
<dependency>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty-management</artifactId>
- <version>6.1.24</version>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-jmx</artifactId>
+ <version>7.6.3.v20120416</version>
</dependency>
<dependency>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty-sslengine</artifactId>
- <version>6.1.24</version>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-security</artifactId>
+ <version>7.6.3.v20120416</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
diff --git a/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java b/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java
index 6a642f0..8091832 100644
--- a/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java
+++ b/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java
@@ -16,13 +16,14 @@
*/
package org.apache.felix.http.jetty.internal;
-import org.osgi.framework.BundleContext;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.HashMap;
+import java.util.Hashtable;
import java.util.Map;
import java.util.Properties;
-import java.util.Hashtable;
+
+import org.osgi.framework.BundleContext;
public final class JettyConfig
{
@@ -112,7 +113,6 @@
private boolean useHttpsNio;
private boolean registerMBeans;
private int sessionTimeout;
- private int headerBufferSize;
private int requestBufferSize;
private int responseBufferSize;
private String contextPath;
@@ -232,11 +232,6 @@
return this.sessionTimeout;
}
- public int getHeaderBufferSize()
- {
- return this.headerBufferSize;
- }
-
public int getRequestBufferSize()
{
return this.requestBufferSize;
@@ -280,7 +275,6 @@
this.useHttpsNio = getBooleanProperty(props, FELIX_HTTPS_NIO, this.useHttpNio);
this.registerMBeans = getBooleanProperty(props, FELIX_HTTP_MBEANS, false);
this.sessionTimeout = getIntProperty(props, FELIX_SESSION_TIMEOUT, 0);
- this.headerBufferSize = getIntProperty(FELIX_JETTY_HEADER_BUFFER_SIZE, 16 * 1024);
this.requestBufferSize = getIntProperty(FELIX_JETTY_REQUEST_BUFFER_SIZE, 8 * 014);
this.responseBufferSize = getIntProperty(FELIX_JETTY_RESPONSE_BUFFER_SIZE, 24 * 1024);
this.contextPath = validateContextPath(getProperty(props, FELIX_HTTP_CONTEXT_PATH, null));
diff --git a/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyLogger.java b/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyLogger.java
index 02d73f6..4f89666 100644
--- a/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyLogger.java
+++ b/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyLogger.java
@@ -16,11 +16,10 @@
*/
package org.apache.felix.http.jetty.internal;
-import org.mortbay.log.Logger;
-import org.mortbay.log.Log;
+import java.text.MessageFormat;
+
import org.apache.felix.http.base.internal.logger.SystemLogger;
-import java.io.PrintStream;
-import java.io.ByteArrayOutputStream;
+import org.eclipse.jetty.util.log.Logger;
public final class JettyLogger
implements Logger
@@ -30,7 +29,7 @@
public JettyLogger()
{
- this("org.mortbay.log");
+ this("org.eclipse.jetty.log");
}
public JettyLogger(String name)
@@ -55,69 +54,57 @@
this.debugEnabled = enabled;
}
- public void debug(String msg, Throwable cause)
- {
- if (this.debugEnabled) {
- SystemLogger.debug(msg);
- }
- }
+ public void debug(Throwable throwable) {
+ if (this.debugEnabled) {
+ SystemLogger.debug(throwable.getMessage());
+ }
+
+ }
- public void debug(String msg, Object arg0, Object arg1)
- {
- if (this.debugEnabled) {
- SystemLogger.debug(format(msg, arg0, arg1));
- }
- }
+ public void debug(String msg, Object... args) {
+ if (this.debugEnabled) {
+ SystemLogger.debug(MessageFormat.format(msg, args));
+ }
+ }
- public void info(String msg, Object arg0, Object arg1)
- {
- // Classify all info messages as debug messages.
- // Jetty uses way to much verbose info messages.
- if (this.debugEnabled) {
- SystemLogger.info(format(msg, arg0, arg1));
- }
- }
+ public void debug(String msg, Throwable throwable) {
+ if (this.debugEnabled) {
+ SystemLogger.debug(msg + ": " + throwable.getMessage());
+ }
+ }
- public void warn(String msg, Throwable cause)
- {
- SystemLogger.warning(msg, cause);
- }
+ public String getName() {
+ return name;
+ }
- public void warn( String msg, Object arg0, Object arg1 )
- {
- SystemLogger.warning(format(msg, arg0, arg1), null);
- }
+ public void ignore(Throwable throwable) {
+
+ }
- public String toString()
- {
- return this.name;
- }
+ public void info(Throwable throwable) {
+ SystemLogger.info(throwable.getMessage());
+ }
- private String format(String msg, Object arg0, Object arg1)
- {
- int i0 = msg.indexOf("{}");
- int i1 = i0 < 0 ? -1 : msg.indexOf("{}", i0 + 2);
+ public void info(String msg, Object... args) {
+ SystemLogger.info(MessageFormat.format(msg, args));
+
+ }
- if (arg1 != null && i1 >= 0) {
- msg = msg.substring(0, i1) + arg1 + msg.substring(i1 + 2);
- }
+ public void info(String msg, Throwable throwable) {
+ SystemLogger.info(msg + ": " + throwable.getMessage());
+ }
- if (arg0 != null && i0 >= 0) {
- msg = msg.substring(0, i0) + arg0 + msg.substring(i0 + 2);
- }
+ public void warn(Throwable throwable) {
+ SystemLogger.warning(null, throwable);
+ }
- return msg;
- }
+ public void warn(String msg, Object... args) {
+ SystemLogger.warning(MessageFormat.format(msg, args), null);
+
+ }
- public static void init()
- {
- PrintStream out = System.err;
+ public void warn(String msg, Throwable throwable) {
+ SystemLogger.warning(msg, throwable);
+ }
- try {
- System.setErr(new PrintStream(new ByteArrayOutputStream()));
- Log.setLog(new JettyLogger());
- } finally {
- System.setErr(out);
- }
- }
}
diff --git a/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java b/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
index ce36439..c8c1e44 100644
--- a/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
+++ b/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
@@ -24,17 +24,17 @@
import org.apache.felix.http.base.internal.EventDispatcher;
import org.apache.felix.http.base.internal.HttpServiceController;
import org.apache.felix.http.base.internal.logger.SystemLogger;
-import org.mortbay.jetty.Connector;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.SessionManager;
-import org.mortbay.jetty.bio.SocketConnector;
-import org.mortbay.jetty.handler.StatisticsHandler;
-import org.mortbay.jetty.nio.SelectChannelConnector;
-import org.mortbay.jetty.security.HashUserRealm;
-import org.mortbay.jetty.security.SslSelectChannelConnector;
-import org.mortbay.jetty.security.SslSocketConnector;
-import org.mortbay.jetty.servlet.Context;
-import org.mortbay.jetty.servlet.ServletHolder;
+import org.eclipse.jetty.security.HashLoginService;
+import org.eclipse.jetty.server.Connector;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.SessionManager;
+import org.eclipse.jetty.server.bio.SocketConnector;
+import org.eclipse.jetty.server.handler.StatisticsHandler;
+import org.eclipse.jetty.server.nio.SelectChannelConnector;
+import org.eclipse.jetty.server.ssl.SslSelectChannelConnector;
+import org.eclipse.jetty.server.ssl.SslSocketConnector;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.servlet.ServletHolder;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceRegistration;
@@ -69,8 +69,6 @@
public void start()
throws Exception
{
- JettyLogger.init();
-
Properties props = new Properties();
props.put(Constants.SERVICE_PID, PID);
this.configServiceReg = this.context.registerService("org.osgi.service.cm.ManagedService",
@@ -150,13 +148,13 @@
if (this.config.isUseHttp() || this.config.isUseHttps())
{
StringBuffer message = new StringBuffer("Started jetty ").append(Server.getVersion()).append(" at port(s)");
- HashUserRealm realm = new HashUserRealm("OSGi HTTP Service Realm");
+ HashLoginService realm = new HashLoginService("OSGi HTTP Service Realm");
this.server = new Server();
// HTTP/1.1 requires Date header if possible (it is)
this.server.setSendDateHeader(true);
- this.server.addUserRealm(realm);
+ this.server.addBean(realm);
if (this.config.isUseHttp())
{
@@ -170,7 +168,8 @@
message.append(" HTTPS:").append(this.config.getHttpsPort());
}
- Context context = new Context(this.server, this.config.getContextPath(), Context.SESSIONS);
+ ServletContextHandler context = new ServletContextHandler(this.server, "/", ServletContextHandler.SESSIONS);
+
message.append(" on context path ").append(this.config.getContextPath());
configureSessionManager(context);
context.addEventListener(eventDispatcher);
@@ -181,7 +180,7 @@
{
this.mbeanServerTracker = new MBeanServerTracker(this.context, this.server);
this.mbeanServerTracker.open();
- context.addHandler(new StatisticsHandler());
+ context.addBean(new StatisticsHandler());
}
this.server.start();
@@ -307,7 +306,6 @@
private void configureConnector(final Connector connector)
{
connector.setMaxIdleTime(this.config.getHttpTimeout());
- connector.setHeaderBufferSize(this.config.getHeaderBufferSize());
connector.setRequestBufferSize(this.config.getRequestBufferSize());
connector.setResponseBufferSize(this.config.getResponseBufferSize());
connector.setHost(this.config.getHost());
@@ -318,14 +316,14 @@
// connector.setResponseBufferSize(responseBufferSize);
}
- private void configureSessionManager(final Context context)
+ private void configureSessionManager(final ServletContextHandler context)
{
final SessionManager manager = context.getSessionHandler().getSessionManager();
manager.setMaxInactiveInterval(this.config.getSessionTimeout() * 60);
manager.setSessionCookie(this.config.getProperty(SessionManager.__SessionCookieProperty, SessionManager.__DefaultSessionCookie));
- manager.setSessionURL(this.config.getProperty(SessionManager.__SessionURLProperty, SessionManager.__DefaultSessionURL));
+ manager.setSessionIdPathParameterName(this.config.getProperty(SessionManager.__SessionIdPathParameterNameProperty, SessionManager.__DefaultSessionIdPathParameterName));
manager.setSessionDomain(this.config.getProperty(SessionManager.__SessionDomainProperty, SessionManager.__DefaultSessionDomain));
manager.setSessionPath(this.config.getProperty(SessionManager.__SessionPathProperty, context.getContextPath()));
manager.setMaxCookieAge(this.config.getIntProperty(SessionManager.__MaxAgeProperty, -1));
diff --git a/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/MBeanServerTracker.java b/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/MBeanServerTracker.java
index 203155d..be0b16e 100644
--- a/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/MBeanServerTracker.java
+++ b/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/MBeanServerTracker.java
@@ -20,8 +20,8 @@
import javax.management.MBeanServer;
-import org.mortbay.jetty.Server;
-import org.mortbay.management.MBeanContainer;
+import org.eclipse.jetty.jmx.MBeanContainer;
+import org.eclipse.jetty.server.Server;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.util.tracker.ServiceTracker;