Merge branch 'jetty-10.0.x' into jetty-11.0.x

This commit is contained in:
olivier lamy 2020-04-02 12:40:18 +10:00
commit a22f2475e3
5 changed files with 16 additions and 11 deletions

View File

@ -118,25 +118,25 @@ public class TestAnnotationConfiguration
@Test
public void testAnnotationScanControl() throws Exception
{
//check that a 2.5 webapp won't discover annotations
//check that a 2.5 webapp with configurationDiscovered will discover annotations
TestableAnnotationConfiguration config25 = new TestableAnnotationConfiguration();
WebAppContext context25 = new WebAppContext();
context25.setClassLoader(Thread.currentThread().getContextClassLoader());
context25.setAttribute(AnnotationConfiguration.MULTI_THREADED, Boolean.FALSE);
context25.setAttribute(AnnotationConfiguration.MAX_SCAN_WAIT, 0);
context25.setConfigurationDiscovered(false);
context25.getMetaData().setWebDescriptor(new WebDescriptor(Resource.newResource(web25)));
context25.getServletContext().setEffectiveMajorVersion(2);
context25.getServletContext().setEffectiveMinorVersion(5);
config25.configure(context25);
config25.assertAnnotationDiscovery(false);
//check that a 2.5 webapp with configurationDiscovered will discover annotations
//check that a 2.5 webapp discover annotations
TestableAnnotationConfiguration config25b = new TestableAnnotationConfiguration();
WebAppContext context25b = new WebAppContext();
context25b.setClassLoader(Thread.currentThread().getContextClassLoader());
context25b.setAttribute(AnnotationConfiguration.MULTI_THREADED, Boolean.FALSE);
context25b.setAttribute(AnnotationConfiguration.MAX_SCAN_WAIT, 0);
context25b.setConfigurationDiscovered(true);
context25b.getMetaData().setWebDescriptor(new WebDescriptor(Resource.newResource(web25)));
context25b.getServletContext().setEffectiveMajorVersion(2);
context25b.getServletContext().setEffectiveMinorVersion(5);
@ -293,6 +293,7 @@ public class TestAnnotationConfiguration
AnnotationConfiguration config = new AnnotationConfiguration();
WebAppContext context = new WebAppContext();
List<ServletContainerInitializer> scis;
context.setConfigurationDiscovered(false);
context.setClassLoader(webAppLoader);
context.getMetaData().setWebDescriptor(new WebDescriptor(Resource.newResource(web25)));
context.getMetaData().setWebInfClassesResources(classes);

View File

@ -121,9 +121,8 @@ As is the case with annotation scanning, the link:#using-extra-classpath-method[
____
[NOTE]
As of Jetty-9.4.4, unless the `web.xml` is version 3.0 or greater, only `ServletContainerInitializers` that are on the container classpath will be discovered.
Users wishing to use `ServletContainerInitializers` from within the webapp with older versions of `web.xml` must either upgrade their `web.xml` version, or call `WebAppContext.setConfigurationDiscovered(true)` either programmatically or in xml.
Upgrading the `web.xml` version is preferable.
As of Jetty 10, Annotations will be discovered even for old versions of `web.xml` (2.5).
Users wishing not to use annotations from the webapp classpath must call `WebAppContext.setConfigurationDiscovered(false)` either programmatically or in xml.
____
===== Controlling the order of ServletContainerInitializer invocation

View File

@ -23,9 +23,14 @@ It is not comprehensive, but covers many of the major changes included in the re
==== Required Java Version
Jetty 10 requires, at a minimum, Java 9 to function.
Jetty 10 requires, at a minimum, Java 11 to function.
Items such as the Java Platform Module System (JPMS), which Jetty 10 supports, are not available in earlier versions of Java.
==== ServletContainerInitializers
As of Jetty 10, Annotations will be discovered even for old versions of `web.xml` (2.5).
Users wishing not to use annotations from the webapp classpath with older versions of `web.xml` must call `WebAppContext.setConfigurationDiscovered(false)` either programmatically or in xml.
==== Removed Classes
//TODO - Insert major removed/refactored classes from Jetty-9.x.x to Jetty-10.0.x

View File

@ -209,7 +209,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
private Map<String, String> _resourceAliases;
private boolean _ownClassLoader = false;
private boolean _configurationDiscovered = false;
private boolean _configurationDiscovered = true;
private boolean _allowDuplicateFragmentNames = false;
private boolean _throwUnavailableOnStartupException = false;

View File

@ -84,20 +84,20 @@ public class MetaInfConfigurationTest
File web31 = MavenTestingUtils.getTestResourceFile("web31.xml");
File web31false = MavenTestingUtils.getTestResourceFile("web31false.xml");
//test a 2.5 webapp will not look for fragments by default
//test a 2.5 webapp will not look for fragments as manually configured
MetaInfConfiguration meta25 = new TestableMetaInfConfiguration(MetaInfConfiguration.__allScanTypes,
Arrays.asList(MetaInfConfiguration.METAINF_TLDS, MetaInfConfiguration.METAINF_RESOURCES));
WebAppContext context25 = new WebAppContext();
context25.setConfigurationDiscovered(false);
context25.getMetaData().setWebDescriptor(new WebDescriptor(Resource.newResource(web25)));
context25.getServletContext().setEffectiveMajorVersion(2);
context25.getServletContext().setEffectiveMinorVersion(5);
meta25.preConfigure(context25);
//test a 2.5 webapp will look for fragments if configurationDiscovered==true
//test a 2.5 webapp will look for fragments as configurationDiscovered default true
MetaInfConfiguration meta25b = new TestableMetaInfConfiguration(MetaInfConfiguration.__allScanTypes,
MetaInfConfiguration.__allScanTypes);
WebAppContext context25b = new WebAppContext();
context25b.setConfigurationDiscovered(true);
context25b.getMetaData().setWebDescriptor(new WebDescriptor(Resource.newResource(web25)));
context25b.getServletContext().setEffectiveMajorVersion(2);
context25b.getServletContext().setEffectiveMinorVersion(5);