Merge remote-tracking branch 'origin/master' into jetty-9.1
Conflicts: jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationParser.java jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenAnnotationConfiguration.java
This commit is contained in:
commit
c5fe3bcfd3
|
@ -692,15 +692,10 @@ public class AnnotationParser
|
||||||
parseDir(handlers, res, resolver);
|
parseDir(handlers, res, resolver);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
System.err.println("TRYING TO SCAN "+res);
|
||||||
//we've already verified the directories, so just verify the class file name
|
//we've already verified the directories, so just verify the class file name
|
||||||
boolean valid = true;
|
|
||||||
File file = res.getFile();
|
File file = res.getFile();
|
||||||
if (file == null)
|
if (isValidClassFileName((file==null?null:file.getName())))
|
||||||
LOG.warn("Unable to validate class file name for {}", res);
|
|
||||||
else
|
|
||||||
valid = isValidClassFileName(file.getName());
|
|
||||||
|
|
||||||
if (valid)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -717,6 +712,10 @@ public class AnnotationParser
|
||||||
me.add(new RuntimeException("Error scanning file "+files[f],ex));
|
me.add(new RuntimeException("Error scanning file "+files[f],ex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (LOG.isDebugEnabled()) LOG.debug("Skipping scan on invalid file {}", res);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.annotations.AnnotationConfiguration;
|
||||||
import org.eclipse.jetty.plus.webapp.EnvConfiguration;
|
import org.eclipse.jetty.plus.webapp.EnvConfiguration;
|
||||||
import org.eclipse.jetty.plus.webapp.PlusConfiguration;
|
import org.eclipse.jetty.plus.webapp.PlusConfiguration;
|
||||||
import org.eclipse.jetty.servlet.FilterHolder;
|
import org.eclipse.jetty.servlet.FilterHolder;
|
||||||
|
@ -111,7 +112,7 @@ public class JettyWebAppContext extends WebAppContext
|
||||||
new FragmentConfiguration(),
|
new FragmentConfiguration(),
|
||||||
_envConfig = new EnvConfiguration(),
|
_envConfig = new EnvConfiguration(),
|
||||||
new PlusConfiguration(),
|
new PlusConfiguration(),
|
||||||
new MavenAnnotationConfiguration(),
|
new AnnotationConfiguration(),
|
||||||
new JettyWebXmlConfiguration()
|
new JettyWebXmlConfiguration()
|
||||||
});
|
});
|
||||||
// Turn off copyWebInf option as it is not applicable for plugin.
|
// Turn off copyWebInf option as it is not applicable for plugin.
|
||||||
|
|
|
@ -1,90 +0,0 @@
|
||||||
//
|
|
||||||
// ========================================================================
|
|
||||||
// Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
// All rights reserved. This program and the accompanying materials
|
|
||||||
// are made available under the terms of the Eclipse Public License v1.0
|
|
||||||
// and Apache License v2.0 which accompanies this distribution.
|
|
||||||
//
|
|
||||||
// The Eclipse Public License is available at
|
|
||||||
// http://www.eclipse.org/legal/epl-v10.html
|
|
||||||
//
|
|
||||||
// The Apache License v2.0 is available at
|
|
||||||
// http://www.opensource.org/licenses/apache2.0.php
|
|
||||||
//
|
|
||||||
// You may elect to redistribute this code under either of these licenses.
|
|
||||||
// ========================================================================
|
|
||||||
//
|
|
||||||
|
|
||||||
package org.eclipse.jetty.maven.plugin;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.eclipse.jetty.annotations.AnnotationConfiguration;
|
|
||||||
import org.eclipse.jetty.annotations.AnnotationParser;
|
|
||||||
import org.eclipse.jetty.annotations.AnnotationParser.Handler;
|
|
||||||
import org.eclipse.jetty.util.log.Log;
|
|
||||||
import org.eclipse.jetty.util.log.Logger;
|
|
||||||
import org.eclipse.jetty.util.resource.Resource;
|
|
||||||
import org.eclipse.jetty.webapp.MetaData;
|
|
||||||
import org.eclipse.jetty.webapp.WebAppContext;
|
|
||||||
|
|
||||||
public class MavenAnnotationConfiguration extends AnnotationConfiguration
|
|
||||||
{
|
|
||||||
private static final Logger LOG = Log.getLogger(MavenAnnotationConfiguration.class);
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
@Override
|
|
||||||
public void parseWebInfClasses(final WebAppContext context, final AnnotationParser parser) throws Exception
|
|
||||||
{
|
|
||||||
JettyWebAppContext jwac = (JettyWebAppContext)context;
|
|
||||||
if (jwac.getClassPathFiles() == null || jwac.getClassPathFiles().size() == 0)
|
|
||||||
super.parseWebInfClasses (context, parser);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG.debug("Scanning classes ");
|
|
||||||
//Look for directories on the classpath and process each one of those
|
|
||||||
|
|
||||||
MetaData metaData = context.getMetaData();
|
|
||||||
if (metaData == null)
|
|
||||||
throw new IllegalStateException ("No metadata");
|
|
||||||
|
|
||||||
Set<Handler> handlers = new HashSet<Handler>();
|
|
||||||
handlers.addAll(_discoverableAnnotationHandlers);
|
|
||||||
if (_classInheritanceHandler != null)
|
|
||||||
handlers.add(_classInheritanceHandler);
|
|
||||||
handlers.addAll(_containerInitializerAnnotationHandlers);
|
|
||||||
|
|
||||||
|
|
||||||
for (File f:jwac.getClassPathFiles())
|
|
||||||
{
|
|
||||||
//scan the equivalent of the WEB-INF/classes directory that has been synthesised by the plugin
|
|
||||||
if (f.isDirectory() && f.exists())
|
|
||||||
{
|
|
||||||
doParse(handlers, context, parser, Resource.newResource(f.toURI()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//if an actual WEB-INF/classes directory also exists (eg because of overlayed wars) then scan that
|
|
||||||
//too
|
|
||||||
if (context.getWebInf() != null && context.getWebInf().exists())
|
|
||||||
{
|
|
||||||
Resource classesDir = context.getWebInf().addPath("classes/");
|
|
||||||
if (classesDir.exists())
|
|
||||||
{
|
|
||||||
doParse(handlers, context, parser, classesDir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void doParse (final Set<? extends Handler> handlers, final WebAppContext context, final AnnotationParser parser, Resource resource)
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
if (_parserTasks != null)
|
|
||||||
_parserTasks.add(new ParserTask(parser, handlers, resource, _webAppClassNameResolver));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -239,6 +239,46 @@ public class MavenWebInfConfiguration extends WebInfConfiguration
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add in the classes dirs from test/classes and target/classes
|
||||||
|
* @see org.eclipse.jetty.webapp.WebInfConfiguration#findClassDirs(org.eclipse.jetty.webapp.WebAppContext)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected List<Resource> findClassDirs(WebAppContext context) throws Exception
|
||||||
|
{
|
||||||
|
List<Resource> list = new ArrayList<Resource>();
|
||||||
|
|
||||||
|
JettyWebAppContext jwac = (JettyWebAppContext)context;
|
||||||
|
if (jwac.getClassPathFiles() != null)
|
||||||
|
{
|
||||||
|
for (File f: jwac.getClassPathFiles())
|
||||||
|
{
|
||||||
|
if (f.exists() && f.isDirectory())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
list.add(Resource.newResource(f.toURI()));
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOG.warn("Bad url ", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Resource> classesDirs = super.findClassDirs(context);
|
||||||
|
if (classesDirs != null)
|
||||||
|
list.addAll(classesDirs);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected Resource unpackOverlay (WebAppContext context, Overlay overlay)
|
protected Resource unpackOverlay (WebAppContext context, Overlay overlay)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
|
|
|
@ -1546,6 +1546,9 @@ public class Request implements HttpServletRequest
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
protected void recycle()
|
protected void recycle()
|
||||||
{
|
{
|
||||||
|
if (_context != null)
|
||||||
|
throw new IllegalStateException("Request in context!");
|
||||||
|
|
||||||
if (_inputState == __READER)
|
if (_inputState == __READER)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -1561,6 +1564,7 @@ public class Request implements HttpServletRequest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_dispatcherType=null;
|
||||||
setAuthentication(Authentication.NOT_CHECKED);
|
setAuthentication(Authentication.NOT_CHECKED);
|
||||||
getHttpChannelState().recycle();
|
getHttpChannelState().recycle();
|
||||||
if (_async!=null)
|
if (_async!=null)
|
||||||
|
@ -1568,8 +1572,6 @@ public class Request implements HttpServletRequest
|
||||||
_async=null;
|
_async=null;
|
||||||
_asyncSupported = true;
|
_asyncSupported = true;
|
||||||
_handled = false;
|
_handled = false;
|
||||||
if (_context != null)
|
|
||||||
throw new IllegalStateException("Request in context!");
|
|
||||||
if (_attributes != null)
|
if (_attributes != null)
|
||||||
_attributes.clearAttributes();
|
_attributes.clearAttributes();
|
||||||
_characterEncoding = null;
|
_characterEncoding = null;
|
||||||
|
@ -1578,7 +1580,9 @@ public class Request implements HttpServletRequest
|
||||||
_cookies.reset();
|
_cookies.reset();
|
||||||
_cookiesExtracted = false;
|
_cookiesExtracted = false;
|
||||||
_context = null;
|
_context = null;
|
||||||
|
_newContext=false;
|
||||||
_serverName = null;
|
_serverName = null;
|
||||||
|
_httpMethod=null;
|
||||||
_httpMethodString = null;
|
_httpMethodString = null;
|
||||||
_pathInfo = null;
|
_pathInfo = null;
|
||||||
_port = 0;
|
_port = 0;
|
||||||
|
@ -1587,6 +1591,7 @@ public class Request implements HttpServletRequest
|
||||||
_queryString = null;
|
_queryString = null;
|
||||||
_requestedSessionId = null;
|
_requestedSessionId = null;
|
||||||
_requestedSessionIdFromCookie = false;
|
_requestedSessionIdFromCookie = false;
|
||||||
|
_secure=false;
|
||||||
_session = null;
|
_session = null;
|
||||||
_sessionManager = null;
|
_sessionManager = null;
|
||||||
_requestURI = null;
|
_requestURI = null;
|
||||||
|
|
Loading…
Reference in New Issue