First cut at migrating to Jetty 6 and prep for using an external

Jetty 6 package.

- Add several jars from the Jetty 6 distribution
- Update jetty.xml
- Add context XML files
- Update WorkingDir to migrate the content XML files
- Update RouterConsoleRunner and LocaleWebAppHandler
- Remove all old Jetty 5.1.15 local mods;
  this will break Seedless using a custom Server() constructor
- Update I2PRequestLog to be a mod of NCSARequestLog from 6.1.26
- Put I2PRequestLog in its own jar
- Copy MultiPartRequest and other required classes from Jetty 5.1.15
  and add it to susimail, as the replacement MultiPartFilter in
  Jetty 6 is difficult to migrate to, and does not support content-type
- Update i2psnark for Jetty 6
- Disable i2psnark RunStandalone, unused and instantiated Jetty 5
- Fix up all webapp build.xml to reference new jars

Not yet working: Plugin/webapp run detection and stopping, eepsite CGI
Not well tested: Plugins, classpaths, webapps
This commit is contained in:
zzz
2011-12-23 00:56:48 +00:00
parent bd14dc3112
commit 92b9d0a996
49 changed files with 757 additions and 6607 deletions

View File

@ -19,6 +19,7 @@
<pathelement location="../../ministreaming/java/build/obj" />
<pathelement location="../../jetty/jettylib/org.mortbay.jetty.jar" />
<pathelement location="../../jetty/jettylib/javax.servlet.jar" />
<pathelement location="../../jetty/jettylib/jetty-util.jar" />
</classpath>
</depend>
</target>
@ -34,7 +35,7 @@
debug="true" deprecation="on" source="1.5" target="1.5"
destdir="./build/obj"
includeAntRuntime="false"
classpath="../../../core/java/build/i2p.jar:../../jetty/jettylib/org.mortbay.jetty.jar:../../jetty/jettylib/javax.servlet.jar:../../ministreaming/java/build/mstreaming.jar" >
classpath="../../../core/java/build/i2p.jar:../../jetty/jettylib/org.mortbay.jetty.jar:../../jetty/jettylib/javax.servlet.jar:../../jetty/jettylib/jetty-util.jar:../../ministreaming/java/build/mstreaming.jar" >
<compilerarg line="${javac.compilerargs}" />
</javac>
</target>

View File

@ -43,17 +43,16 @@ import org.klomp.snark.SnarkManager;
import org.klomp.snark.Storage;
import org.klomp.snark.TrackerClient;
import org.mortbay.http.HttpResponse;
import org.mortbay.jetty.servlet.Default;
import org.mortbay.util.Resource;
import org.mortbay.util.URI;
import org.mortbay.jetty.servlet.DefaultServlet;
import org.mortbay.resource.Resource;
import org.mortbay.util.URIUtil;
/**
* We extend Default instead of HTTPServlet so we can handle
* i2psnark/ file requests with http:// instead of the flaky and
* often-blocked-by-the-browser file://
*/
public class I2PSnarkServlet extends Default {
public class I2PSnarkServlet extends DefaultServlet {
private I2PAppContext _context;
private Log _log;
private SnarkManager _manager;
@ -99,13 +98,17 @@ public class I2PSnarkServlet extends Default {
* and we can't get any resources (like icons) out of the .war
*/
@Override
protected Resource getResource(String pathInContext) throws IOException
public Resource getResource(String pathInContext)
{
if (pathInContext == null || pathInContext.equals("/") || pathInContext.equals("/index.jsp") ||
pathInContext.equals("/index.html") || pathInContext.startsWith("/_icons/"))
return super.getResource(pathInContext);
// files in the i2psnark/ directory
return _resourceBase.addPath(pathInContext);
try {
return _resourceBase.addPath(pathInContext);
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
}
/**
@ -113,10 +116,11 @@ public class I2PSnarkServlet extends Default {
* @since 0.8.3
*/
@Override
public void handleGet(HttpServletRequest request, HttpServletResponse response, String pathInContext, Resource resource, boolean endsWithSlash) throws ServletException, IOException {
if (resource.getName().startsWith("jar:file:"))
response.setHeader("Cache-Control", "max-age=86400"); // cache for a day
super.handleGet(request, response, pathInContext, resource, endsWithSlash);
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
////////////////////////////////////
//if (resource.getName().startsWith("jar:file:"))
// response.setHeader("Cache-Control", "max-age=86400"); // cache for a day
super.doGet(request, response);
}
/**
@ -144,7 +148,7 @@ public class I2PSnarkServlet extends Default {
// since we are not overriding handle*(), do this here
String method = req.getMethod();
if (!(method.equals("GET") || method.equals("HEAD") || method.equals("POST"))) {
resp.sendError(HttpResponse.__405_Method_Not_Allowed);
resp.sendError(405);
return;
}
_themePath = "/themes/snark/" + _manager.getTheme() + '/';
@ -157,20 +161,20 @@ public class I2PSnarkServlet extends Default {
if (path.endsWith("/")) {
// bypass the horrid Resource.getListHTML()
String pathInfo = req.getPathInfo();
String pathInContext = URI.addPaths(path, pathInfo);
String pathInContext = URIUtil.addPaths(path, pathInfo);
req.setCharacterEncoding("UTF-8");
resp.setCharacterEncoding("UTF-8");
resp.setContentType("text/html; charset=UTF-8");
Resource resource = getResource(pathInContext);
if (resource == null || (!resource.exists())) {
resp.sendError(HttpResponse.__404_Not_Found);
resp.sendError(404);
} else {
String base = URI.addPaths(req.getRequestURI(), "/");
String base = URIUtil.addPaths(req.getRequestURI(), "/");
String listing = getListHTML(resource, base, true, method.equals("POST") ? req.getParameterMap() : null);
if (listing != null)
resp.getWriter().write(listing);
else // shouldn't happen
resp.sendError(HttpResponse.__404_Not_Found);
resp.sendError(404);
}
} else {
super.service(req, resp);
@ -1680,7 +1684,7 @@ public class I2PSnarkServlet extends Default {
StringBuilder buf=new StringBuilder(4096);
buf.append(DOCTYPE + "<HTML><HEAD><TITLE>");
String title = URI.decodePath(base);
String title = URIUtil.decodePath(base);
if (title.startsWith("/i2psnark/"))
title = title.substring("/i2psnark/".length());
@ -1783,7 +1787,7 @@ public class I2PSnarkServlet extends Default {
.append(_("Priority")).append("</th>");
buf.append("</tr></thead>\n");
buf.append("<tr><td colspan=\"" + (showPriority ? '4' : '3') + "\" class=\"ParentDir\"><A HREF=\"");
buf.append(URI.addPaths(base,"../"));
buf.append(URIUtil.addPaths(base,"../"));
buf.append("\"><img alt=\"\" border=\"0\" src=\"" + _imgPath + "up.png\"> ")
.append(_("Up to higher level directory")).append("</A></td></tr>\n");
@ -1793,7 +1797,7 @@ public class I2PSnarkServlet extends Default {
boolean showSaveButton = false;
for (int i=0 ; i< ls.length ; i++)
{
String encoded=URI.encodePath(ls[i]);
String encoded=URIUtil.encodePath(ls[i]);
// bugfix for I2P - Backport from Jetty 6 (zero file lengths and last-modified times)
// http://jira.codehaus.org/browse/JETTY-361?page=com.atlassian.jira.plugin.system.issuetabpanels%3Achangehistory-tabpanel#issue-tabs
// See resource.diff attachment
@ -1849,9 +1853,9 @@ public class I2PSnarkServlet extends Default {
}
}
String path=URI.addPaths(base,encoded);
String path=URIUtil.addPaths(base,encoded);
if (item.isDirectory() && !path.endsWith("/"))
path=URI.addPaths(path,"/");
path=URIUtil.addPaths(path,"/");
String icon = toIcon(item);
if (complete) {

View File

@ -31,6 +31,8 @@ public class RunStandalone {
if (!workDirCreated)
System.err.println("ERROR: Unable to create Jetty temporary work directory");
throw new RuntimeException("unsupported");
/****
try {
_server = new Server("jetty-i2psnark.xml");
// just blow up NPE if we don't have a context
@ -39,13 +41,17 @@ public class RunStandalone {
} catch (Exception e) {
e.printStackTrace();
}
****/
}
public void stop() {
throw new RuntimeException("unsupported");
/****
try {
_server.stop();
} catch (InterruptedException ie) {
ie.printStackTrace();
}
****/
}
}