I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 76c0f56b authored by zzz's avatar zzz
Browse files

* Plugins: Fix setting webapp classpath on Jetty 6

parent d85ae48f
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,7 @@ import java.util.StringTokenizer; ...@@ -7,6 +7,7 @@ import java.util.StringTokenizer;
import net.i2p.I2PAppContext; import net.i2p.I2PAppContext;
import org.mortbay.jetty.webapp.Configuration; import org.mortbay.jetty.webapp.Configuration;
import org.mortbay.jetty.webapp.WebAppClassLoader;
import org.mortbay.jetty.webapp.WebAppContext; import org.mortbay.jetty.webapp.WebAppContext;
...@@ -45,7 +46,10 @@ public class WebAppConfiguration implements Configuration { ...@@ -45,7 +46,10 @@ public class WebAppConfiguration implements Configuration {
return _wac; return _wac;
} }
public void configureClassPath() throws Exception { /**
* This was the interface in Jetty 5, now it's configureClassLoader()
*/
private void configureClassPath() throws Exception {
String ctxPath = _wac.getContextPath(); String ctxPath = _wac.getContextPath();
//System.err.println("Configure Class Path " + ctxPath); //System.err.println("Configure Class Path " + ctxPath);
if (ctxPath.equals("/")) if (ctxPath.equals("/"))
...@@ -78,7 +82,10 @@ public class WebAppConfiguration implements Configuration { ...@@ -78,7 +82,10 @@ public class WebAppConfiguration implements Configuration {
if (cp == null) if (cp == null)
return; return;
StringTokenizer tok = new StringTokenizer(cp, " ,"); StringTokenizer tok = new StringTokenizer(cp, " ,");
StringBuilder buf = new StringBuilder();
while (tok.hasMoreTokens()) { while (tok.hasMoreTokens()) {
if (buf.length() > 0)
buf.append(',');
String elem = tok.nextToken().trim(); String elem = tok.nextToken().trim();
String path; String path;
if (elem.startsWith("$I2P")) if (elem.startsWith("$I2P"))
...@@ -88,7 +95,17 @@ public class WebAppConfiguration implements Configuration { ...@@ -88,7 +95,17 @@ public class WebAppConfiguration implements Configuration {
else else
path = dir.getAbsolutePath() + '/' + elem; path = dir.getAbsolutePath() + '/' + elem;
System.err.println("Adding " + path + " to classpath for " + appName); System.err.println("Adding " + path + " to classpath for " + appName);
_wac.setExtraClasspath(path); buf.append(path);
}
ClassLoader cl = _wac.getClassLoader();
if (cl != null && cl instanceof WebAppClassLoader) {
WebAppClassLoader wacl = (WebAppClassLoader) cl;
wacl.addClassPath(buf.toString());
} else {
// This was not working because the WebAppClassLoader already exists
// and it calls getExtraClasspath in its constructor
// Not sure why WACL already exists...
_wac.setExtraClasspath(buf.toString());
} }
} }
...@@ -99,5 +116,7 @@ public class WebAppConfiguration implements Configuration { ...@@ -99,5 +116,7 @@ public class WebAppConfiguration implements Configuration {
public void deconfigureWebApp() {} public void deconfigureWebApp() {}
/** @since Jetty 6 */ /** @since Jetty 6 */
public void configureClassLoader() {} public void configureClassLoader() throws Exception {
configureClassPath();
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment