From 67b5caadbb59851fe2d5292bf5a38b846de9b29c Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Mon, 19 Nov 2012 17:42:31 +1100 Subject: [PATCH] jetty-9 cleaned up serverClasses to minimum --- examples/async-rest/async-rest-jar/pom.xml | 1 + examples/async-rest/async-rest-webapp/pom.xml | 6 ++++ .../src/main/webapp/WEB-INF/jetty-web.xml | 3 ++ .../jetty/example/asyncrest/DemoServer.java | 2 -- .../src/main/config/etc/jetty-deploy.xml | 2 +- jetty-util-ajax/pom.xml | 1 + .../webapp/StandardDescriptorProcessor.java | 20 +++++++----- .../eclipse/jetty/webapp/WebAppContext.java | 14 ++------- jetty-websocket/websocket-servlet/pom.xml | 1 + tests/test-webapps/test-jetty-webapp/pom.xml | 31 ++----------------- .../src/main/webapp/WEB-INF/jetty-web.xml | 3 ++ .../java/org/eclipse/jetty/TestServer.java | 8 ++--- 12 files changed, 39 insertions(+), 53 deletions(-) diff --git a/examples/async-rest/async-rest-jar/pom.xml b/examples/async-rest/async-rest-jar/pom.xml index 919bcd955d7..db25076f28a 100644 --- a/examples/async-rest/async-rest-jar/pom.xml +++ b/examples/async-rest/async-rest-jar/pom.xml @@ -14,6 +14,7 @@ org.eclipse.jetty jetty-client ${project.version} + provided org.eclipse.jetty diff --git a/examples/async-rest/async-rest-webapp/pom.xml b/examples/async-rest/async-rest-webapp/pom.xml index 4544b19ade0..b41d3084276 100644 --- a/examples/async-rest/async-rest-webapp/pom.xml +++ b/examples/async-rest/async-rest-webapp/pom.xml @@ -18,6 +18,12 @@ example-async-rest-jar ${project.version} + + org.eclipse.jetty + jetty-client + ${project.version} + test + org.eclipse.jetty jetty-webapp diff --git a/examples/async-rest/async-rest-webapp/src/main/webapp/WEB-INF/jetty-web.xml b/examples/async-rest/async-rest-webapp/src/main/webapp/WEB-INF/jetty-web.xml index 572942fd5ca..d30fb228479 100644 --- a/examples/async-rest/async-rest-webapp/src/main/webapp/WEB-INF/jetty-web.xml +++ b/examples/async-rest/async-rest-webapp/src/main/webapp/WEB-INF/jetty-web.xml @@ -12,4 +12,7 @@ org.eclipse.jetty.servlet.WebApplicationContext object async-rest webapp is deployed. DO NOT USE IN PRODUCTION! + + -org.eclipse.jetty.client. + diff --git a/examples/async-rest/async-rest-webapp/src/test/java/org/eclipse/jetty/example/asyncrest/DemoServer.java b/examples/async-rest/async-rest-webapp/src/test/java/org/eclipse/jetty/example/asyncrest/DemoServer.java index 91471d50da1..da909fb8a33 100644 --- a/examples/async-rest/async-rest-webapp/src/test/java/org/eclipse/jetty/example/asyncrest/DemoServer.java +++ b/examples/async-rest/async-rest-webapp/src/test/java/org/eclipse/jetty/example/asyncrest/DemoServer.java @@ -33,8 +33,6 @@ public class DemoServer WebAppContext webapp = new WebAppContext(); webapp.setContextPath("/"); webapp.setWar(jetty_home+"/target/async-rest/"); - webapp.setParentLoaderPriority(true); - webapp.setServerClasses(new String[]{}); server.setHandler(webapp); server.start(); diff --git a/jetty-deploy/src/main/config/etc/jetty-deploy.xml b/jetty-deploy/src/main/config/etc/jetty-deploy.xml index 9b42604d6d3..0572fc54bca 100644 --- a/jetty-deploy/src/main/config/etc/jetty-deploy.xml +++ b/jetty-deploy/src/main/config/etc/jetty-deploy.xml @@ -36,7 +36,7 @@ --> - + /webapps diff --git a/jetty-util-ajax/pom.xml b/jetty-util-ajax/pom.xml index c08c077e2c4..b649a823f82 100644 --- a/jetty-util-ajax/pom.xml +++ b/jetty-util-ajax/pom.xml @@ -75,6 +75,7 @@ org.eclipse.jetty jetty-util ${project.version} + provided org.eclipse.jetty.orbit diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/StandardDescriptorProcessor.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/StandardDescriptorProcessor.java index ef8681f5751..3bfb7f27e4b 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/StandardDescriptorProcessor.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/StandardDescriptorProcessor.java @@ -1854,12 +1854,19 @@ public class StandardDescriptorProcessor extends IterativeDescriptorProcessor ((WebDescriptor)descriptor).addClassName(className); - Class listenerClass = (Class)context.loadClass(className); - listener = newListenerInstance(context,listenerClass); - if (!(listener instanceof EventListener)) + Class listenerClass = context.loadClass(className); + if (listenerClass==null) { - LOG.warn("Not an EventListener: " + listener); - return; + throw new RuntimeException("Could not Load EventListener: " + className); + } + if (!(EventListener.class.isAssignableFrom(listenerClass))) + { + throw new RuntimeException("Not an EventListener: " + className); + } + listener = newListenerInstance(context,(Class)listenerClass); + if (listener==null) + { + throw new RuntimeException("Could not Load EventListener: " + className); } context.addEventListener(listener); context.getMetaData().setOrigin(className+".listener", descriptor); @@ -1868,8 +1875,7 @@ public class StandardDescriptorProcessor extends IterativeDescriptorProcessor } catch (Exception e) { - LOG.warn("Could not instantiate listener " + className, e); - return; + throw new RuntimeException("Could not instantiate listener " + className, e); } } diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java index 6abfaba3349..6c64a27a564 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java @@ -104,18 +104,14 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL // System classes are classes that cannot be replaced by // the web application, and they are *always* loaded via - // system classloader. + // system classloader if possible public final static String[] __dftSystemClasses = { "java.", // Java SE classes (per servlet spec v2.5 / SRV.9.7.2) "javax.", // Java SE classes (per servlet spec v2.5 / SRV.9.7.2) "org.xml.", // needed by javax.xml "org.w3c.", // needed by javax.xml - "org.eclipse.jetty.continuation.", // webapp cannot change continuation classes - "org.eclipse.jetty.jndi.", // webapp cannot change naming classes - "org.eclipse.jetty.jaas.", // webapp cannot change jaas classes - "org.eclipse.jetty.websocket.", // WebSocket is a jetty extension - "org.eclipse.jetty.servlet.DefaultServlet" // webapp cannot change default servlets + "org.eclipse.jetty.", // webapp cannot change jetty classes } ; // Server classes are classes that are hidden from being @@ -124,12 +120,8 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL // it has to include them in its distribution. public final static String[] __dftServerClasses = { - "-org.eclipse.jetty.continuation.", // don't hide continuation classes - "-org.eclipse.jetty.jndi.", // don't hide naming classes - "-org.eclipse.jetty.jaas.", // don't hide jaas classes - "-org.eclipse.jetty.servlets.", // don't hide jetty servlets + "-org.eclipse.jetty.servlet.listener.", // don't hide listeners use in webdefault.xml "-org.eclipse.jetty.servlet.DefaultServlet", // don't hide default servlet - "-org.eclipse.jetty.servlet.listener.", // don't hide useful listeners "org.eclipse.jetty." // hide other jetty classes } ; diff --git a/jetty-websocket/websocket-servlet/pom.xml b/jetty-websocket/websocket-servlet/pom.xml index 9a991924728..1baa4d1b121 100644 --- a/jetty-websocket/websocket-servlet/pom.xml +++ b/jetty-websocket/websocket-servlet/pom.xml @@ -19,6 +19,7 @@ org.eclipse.jetty.websocket websocket-api ${project.version} + provided org.eclipse.jetty.orbit diff --git a/tests/test-webapps/test-jetty-webapp/pom.xml b/tests/test-webapps/test-jetty-webapp/pom.xml index 68802495b59..c297e3d1fc5 100644 --- a/tests/test-webapps/test-jetty-webapp/pom.xml +++ b/tests/test-webapps/test-jetty-webapp/pom.xml @@ -24,6 +24,7 @@ ../pom.xml 4.0.0 + org.eclipse.jetty test-jetty-webapp Test :: Jetty Test Webapp war @@ -183,20 +184,7 @@ org.eclipse.jetty jetty-servlets ${project.version} - - - org.eclipse.jetty - jetty-util - - - org.eclipse.jetty - jetty-client - - - org.eclipse.jetty - jetty-http - - + provided org.eclipse.jetty.orbit @@ -212,20 +200,7 @@ org.eclipse.jetty.websocket websocket-server ${project.version} - - - org.eclipse.jetty - jetty-util - - - org.eclipse.jetty - jetty-http - - - org.eclipse.jetty - jetty-io - - + provided org.eclipse.jetty diff --git a/tests/test-webapps/test-jetty-webapp/src/main/webapp/WEB-INF/jetty-web.xml b/tests/test-webapps/test-jetty-webapp/src/main/webapp/WEB-INF/jetty-web.xml index ca48bb7ac9a..687f31539f5 100644 --- a/tests/test-webapps/test-jetty-webapp/src/main/webapp/WEB-INF/jetty-web.xml +++ b/tests/test-webapps/test-jetty-webapp/src/main/webapp/WEB-INF/jetty-web.xml @@ -11,6 +11,9 @@ org.eclipse.jetty.servlet.WebApplicationContext object -org.eclipse.jetty.util. -org.eclipse.jetty.servlets. + -org.eclipse.jetty.websocket. + -org.eclipse.jetty.servlets. + -org.eclipse.jetty.servlet.listener. test webapp is deployed. DO NOT USE IN PRODUCTION! diff --git a/tests/test-webapps/test-jetty-webapp/src/test/java/org/eclipse/jetty/TestServer.java b/tests/test-webapps/test-jetty-webapp/src/test/java/org/eclipse/jetty/TestServer.java index 75f1580c663..5ecafdc7414 100644 --- a/tests/test-webapps/test-jetty-webapp/src/test/java/org/eclipse/jetty/TestServer.java +++ b/tests/test-webapps/test-jetty-webapp/src/test/java/org/eclipse/jetty/TestServer.java @@ -67,7 +67,7 @@ public class TestServer { ((StdErrLog)Log.getLog()).setSource(false); - String jetty_root = ".."; + String jetty_root = "../../.."; // Setup Threadpool QueuedThreadPool threadPool = new QueuedThreadPool(); @@ -153,7 +153,7 @@ public class TestServer HashLoginService login = new HashLoginService(); login.setName("Test Realm"); - login.setConfig(jetty_root + "/test-jetty-webapp/src/main/config/etc/realm.properties"); + login.setConfig(jetty_root + "/tests/test-webapps/test-jetty-webapp/src/main/config/etc/realm.properties"); server.addBean(login); File log=File.createTempFile("jetty-yyyy_mm_dd", "log"); @@ -165,8 +165,8 @@ public class TestServer server.setSendServerVersion(true); WebAppContext webapp = new WebAppContext(); - webapp.setParentLoaderPriority(true); - webapp.prependServerClass("-org.eclipse.jetty.websocket.server."); + // webapp.setParentLoaderPriority(true); + // webapp.prependServerClass("-org.eclipse.jetty.websocket.server."); webapp.setResourceBase("./src/main/webapp"); webapp.setAttribute("testAttribute","testValue"); File sessiondir=File.createTempFile("sessions",null);