Author: hannes
Date: 2009-04-06 11:08:18 +0200 (Mon, 06 Apr 2009)
New Revision: 9578
Added:
helma/helma/branches/jetty6/lib/jetty-ajp.jar
helma/helma/branches/jetty6/lib/jetty-util.jar
Modified:
helma/helma/branches/jetty6/lib/jetty.jar
helma/helma/branches/jetty6/lib/servlet.jar
helma/helma/branches/jetty6/src/helma/main/ApplicationManager.java
helma/helma/branches/jetty6/src/helma/main/JettyServer.java
helma/helma/branches/jetty6/src/helma/main/Server.java
helma/helma/branches/jetty6/src/helma/main/launcher/Main.java
Log:
Update to Jetty 6.1.16 with patch from Bernhard Froehlich (decke) and a few fixes from me. Unfortunately there are a few unresolved issues in helma.main.JettyServer wich need to be sorted out before merging to trunk.
Details at http://dev.helma.org/trac/helma/changeset/9578
Added: helma/helma/branches/jetty6/lib/jetty-ajp.jar
Property changes on: helma/helma/branches/jetty6/lib/jetty-ajp.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: helma/helma/branches/jetty6/lib/jetty-util.jar
Property changes on: helma/helma/branches/jetty6/lib/jetty-util.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: helma/helma/branches/jetty6/lib/jetty.jar
===================================================================
(Binary files differ)
Modified: helma/helma/branches/jetty6/lib/servlet.jar
===================================================================
(Binary files differ)
Modified: helma/helma/branches/jetty6/src/helma/main/ApplicationManager.java
===================================================================
--- helma/helma/branches/jetty6/src/helma/main/ApplicationManager.java 2009-04-06 09:04:34 UTC (rev 9577)
+++ helma/helma/branches/jetty6/src/helma/main/ApplicationManager.java 2009-04-06 09:08:18 UTC (rev 9578)
@@ -22,14 +22,17 @@
import helma.util.StringUtils;
import org.apache.xmlrpc.XmlRpcHandler;
import org.apache.commons.logging.Log;
-import org.mortbay.http.*;
-import org.mortbay.http.handler.*;
-import org.mortbay.jetty.servlet.*;
+import org.mortbay.jetty.handler.ContextHandler;
+import org.mortbay.jetty.handler.ContextHandlerCollection;
+import org.mortbay.jetty.handler.ResourceHandler;
+import org.mortbay.jetty.servlet.ServletHandler;
+import org.mortbay.jetty.servlet.ServletHolder;
+
import java.io.*;
import java.rmi.*;
import java.util.*;
import helma.util.ResourceProperties;
-import helma.util.Logging;
+import helma.servlet.EmbeddedServletClient;
/**
* This class is responsible for starting and stopping Helma applications.
@@ -42,6 +45,7 @@
private ResourceProperties props;
private Server server;
private long lastModified;
+ private ContextHandlerCollection context;
private JettyServer jetty = null;
/**
@@ -271,10 +275,10 @@
}
if (mountpoint.endsWith("/")) {
- return mountpoint + "*";
+ return mountpoint.substring(0, mountpoint.length()-1);
}
- return mountpoint + "/*";
+ return mountpoint;
}
private File getAbsoluteFile(String path) {
@@ -307,6 +311,9 @@
Application app;
+ private ContextHandler staticContext = null;
+ private ContextHandler appContext = null;
+
String appName;
File appDir;
File dbDir;
@@ -483,9 +490,34 @@
// bind to Jetty HTTP server
if (jetty != null) {
+ if(context == null) {
+ context = new ContextHandlerCollection();
+ context.mapContexts();
+ jetty.getHttpServer().setHandler(context);
+ }
- HttpContext context = jetty.addContext(pathPattern);
+ // if there is a static direcory specified, mount it
+ if (staticDir != null) {
+ File staticContent = getAbsoluteFile(staticDir);
+
+ getLogger().info("Serving static from " +
+ staticContent.getPath());
+ getLogger().info("Mounting static at " +
+ staticMountpoint);
+
+ ResourceHandler rhandler = new ResourceHandler();
+ rhandler.setResourceBase(staticContent.getPath());
+ rhandler.setWelcomeFiles(staticHome);
+
+ staticContext = context.addContext(staticMountpoint, "");
+ staticContext.setHandler(rhandler);
+
+ staticContext.start();
+ }
+
+ appContext = context.addContext(pathPattern, "");
+
if (encode) {
// FIXME: ContentEncodingHandler is broken/removed in Jetty 4.2
// context.addHandler(new ContentEncodingHandler());
@@ -494,8 +526,8 @@
ServletHandler handler = new ServletHandler();
- ServletHolder holder = handler.addServlet(appName, "/*",
- "helma.servlet.EmbeddedServletClient");
+ ServletHolder holder = new ServletHolder(EmbeddedServletClient.class);
+ handler.addServletWithMapping(holder, "/*");
holder.setInitParameter("application", appName);
// holder.setInitParameter("mountpoint", mountpoint);
@@ -523,38 +555,17 @@
if (debug != null) {
holder.setInitParameter("debug", debug);
}
+
+ appContext.setHandler(handler);
- context.addHandler(handler);
-
if (protectedStaticDir != null) {
File protectedContent = getAbsoluteFile(protectedStaticDir);
- context.setResourceBase(protectedContent.getPath());
+ appContext.setResourceBase(protectedContent.getPath());
getLogger().info("Serving protected static from " +
protectedContent.getPath());
}
- context.start();
-
- // if there is a static direcory specified, mount it
- if (staticDir != null) {
-
- File staticContent = getAbsoluteFile(staticDir);
-
- getLogger().info("Serving static from " +
- staticContent.getPath());
- getLogger().info("Mounting static at " +
- staticMountpoint);
-
- context = jetty.addContext(staticMountpoint);
- context.setWelcomeFiles(staticHome);
-
- context.setResourceBase(staticContent.getPath());
-
- ResourceHandler rhandler = new ResourceHandler();
- rhandler.setDirAllowed(staticIndex);
- context.addHandler(rhandler);
- context.start();
- }
+ appContext.start();
}
// register as XML-RPC handler
@@ -578,20 +589,16 @@
// unbind from Jetty HTTP server
if (jetty != null) {
- HttpContext context = jetty.getContext(pathPattern);
-
- if (context != null) {
- context.stop();
- context.destroy();
+ if (appContext != null) {
+ appContext.stop();
+ appContext.destroy();
+ appContext = null;
}
- if (staticDir != null) {
- context = jetty.getContext(staticMountpoint);
-
- if (context != null) {
- context.stop();
- context.destroy();
- }
+ if (staticContext != null) {
+ staticContext.stop();
+ staticContext.destroy();
+ staticContext = null;
}
}
Modified: helma/helma/branches/jetty6/src/helma/main/JettyServer.java
===================================================================
--- helma/helma/branches/jetty6/src/helma/main/JettyServer.java 2009-04-06 09:04:34 UTC (rev 9577)
+++ helma/helma/branches/jetty6/src/helma/main/JettyServer.java 2009-04-06 09:08:18 UTC (rev 9578)
@@ -16,13 +16,12 @@
package helma.main;
-import org.mortbay.http.HttpServer;
-import org.mortbay.http.HttpContext;
-import org.mortbay.http.SocketListener;
-import org.mortbay.http.HttpListener;
-import org.mortbay.http.ajp.AJP13Listener;
-import org.mortbay.util.InetAddrPort;
+import org.mortbay.jetty.Connector;
+import org.mortbay.jetty.ajp.Ajp13SocketConnector;
+import org.mortbay.jetty.bio.SocketConnector;
+import org.mortbay.jetty.nio.SelectChannelConnector;
+
import java.util.StringTokenizer;
import java.net.URL;
import java.net.InetSocketAddress;
@@ -31,10 +30,10 @@
public class JettyServer {
// the embedded web server
- protected HttpServer http;
+ protected org.mortbay.jetty.Server http;
// the AJP13 Listener, used for connecting from external webserver to servlet via JK
- protected AJP13Listener ajp13;
+ protected Ajp13SocketConnector ajp13;
public static JettyServer init(Server server) throws IOException {
if (server.configFile != null && server.configFile.exists()) {
@@ -46,24 +45,34 @@
}
private JettyServer(URL url) throws IOException {
- http = new org.mortbay.jetty.Server(url);
+ // TODO: this is wrong. url is supposed to be the url of a jetty config file.
+ http = new org.mortbay.jetty.Server(url.getPort());
openListeners();
}
private JettyServer(InetSocketAddress webPort, InetSocketAddress ajpPort, Server server)
throws IOException {
- http = new HttpServer();
-
- // create embedded web server if port is specified
+
+ http = new org.mortbay.jetty.Server();
+ http.setServer(http);
+
+ // start embedded web server if port is specified
if (webPort != null) {
- http.addListener(new InetAddrPort(webPort.getAddress(), webPort.getPort()));
+ Connector conn = new SelectChannelConnector();
+ conn.setHost(webPort.getAddress().getHostAddress());
+ conn.setPort(webPort.getPort());
+
+ http.addConnector(conn);
}
// activate the ajp13-listener
if (ajpPort != null) {
// create AJP13Listener
- ajp13 = new AJP13Listener(new InetAddrPort(ajpPort.getAddress(), ajpPort.getPort()));
- ajp13.setHttpServer(http);
+ ajp13 = new Ajp13SocketConnector();
+ ajp13.setHost(ajpPort.getAddress().getHostAddress());
+ ajp13.setPort(ajpPort.getPort());
+
+ http.addConnector(ajp13);
String jkallow = server.sysProps.getProperty("allowAJP13");
@@ -81,16 +90,17 @@
cnt++;
}
- ajp13.setRemoteServers(jkallowarr);
+ // TODO:
+ //ajp13.setRemoteServers(jkallowarr);
server.getLogger().info("Starting AJP13-Listener on port " + (ajpPort));
}
openListeners();
}
- public HttpServer getHttpServer() {
+ public org.mortbay.jetty.Server getHttpServer() {
return http;
}
-
+/* TODO:
public HttpContext getContext(String contextPath) {
return http.getContext(contextPath);
}
@@ -98,6 +108,7 @@
public HttpContext addContext(String contextPath) {
return http.addContext(contextPath);
}
+*/
public void start() throws Exception {
http.start();
@@ -106,7 +117,7 @@
}
}
- public void stop() throws InterruptedException {
+ public void stop() throws Exception {
http.stop();
if (ajp13 != null) {
ajp13.stop();
@@ -121,11 +132,11 @@
// opening the listener here allows us to run on priviledged port 80 under jsvc
// even as non-root user, because init() is called with root privileges
// while start() will be called with the user we will actually run as
- HttpListener[] listeners = http.getListeners();
- for (int i = 0; i < listeners.length; i++) {
- if (listeners[i] instanceof SocketListener) {
- SocketListener listener = (SocketListener) listeners[i];
- listener.open();
+ Connector[] connectors = http.getConnectors();
+ for (int i = 0; i < connectors.length; i++) {
+ if (connectors[i] instanceof SocketConnector) {
+ SocketConnector connector = (SocketConnector) connectors[i];
+ connector.open();
}
}
}
Modified: helma/helma/branches/jetty6/src/helma/main/Server.java
===================================================================
--- helma/helma/branches/jetty6/src/helma/main/Server.java 2009-04-06 09:04:34 UTC (rev 9577)
+++ helma/helma/branches/jetty6/src/helma/main/Server.java 2009-04-06 09:08:18 UTC (rev 9578)
@@ -523,8 +523,8 @@
try {
jetty.stop();
jetty.destroy();
- } catch (InterruptedException irx) {
- // http.stop() interrupted by another thread. ignore.
+ } catch (Exception x) {
+ // exception in jettx stop. ignore.
}
}
Modified: helma/helma/branches/jetty6/src/helma/main/launcher/Main.java
===================================================================
--- helma/helma/branches/jetty6/src/helma/main/launcher/Main.java 2009-04-06 09:04:34 UTC (rev 9577)
+++ helma/helma/branches/jetty6/src/helma/main/launcher/Main.java 2009-04-06 09:08:18 UTC (rev 9578)
@@ -36,8 +36,9 @@
public class Main {
public static final String[] jars = {
"helma.jar", "rhino.jar", "jetty.jar",
- "commons-logging.jar",
- "crimson.jar", "xmlrpc.jar", "servlet.jar",
+ "jetty-util.jar", "jetty-ajp.jar",
+ "commons-logging.jar", "crimson.jar",
+ "xmlrpc.jar", "servlet.jar",
"mail.jar", "activation.jar",
"commons-fileupload.jar", "commons-codec.jar",
"commons-io.jar", "commons-net.jar",
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.