diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneWebAppWithJsp.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneWebAppWithJsp.java index 64f1e9aa8e6..d8e6f7c3326 100644 --- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneWebAppWithJsp.java +++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneWebAppWithJsp.java @@ -55,7 +55,7 @@ public class OneWebAppWithJsp WebAppContext webapp = new WebAppContext(); webapp.setContextPath( "/" ); File warFile = new File( - "../../jetty-distribution/target/distribution/demo-base/webapps/test.war" ); + "jetty-distribution/target/distribution/demo-base/webapps/test.war" ); if (!warFile.exists()) { throw new RuntimeException( "Unable to find WAR File: " @@ -93,7 +93,7 @@ public class OneWebAppWithJsp // itself. HashLoginService loginService = new HashLoginService(); loginService.setName( "Test Realm" ); - loginService.setConfig( "src/test/resources/realm.properties" ); + loginService.setConfig( "examples/embedded/src/test/resources/realm.properties" ); server.addBean( loginService ); // Start things up! diff --git a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationConfiguration.java b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationConfiguration.java index 6168b74b0bc..5a11e06bec3 100644 --- a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationConfiguration.java +++ b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationConfiguration.java @@ -84,9 +84,9 @@ public class AnnotationConfiguration extends AbstractConfiguration public static final int DEFAULT_MAX_SCAN_WAIT = 60; /* time in sec */ public static final boolean DEFAULT_MULTI_THREADED = true; - protected List _discoverableAnnotationHandlers = new ArrayList(); + protected final List _discoverableAnnotationHandlers = new ArrayList<>(); protected ClassInheritanceHandler _classInheritanceHandler; - protected List _containerInitializerAnnotationHandlers = new ArrayList(); + protected final List _containerInitializerAnnotationHandlers = new ArrayList<>(); protected List _parserTasks; @@ -332,29 +332,12 @@ public class AnnotationConfiguration extends AbstractConfiguration String tmp = (String)context.getAttribute(SERVLET_CONTAINER_INITIALIZER_EXCLUSION_PATTERN); _sciExcludePattern = (tmp==null?null:Pattern.compile(tmp)); } - public void addDiscoverableAnnotationHandler(AbstractDiscoverableAnnotationHandler handler) { _discoverableAnnotationHandlers.add(handler); } - @Override - public void deconfigure(WebAppContext context) throws Exception - { - context.removeAttribute(CLASS_INHERITANCE_MAP); - context.removeAttribute(CONTAINER_INITIALIZERS); - ServletContainerInitializersStarter starter = (ServletContainerInitializersStarter)context.getAttribute(CONTAINER_INITIALIZER_STARTER); - if (starter != null) - { - context.removeBean(starter); - context.removeAttribute(CONTAINER_INITIALIZER_STARTER); - } - - if (_initializers != null) - _initializers.clear(); - } - /** * @see org.eclipse.jetty.webapp.AbstractConfiguration#configure(org.eclipse.jetty.webapp.WebAppContext) */ @@ -400,15 +383,14 @@ public class AnnotationConfiguration extends AbstractConfiguration public void postConfigure(WebAppContext context) throws Exception { Map> classMap = (ClassInheritanceMap)context.getAttribute(CLASS_INHERITANCE_MAP); - List initializers = (List)context.getAttribute(CONTAINER_INITIALIZERS); - - context.removeAttribute(CLASS_INHERITANCE_MAP); if (classMap != null) classMap.clear(); - - context.removeAttribute(CONTAINER_INITIALIZERS); + context.removeAttribute(CLASS_INHERITANCE_MAP); + + List initializers = (List)context.getAttribute(CONTAINER_INITIALIZERS); if (initializers != null) initializers.clear(); + context.removeAttribute(CONTAINER_INITIALIZERS); if (_discoverableAnnotationHandlers != null) _discoverableAnnotationHandlers.clear(); @@ -422,7 +404,17 @@ public class AnnotationConfiguration extends AbstractConfiguration _parserTasks.clear(); _parserTasks = null; } - + + ServletContainerInitializersStarter starter = (ServletContainerInitializersStarter)context.getAttribute(CONTAINER_INITIALIZER_STARTER); + if (starter != null) + { + context.removeBean(starter); + context.removeAttribute(CONTAINER_INITIALIZER_STARTER); + } + + if (_initializers != null) + _initializers.clear(); + super.postConfigure(context); } diff --git a/jetty-jspc-maven-plugin/src/it/package-root/invoker.properties b/jetty-jspc-maven-plugin/src/it/package-root/invoker.properties new file mode 100644 index 00000000000..df6cbf2d0bc --- /dev/null +++ b/jetty-jspc-maven-plugin/src/it/package-root/invoker.properties @@ -0,0 +1,2 @@ +invoker.goals = test -fae +invoker.debug = true diff --git a/jetty-jspc-maven-plugin/src/it/package-root/pom.xml b/jetty-jspc-maven-plugin/src/it/package-root/pom.xml new file mode 100644 index 00000000000..9e53639c1e1 --- /dev/null +++ b/jetty-jspc-maven-plugin/src/it/package-root/pom.xml @@ -0,0 +1,43 @@ + + + 4.0.0 + + org.eclipse.jetty.its.jspc + simple-jsp + 0.0.1-SNAPSHOT + pom + + Jetty :: Simple Jsp + + + UTF-8 + UTF-8 + 1.8 + @project.version@ + + + + + + org.eclipse.jetty + jetty-jspc-maven-plugin + ${jetty.version} + + + + jspc + + compile + + + org.eclipse.jetty.test + + + + + + + + + diff --git a/jetty-jspc-maven-plugin/src/it/package-root/postbuild.groovy b/jetty-jspc-maven-plugin/src/it/package-root/postbuild.groovy new file mode 100644 index 00000000000..4a73995f2a0 --- /dev/null +++ b/jetty-jspc-maven-plugin/src/it/package-root/postbuild.groovy @@ -0,0 +1,9 @@ + + +System.out.println( "running postbuild.groovy" ) + +File file = new File( basedir, "target/classes/org/eclipse/jetty/test/foo_jsp.class" ); +if ( !file.isFile() ) +{ + throw new FileNotFoundException( "Could not find generated class in the proper package name: " + file ); +} diff --git a/jetty-jspc-maven-plugin/src/it/package-root/src/main/webapp/foo.jsp b/jetty-jspc-maven-plugin/src/it/package-root/src/main/webapp/foo.jsp new file mode 100644 index 00000000000..fb73b0b0002 --- /dev/null +++ b/jetty-jspc-maven-plugin/src/it/package-root/src/main/webapp/foo.jsp @@ -0,0 +1,23 @@ + +<%@ page import="java.util.Enumeration" %> + +

JSP Dump

+ + + + + + +<% + Enumeration e =request.getParameterNames(); + while(e.hasMoreElements()) + { + String name = (String)e.nextElement(); +%> + + + +<% } %> + +
Request URI:<%= request.getRequestURI() %>
ServletPath:<%= request.getServletPath() %>
PathInfo:<%= request.getPathInfo() %>
getParameter("<%= name %>")<%= request.getParameter(name) %>
+ diff --git a/jetty-jspc-maven-plugin/src/main/java/org/eclipse/jetty/jspc/plugin/JspcMojo.java b/jetty-jspc-maven-plugin/src/main/java/org/eclipse/jetty/jspc/plugin/JspcMojo.java index 34c75bd66ee..a8c7cc48ab3 100644 --- a/jetty-jspc-maven-plugin/src/main/java/org/eclipse/jetty/jspc/plugin/JspcMojo.java +++ b/jetty-jspc-maven-plugin/src/main/java/org/eclipse/jetty/jspc/plugin/JspcMojo.java @@ -42,7 +42,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; @@ -137,7 +136,7 @@ public class JspcMojo extends AbstractMojo * @since jetty-7.6.3 */ @Parameter(defaultValue = "${project.artifacts}", readonly = true) - private Set projectArtifacts; + private Set projectArtifacts; /** @@ -152,7 +151,7 @@ public class JspcMojo extends AbstractMojo * The artifacts for the plugin itself. */ @Parameter(defaultValue = "${plugin.artifacts}", readonly = true) - private List pluginArtifacts; + private List pluginArtifacts; /** @@ -336,7 +335,7 @@ public class JspcMojo extends AbstractMojo jspc = new JettyJspC(); - jspc.setWebXmlFragment(webXmlFragment); + jspc.setWebXmlInclude(webXmlFragment); jspc.setUriroot(webAppSourceDirectory); jspc.setOutputDir(generatedClasses); jspc.setClassLoader(fakeWebAppClassLoader); @@ -373,7 +372,7 @@ public class JspcMojo extends AbstractMojo private String getJspFiles(String webAppSourceDirectory) throws Exception { - List fileNames = FileUtils.getFileNames(new File(webAppSourceDirectory),includes, excludes, false); + List fileNames = FileUtils.getFileNames(new File(webAppSourceDirectory),includes, excludes, false); return StringUtils.join(fileNames.toArray(new String[0]), ","); } @@ -532,7 +531,7 @@ public class JspcMojo extends AbstractMojo //add the dependencies of the webapp (which will form WEB-INF/lib) for (Iterator iter = project.getArtifacts().iterator(); iter.hasNext();) { - Artifact artifact = (Artifact)iter.next(); + Artifact artifact = iter.next(); // Include runtime and compile time libraries if (!Artifact.SCOPE_TEST.equals(artifact.getScope()) && !Artifact.SCOPE_PROVIDED.equals(artifact.getScope())) diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java index efe5163c010..9fffec342be 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java @@ -295,6 +295,7 @@ public class ServletContextHandler extends ContextHandler { super.doStop(); _objFactory.clear(); + getServletContext().removeAttribute(DecoratedObjectFactory.ATTR); } /* ------------------------------------------------------------ */