Merge remote-tracking branch 'origin/jetty-9.4.x' into jetty-10.0.x

This commit is contained in:
Greg Wilkins 2018-11-28 13:05:57 +01:00
commit c9d5b91c79
8 changed files with 102 additions and 33 deletions

View File

@ -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!

View File

@ -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<AbstractDiscoverableAnnotationHandler> _discoverableAnnotationHandlers = new ArrayList<AbstractDiscoverableAnnotationHandler>();
protected final List<AbstractDiscoverableAnnotationHandler> _discoverableAnnotationHandlers = new ArrayList<>();
protected ClassInheritanceHandler _classInheritanceHandler;
protected List<ContainerInitializerAnnotationHandler> _containerInitializerAnnotationHandlers = new ArrayList<ContainerInitializerAnnotationHandler>();
protected final List<ContainerInitializerAnnotationHandler> _containerInitializerAnnotationHandlers = new ArrayList<>();
protected List<ParserTask> _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<String, Set<String>> classMap = (ClassInheritanceMap)context.getAttribute(CLASS_INHERITANCE_MAP);
List<ContainerInitializer> initializers = (List<ContainerInitializer>)context.getAttribute(CONTAINER_INITIALIZERS);
context.removeAttribute(CLASS_INHERITANCE_MAP);
if (classMap != null)
classMap.clear();
context.removeAttribute(CONTAINER_INITIALIZERS);
context.removeAttribute(CLASS_INHERITANCE_MAP);
List<ContainerInitializer> initializers = (List<ContainerInitializer>)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);
}

View File

@ -0,0 +1,2 @@
invoker.goals = test -fae
invoker.debug = true

View File

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.eclipse.jetty.its.jspc</groupId>
<artifactId>simple-jsp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Jetty :: Simple Jsp</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<jetty.version>@project.version@</jetty.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jspc-maven-plugin</artifactId>
<version>${jetty.version}</version>
<executions>
<execution>
<goals>
<goal>jspc</goal>
</goals>
<phase>compile</phase>
<configuration>
<jspc>
<package>org.eclipse.jetty.test</package>
</jspc>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -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 );
}

View File

@ -0,0 +1,23 @@
<html><head>
<%@ page import="java.util.Enumeration" %>
</head><body>
<h1>JSP Dump</h1>
<table border="1">
<tr><th>Request URI:</th><td><%= request.getRequestURI() %></td></tr>
<tr><th>ServletPath:</th><td><%= request.getServletPath() %></td></tr>
<tr><th>PathInfo:</th><td><%= request.getPathInfo() %></td></tr>
<%
Enumeration e =request.getParameterNames();
while(e.hasMoreElements())
{
String name = (String)e.nextElement();
%>
<tr>
<th>getParameter("<%= name %>")</th>
<td><%= request.getParameter(name) %></td></tr>
<% } %>
</table>
</body></html>

View File

@ -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<Artifact> 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<Artifact> 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<String> 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<Artifact> 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()))

View File

@ -295,6 +295,7 @@ public class ServletContextHandler extends ContextHandler
{
super.doStop();
_objFactory.clear();
getServletContext().removeAttribute(DecoratedObjectFactory.ATTR);
}
/* ------------------------------------------------------------ */