diff --git a/jetty-core/jetty-ee/src/main/java/org/eclipse/jetty/ee/WebAppClassLoading.java b/jetty-core/jetty-ee/src/main/java/org/eclipse/jetty/ee/WebAppClassLoading.java index eaf13e52a64a..dcdac85af037 100644 --- a/jetty-core/jetty-ee/src/main/java/org/eclipse/jetty/ee/WebAppClassLoading.java +++ b/jetty-core/jetty-ee/src/main/java/org/eclipse/jetty/ee/WebAppClassLoading.java @@ -169,8 +169,9 @@ public static void addHiddenClasses(String... patterns) * Add a hidden (server) Class pattern to use for all WebAppContexts of a given {@link Server}. * @param attributes The {@link Attributes} instance to add classes to * @param patterns the patterns to use + * @deprecated use {@link #addHiddenClasses(Server, String...)} instead */ - @Deprecated (forRemoval = true) + @Deprecated (since = "12.0.9", forRemoval = true) public static void addHiddenClasses(Attributes attributes, String... patterns) { if (patterns != null && patterns.length > 0) diff --git a/jetty-ee10/jetty-ee10-cdi/src/main/java/org/eclipse/jetty/ee10/cdi/CdiConfiguration.java b/jetty-ee10/jetty-ee10-cdi/src/main/java/org/eclipse/jetty/ee10/cdi/CdiConfiguration.java index 07370998d8d1..32ed6ef47c4f 100644 --- a/jetty-ee10/jetty-ee10-cdi/src/main/java/org/eclipse/jetty/ee10/cdi/CdiConfiguration.java +++ b/jetty-ee10/jetty-ee10-cdi/src/main/java/org/eclipse/jetty/ee10/cdi/CdiConfiguration.java @@ -13,8 +13,6 @@ package org.eclipse.jetty.ee10.cdi; -import java.util.function.Predicate; - import org.eclipse.jetty.ee10.annotations.AnnotationConfiguration; import org.eclipse.jetty.ee10.plus.webapp.PlusConfiguration; import org.eclipse.jetty.ee10.webapp.AbstractConfiguration; @@ -33,11 +31,11 @@ public CdiConfiguration() { super(new Builder() .protectAndExpose("org.eclipse.jetty.ee10.cdi.CdiServletContainerInitializer") - .hide(getHiddenClasses()) + .hide(getCdiHiddenClasses()) .addDependents(AnnotationConfiguration.class, PlusConfiguration.class)); } - private static String[] getHiddenClasses() + private static String[] getCdiHiddenClasses() { //Only hide the cdi api classes if there is not also an impl on the //environment classpath - vital for embedded uses. @@ -45,4 +43,4 @@ private static String[] getHiddenClasses() return new String[]{"jakarta.enterprise.", "jakarta.decorator."}; return new String[0]; } -} \ No newline at end of file +} diff --git a/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/AbstractConfiguration.java b/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/AbstractConfiguration.java index 2db4056c8bd9..5929ce18aa1e 100644 --- a/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/AbstractConfiguration.java +++ b/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/AbstractConfiguration.java @@ -19,13 +19,15 @@ import java.util.Collections; import java.util.List; +import org.eclipse.jetty.util.ClassMatcher; + public class AbstractConfiguration implements Configuration { private final boolean _enabledByDefault; private final List _after; private final List _before; - private final ClassMatcher _system; - private final ClassMatcher _server; + private final ClassMatcher _protected; + private final ClassMatcher _hidden; public static class Builder { @@ -88,7 +90,7 @@ public Builder addDependents(Class... classes) /** * Protect classes from modification by the web application by adding them - * to the {@link WebAppConfiguration#getSystemClasses()} + * to the {@link WebAppConfiguration#getProtectedClasses()} * * @param classes classname or package pattern */ @@ -100,7 +102,7 @@ public Builder protect(String... classes) /** * Hide classes from the web application by adding them - * to the {@link WebAppConfiguration#getServerClasses()} + * to the {@link WebAppConfiguration#getHiddenClasses()} * * @param classes classname or package pattern */ @@ -112,7 +114,7 @@ public Builder hide(String... classes) /** * Expose classes to the web application by adding them - * as exclusions to the {@link WebAppConfiguration#getServerClasses()} + * as exclusions to the {@link WebAppConfiguration#getHiddenClasses()} * * @param classes classname or package pattern */ @@ -129,9 +131,9 @@ public Builder expose(String... classes) /** * Protect classes from modification by the web application by adding them - * to the {@link WebAppConfiguration#getSystemClasses()} and + * to the {@link WebAppConfiguration#getHiddenClasses()} and * expose them to the web application by adding them - * as exclusions to the {@link WebAppConfiguration#getServerClasses()} + * as exclusions to the {@link WebAppConfiguration#getHiddenClasses()} * * @param classes classname or package pattern */ @@ -154,8 +156,8 @@ protected AbstractConfiguration(Builder builder) _enabledByDefault = builder._enabledByDefault; _after = List.copyOf(builder._after); _before = List.copyOf(builder._before); - _system = new ClassMatcher(builder._system).asImmutable(); - _server = new ClassMatcher(builder._server).asImmutable(); + _protected = new ClassMatcher(builder._system).asImmutable(); + _hidden = new ClassMatcher(builder._server).asImmutable(); } @Override @@ -171,15 +173,15 @@ public Collection getDependencies() } @Override - public ClassMatcher getSystemClasses() + public ClassMatcher getProtectedClasses() { - return _system; + return _protected; } @Override - public ClassMatcher getServerClasses() + public ClassMatcher getHiddenClasses() { - return _server; + return _hidden; } @Override diff --git a/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/ClassMatcher.java b/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/ClassMatcher.java index 23a625dcd1c3..3eb611146b6f 100644 --- a/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/ClassMatcher.java +++ b/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/ClassMatcher.java @@ -21,7 +21,6 @@ /** * @deprecated Use org.eclipse.jetty.util.ClassMatcher */ - @Deprecated(since = "12.0.8", forRemoval = true) public class ClassMatcher extends org.eclipse.jetty.util.ClassMatcher { diff --git a/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/Configuration.java b/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/Configuration.java index ca8e4934ecdb..1e92b56f68d9 100644 --- a/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/Configuration.java +++ b/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/Configuration.java @@ -17,6 +17,7 @@ import java.util.Collections; import java.util.ServiceLoader; +import org.eclipse.jetty.util.ClassMatcher; import org.eclipse.jetty.util.TopologicalSort; /** @@ -43,8 +44,8 @@ * (eg {@link JndiConfiguration}, {@link JaasConfiguration}} etc.) can be added or removed without concern * for ordering. *

- *

Also since Jetty-9.4, Configurations are responsible for providing {@link #getServerClasses()} and - * {@link #getSystemClasses()} to configure the {@link WebAppClassLoader} for each context. + *

Also since Jetty-9.4, Configurations are responsible for providing {@link #getHiddenClasses()} and + * {@link #getHiddenClasses()} to configure the {@link WebAppClassLoader} for each context. *

*/ public interface Configuration @@ -93,25 +94,43 @@ default Collection getDependents() } /** - * Get the system classes associated with this Configuration. + * Get the system (protected) classes associated with this Configuration. * * @return ClassMatcher of system classes. */ - default ClassMatcher getSystemClasses() + default ClassMatcher getProtectedClasses() { return new ClassMatcher(); } /** - * Get the system classes associated with this Configuration. + * Get the system (hidden) classes associated with this Configuration. * * @return ClassMatcher of server classes. */ - default ClassMatcher getServerClasses() + default ClassMatcher getHiddenClasses() { return new ClassMatcher(); } + /** + * @deprecated use {@link #getProtectedClasses()} instead + */ + @Deprecated(since = "12.0.8", forRemoval = true) + default org.eclipse.jetty.ee10.webapp.ClassMatcher getSystemClasses() + { + return new org.eclipse.jetty.ee10.webapp.ClassMatcher(getProtectedClasses()); + } + + /** + * @deprecated use {@link #getHiddenClasses()} instead + */ + @Deprecated(since = "12.0.8", forRemoval = true) + default org.eclipse.jetty.ee10.webapp.ClassMatcher getServerClasses() + { + return new org.eclipse.jetty.ee10.webapp.ClassMatcher(getHiddenClasses()); + } + /** * Set up for configuration. *

diff --git a/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/WebAppClassLoader.java b/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/WebAppClassLoader.java index a1ad3d32d9af..82e14887a483 100644 --- a/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/WebAppClassLoader.java +++ b/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/WebAppClassLoader.java @@ -20,28 +20,24 @@ import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; -import java.nio.file.Files; import java.nio.file.Path; import java.security.CodeSource; import java.security.PermissionCollection; import java.security.PrivilegedExceptionAction; import java.util.ArrayList; import java.util.Collections; -import java.util.Comparator; import java.util.Enumeration; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.StringTokenizer; import java.util.concurrent.CopyOnWriteArrayList; -import java.util.stream.Stream; import org.eclipse.jetty.util.ClassVisibilityChecker; import org.eclipse.jetty.util.FileID; import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.TypeUtil; -import org.eclipse.jetty.util.URIUtil; import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.resource.ResourceCollators; import org.eclipse.jetty.util.resource.ResourceFactory; @@ -115,9 +111,33 @@ public interface Context extends ClassVisibilityChecker List getExtraClasspath(); - boolean isHiddenResource(String name, URL parentUrl); + /** + * @deprecated use {@link #isHiddenResource(String, URL)} + */ + @Deprecated(since = "12.0.8", forRemoval = true) + default boolean isServerResource(String name, URL parentUrl) + { + return isHiddenResource(name, parentUrl); + } + + /** + * @deprecated use {@link #isProtectedResource(String, URL)} + */ + @Deprecated(since = "12.0.8", forRemoval = true) + default boolean isSystemResource(String name, URL webappUrl) + { + return isProtectedResource(name, webappUrl); + } - boolean isProtectedResource(String name, URL webappUrl); + default boolean isHiddenResource(String name, URL parentUrl) + { + return false; + } + + default boolean isProtectedResource(String name, URL webappUrl) + { + return false; + } } /** diff --git a/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/WebAppContext.java b/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/WebAppContext.java index 473eca9595b0..53081d51dc39 100644 --- a/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/WebAppContext.java +++ b/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/WebAppContext.java @@ -425,7 +425,7 @@ public void preConfigure() throws Exception // Add the known server class inclusions for all known configurations for (Configuration configuration : Configurations.getKnown()) { - _hiddenClasses.include(configuration.getServerClasses().getInclusions()); + _hiddenClasses.include(configuration.getHiddenClasses().getInclusions()); } // Setup Configuration classes for this webapp! @@ -433,8 +433,8 @@ public void preConfigure() throws Exception _configurations.sort(); for (Configuration configuration : _configurations) { - _protectedClasses.add(configuration.getSystemClasses().getPatterns()); - _hiddenClasses.exclude(configuration.getServerClasses().getExclusions()); + _protectedClasses.add(configuration.getProtectedClasses().getPatterns()); + _hiddenClasses.exclude(configuration.getHiddenClasses().getExclusions()); } // Configure classloader @@ -620,9 +620,9 @@ public PermissionCollection getPermissions() } /** - * Set the hidden (aka server) classes patterns. + * Set the hidden (server) classes patterns. *

- * These classes/packages are used to implement the server and are hiddenClasses + * These classes/packages are used to implement the server and are hidden * from the context. If the context needs to load these classes, it must have its * own copy of them in WEB-INF/lib or WEB-INF/classes. * @@ -635,7 +635,7 @@ public void setHiddenClassMatcher(ClassMatcher hiddenClasses) } /** - * Set the protected (aka system) classes patterns. + * Set the protected (system) classes patterns. *

* These classes/packages are provided by the JVM and * cannot be replaced by classes of the same name from WEB-INF, @@ -680,7 +680,7 @@ public ClassMatcher getProtectedClassMatcher() } /** - * @return The ClassMatcher used to match Server (hiddenClasses) classes + * @return The ClassMatcher used to match Server (hidden) classes */ public ClassMatcher getHiddenClassMatcher() { @@ -693,7 +693,7 @@ public String[] getProtectedClasses() return _protectedClasses.getPatterns(); } - @ManagedAttribute(value = "classes and packages hiddenClasses by the context classloader", readonly = true) + @ManagedAttribute(value = "classes and packages hidden by the context classloader", readonly = true) public String[] getHiddenClasses() { return _hiddenClasses.getPatterns(); @@ -727,56 +727,54 @@ public boolean isProtectedResource(String name, URL url) * @deprecated use {@link #setHiddenClassMatcher(ClassMatcher)} */ @Deprecated(since = "12.0.8", forRemoval = true) - public void setServerClassMatcher(ClassMatcher serverClasses) + public void setServerClassMatcher(org.eclipse.jetty.ee10.webapp.ClassMatcher serverClasses) { - _hiddenClasses.clear(); - _hiddenClasses.add(serverClasses.getPatterns()); + setHiddenClassMatcher(serverClasses); } /** * @deprecated use {@link #setProtectedClassMatcher(ClassMatcher)} */ @Deprecated(since = "12.0.8", forRemoval = true) - public void setSystemClassMatcher(ClassMatcher systemClasses) + public void setSystemClassMatcher(org.eclipse.jetty.ee10.webapp.ClassMatcher systemClasses) { - _protectedClasses.clear(); - _protectedClasses.add(systemClasses.getPatterns()); + setProtectedClassMatcher(systemClasses); } /** * @deprecated use {@link #addHiddenClassMatcher(ClassMatcher)} */ @Deprecated(since = "12.0.8", forRemoval = true) - public void addServerClassMatcher(ClassMatcher serverClasses) + public void addServerClassMatcher(org.eclipse.jetty.ee10.webapp.ClassMatcher serverClasses) { - _hiddenClasses.add(serverClasses.getPatterns()); + addHiddenClassMatcher(serverClasses); } /** * @deprecated use {@link #addProtectedClassMatcher(ClassMatcher)} */ @Deprecated(since = "12.0.8", forRemoval = true) - public void addSystemClassMatcher(ClassMatcher systemClasses) + public void addSystemClassMatcher(org.eclipse.jetty.ee10.webapp.ClassMatcher systemClasses) { - _protectedClasses.add(systemClasses.getPatterns()); + addProtectedClassMatcher(systemClasses); } /** * @deprecated use {@link #getProtectedClassMatcher()} */ @Deprecated(since = "12.0.8", forRemoval = true) - public ClassMatcher getSystemClassMatcher() + public org.eclipse.jetty.ee10.webapp.ClassMatcher getSystemClassMatcher() { - return _protectedClasses; + return new org.eclipse.jetty.ee10.webapp.ClassMatcher(getProtectedClassMatcher()); } /** * @deprecated use {@link #getHiddenClassMatcher()} */ @Deprecated(since = "12.0.8", forRemoval = true) - public ClassMatcher getServerClassMatcher() + public org.eclipse.jetty.ee10.webapp.ClassMatcher getServerClassMatcher() { - return _hiddenClasses; + return new org.eclipse.jetty.ee10.webapp.ClassMatcher(getHiddenClassMatcher()); } /** @@ -785,7 +783,7 @@ public ClassMatcher getServerClassMatcher() @Deprecated(since = "12.0.8", forRemoval = true) public String[] getSystemClasses() { - return _protectedClasses.getPatterns(); + return getProtectedClasses(); } /** @@ -794,7 +792,7 @@ public String[] getSystemClasses() @Deprecated(since = "12.0.8", forRemoval = true) public String[] getServerClasses() { - return _hiddenClasses.getPatterns(); + return getHiddenClasses(); } /** @@ -803,7 +801,7 @@ public String[] getServerClasses() @Deprecated(since = "12.0.8", forRemoval = true) public boolean isServerClass(Class clazz) { - return _hiddenClasses.match(clazz); + return isHiddenClass(clazz); } /** @@ -812,25 +810,7 @@ public boolean isServerClass(Class clazz) @Deprecated(since = "12.0.8", forRemoval = true) public boolean isSystemClass(Class clazz) { - return _protectedClasses.match(clazz); - } - - /** - * @deprecated use {@link #isHiddenResource(String, URL)} - */ - @Deprecated(since = "12.0.8", forRemoval = true) - public boolean isServerResource(String name, URL url) - { - return _hiddenClasses.match(name, url); - } - - /** - * @deprecated use {@link #isProtectedResource(String, URL)} - */ - @Deprecated(since = "12.0.8", forRemoval = true) - public boolean isSystemResource(String name, URL url) - { - return _protectedClasses.match(name, url); + return isProtectedClass(clazz); } @Override diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-proxy-webapp/src/test/java/org/eclipse/jetty/ee9/demos/ProxyWebAppTest.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-proxy-webapp/src/test/java/org/eclipse/jetty/ee9/demos/ProxyWebAppTest.java index 78ec5592f3b9..0848380e77b1 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-proxy-webapp/src/test/java/org/eclipse/jetty/ee9/demos/ProxyWebAppTest.java +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-proxy-webapp/src/test/java/org/eclipse/jetty/ee9/demos/ProxyWebAppTest.java @@ -57,7 +57,7 @@ public void setup() throws Exception // This is a pieced together WebApp. // We don't have a valid WEB-INF/lib to rely on at this point. // So, open up server classes here, for purposes of this testcase. - webapp.getServerClassMatcher().add("-org.eclipse.jetty.ee9.proxy."); + webapp.getHiddenClassMatcher().add("-org.eclipse.jetty.ee9.proxy."); // Default location (EE9) Path webappDir = MavenTestingUtils.getBasePath().resolve("src/main/webapp"); if (!Files.exists(webappDir)) diff --git a/jetty-ee9/jetty-ee9-plus/src/test/java/org/eclipse/jetty/ee9/plus/webapp/PlusDescriptorProcessorTest.java b/jetty-ee9/jetty-ee9-plus/src/test/java/org/eclipse/jetty/ee9/plus/webapp/PlusDescriptorProcessorTest.java index 4a84332199da..6892cbc29f0b 100644 --- a/jetty-ee9/jetty-ee9-plus/src/test/java/org/eclipse/jetty/ee9/plus/webapp/PlusDescriptorProcessorTest.java +++ b/jetty-ee9/jetty-ee9-plus/src/test/java/org/eclipse/jetty/ee9/plus/webapp/PlusDescriptorProcessorTest.java @@ -129,7 +129,7 @@ public void setUp() throws Exception context.setConfigurations(new Configuration[]{new PlusConfiguration(), new EnvConfiguration()}); context.preConfigure(); context.setClassLoader(new WebAppClassLoader(Thread.currentThread().getContextClassLoader(), context)); - context.getServerClassMatcher().exclude("org.eclipse.jetty.ee9.plus.webapp."); //need visbility of the TestInjections class + context.getHiddenClassMatcher().exclude("org.eclipse.jetty.ee9.plus.webapp."); //need visbility of the TestInjections class ClassLoader oldLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(context.getClassLoader()); Context icontext = new InitialContext(); diff --git a/jetty-ee9/jetty-ee9-quickstart/src/test/java/org/eclipse/jetty/ee9/quickstart/TestQuickStart.java b/jetty-ee9/jetty-ee9-quickstart/src/test/java/org/eclipse/jetty/ee9/quickstart/TestQuickStart.java index 1040160a5ebf..4a58dc4e3acd 100644 --- a/jetty-ee9/jetty-ee9-quickstart/src/test/java/org/eclipse/jetty/ee9/quickstart/TestQuickStart.java +++ b/jetty-ee9/jetty-ee9-quickstart/src/test/java/org/eclipse/jetty/ee9/quickstart/TestQuickStart.java @@ -89,7 +89,7 @@ public void testProgrammaticOverrideOfDefaultServletMapping() throws Exception WebAppContext webapp = new WebAppContext(); webapp.setResourceBase(testDir.getAbsolutePath()); webapp.addConfiguration(new QuickStartConfiguration()); - webapp.getServerClassMatcher().exclude("org.eclipse.jetty.ee9.quickstart."); + webapp.getHiddenClassMatcher().exclude("org.eclipse.jetty.ee9.quickstart."); webapp.setAttribute(QuickStartConfiguration.MODE, QuickStartConfiguration.Mode.QUICKSTART); //add in the servlet webapp.getServletHandler().addServlet(fooHolder); @@ -139,7 +139,7 @@ public void testDefaultContextPath() throws Exception webapp.addConfiguration(new QuickStartConfiguration()); webapp.setAttribute(QuickStartConfiguration.MODE, QuickStartConfiguration.Mode.QUICKSTART); webapp.setResourceBase(testDir.getAbsolutePath()); - webapp.getServerClassMatcher().exclude("org.eclipse.jetty.ee9.quickstart."); + webapp.getHiddenClassMatcher().exclude("org.eclipse.jetty.ee9.quickstart."); server.setHandler(webapp); server.setDryRun(false); @@ -180,7 +180,7 @@ public void testDefaultRequestAndResponseEncodings() throws Exception webapp.addConfiguration(new QuickStartConfiguration()); webapp.setAttribute(QuickStartConfiguration.MODE, QuickStartConfiguration.Mode.QUICKSTART); webapp.setResourceBase(testDir.getAbsolutePath()); - webapp.getServerClassMatcher().exclude("org.eclipse.jetty.ee9.quickstart."); + webapp.getHiddenClassMatcher().exclude("org.eclipse.jetty.ee9.quickstart."); server.setHandler(webapp); server.setDryRun(false); @@ -255,7 +255,7 @@ public void testDuplicateGenerationFromContextXml() throws Exception //a freshly applied context xml quickstart = new WebAppContext(); //need visibility of FooServlet, FooFilter, FooContextListener when we quickstart - quickstart.getServerClassMatcher().exclude("org.eclipse.jetty.ee9.quickstart."); + quickstart.getHiddenClassMatcher().exclude("org.eclipse.jetty.ee9.quickstart."); quickstart.addConfiguration(new QuickStartConfiguration()); quickstart.setWar(testDir.toURI().toURL().toExternalForm()); quickstart.setDescriptor(MavenTestingUtils.getTargetFile("test-classes/web.xml").getAbsolutePath()); diff --git a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-cdi/src/test/java/org/eclipse/jetty/ee9/cdi/tests/EmbeddedWeldTest.java b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-cdi/src/test/java/org/eclipse/jetty/ee9/cdi/tests/EmbeddedWeldTest.java index c9978cbec67d..b5e8c07b852e 100644 --- a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-cdi/src/test/java/org/eclipse/jetty/ee9/cdi/tests/EmbeddedWeldTest.java +++ b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-cdi/src/test/java/org/eclipse/jetty/ee9/cdi/tests/EmbeddedWeldTest.java @@ -202,8 +202,8 @@ public void testWebappContext() throws Exception webapp.addBean(new ServletContextHandler.Initializer(webapp, new org.jboss.weld.environment.servlet.EnhancedListener())); String pkg = EmbeddedWeldTest.class.getPackage().getName(); - webapp.getServerClassMatcher().add("-" + pkg + "."); - webapp.getSystemClassMatcher().add(pkg + "."); + webapp.getHiddenClassMatcher().add("-" + pkg + "."); + webapp.getProtectedClassMatcher().add(pkg + "."); webapp.addServlet(GreetingsServlet.class, "/greet"); webapp.addFilter(MyFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)); @@ -238,8 +238,8 @@ public void testWebappContextDiscovered() throws Exception // This is ugly but needed for maven for testing in a overlaid war pom String pkg = EmbeddedWeldTest.class.getPackage().getName(); - webapp.getServerClassMatcher().add("-" + pkg + "."); - webapp.getSystemClassMatcher().add(pkg + "."); + webapp.getHiddenClassMatcher().add("-" + pkg + "."); + webapp.getProtectedClassMatcher().add(pkg + "."); webapp.getServletHandler().addListener(new ListenerHolder(MyContextListener.class)); webapp.addFilter(MyFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)); diff --git a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/AbstractConfiguration.java b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/AbstractConfiguration.java index 2d5db6c60989..d49b379fe05c 100644 --- a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/AbstractConfiguration.java +++ b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/AbstractConfiguration.java @@ -19,13 +19,15 @@ import java.util.List; import java.util.stream.Collectors; +import org.eclipse.jetty.util.ClassMatcher; + public class AbstractConfiguration implements Configuration { private final boolean _enabledByDefault; private final List _after = new ArrayList<>(); private final List _beforeThis = new ArrayList<>(); - private final ClassMatcher _system = new ClassMatcher(); - private final ClassMatcher _server = new ClassMatcher(); + private final ClassMatcher _protected = new ClassMatcher(); + private final ClassMatcher _hidden = new ClassMatcher(); protected AbstractConfiguration() { @@ -85,29 +87,29 @@ protected void addDependents(Class... classes) /** * Protect classes from modification by the web application by adding them - * to the {@link WebAppConfiguration#getSystemClasses()} + * to the {@link WebAppConfiguration#getProtectedClasses()} * * @param classes classname or package pattern */ protected void protect(String... classes) { - _system.add(classes); + _protected.add(classes); } /** * Hide classes from the web application by adding them - * to the {@link WebAppConfiguration#getServerClasses()} + * to the {@link WebAppConfiguration#getHiddenClasses()} * * @param classes classname or package pattern */ protected void hide(String... classes) { - _server.add(classes); + _hidden.add(classes); } /** * Expose classes to the web application by adding them - * as exclusions to the {@link WebAppConfiguration#getServerClasses()} + * as exclusions to the {@link WebAppConfiguration#getHiddenClasses()} * * @param classes classname or package pattern */ @@ -117,15 +119,15 @@ protected void expose(String... classes) { if (c.startsWith("-")) throw new IllegalArgumentException(); - _server.add("-" + c); + _hidden.add("-" + c); } } /** * Protect classes from modification by the web application by adding them - * to the {@link WebAppConfiguration#getSystemClasses()} and + * to the {@link WebAppConfiguration#getProtectedClasses()} and * expose them to the web application by adding them - * as exclusions to the {@link WebAppConfiguration#getServerClasses()} + * as exclusions to the {@link WebAppConfiguration#getHiddenClasses()} * * @param classes classname or package pattern */ @@ -136,8 +138,8 @@ protected void protectAndExpose(String... classes) if (c.startsWith("-")) throw new IllegalArgumentException(); - _system.add(c); - _server.add("-" + c); + _protected.add(c); + _hidden.add("-" + c); } } @@ -154,15 +156,15 @@ public Collection getDependencies() } @Override - public ClassMatcher getSystemClasses() + public ClassMatcher getProtectedClasses() { - return _system; + return _protected; } @Override - public ClassMatcher getServerClasses() + public ClassMatcher getHiddenClasses() { - return _server; + return _hidden; } @Override diff --git a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/ClassMatcher.java b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/ClassMatcher.java index d382b4cf4ac1..733f559c296a 100644 --- a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/ClassMatcher.java +++ b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/ClassMatcher.java @@ -21,7 +21,6 @@ /** * @deprecated Use org.eclipse.jetty.util.ClassMatcher */ - @Deprecated(since = "12.0.8", forRemoval = true) public class ClassMatcher extends org.eclipse.jetty.util.ClassMatcher { diff --git a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/Configuration.java b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/Configuration.java index bc0b23f3a682..41e8dc12e599 100644 --- a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/Configuration.java +++ b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/Configuration.java @@ -17,6 +17,7 @@ import java.util.Collections; import java.util.ServiceLoader; +import org.eclipse.jetty.util.ClassMatcher; import org.eclipse.jetty.util.TopologicalSort; /** @@ -42,8 +43,8 @@ * (eg {@link JndiConfiguration}, {@link JaasConfiguration}} etc.) can be added or removed without concern * for ordering. *

- *

Also since Jetty-9.4, Configurations are responsible for providing {@link #getServerClasses()} and - * {@link #getSystemClasses()} to configure the {@link WebAppClassLoader} for each context. + *

Also since Jetty-9.4, Configurations are responsible for providing {@link #getHiddenClasses()} and + * {@link #getHiddenClasses()} to configure the {@link WebAppClassLoader} for each context. *

*/ public interface Configuration @@ -94,25 +95,43 @@ default Collection getDependents() } /** - * Get the system classes associated with this Configuration. + * Get the system (protected) classes associated with this Configuration. * * @return ClassMatcher of system classes. */ - default ClassMatcher getSystemClasses() + default ClassMatcher getProtectedClasses() { return new ClassMatcher(); } /** - * Get the system classes associated with this Configuration. + * Get the system (hidden) classes associated with this Configuration. * * @return ClassMatcher of server classes. */ - default ClassMatcher getServerClasses() + default ClassMatcher getHiddenClasses() { return new ClassMatcher(); } + /** + * @deprecated use {@link #getProtectedClasses()} instead + */ + @Deprecated(since = "12.0.8", forRemoval = true) + default org.eclipse.jetty.ee9.webapp.ClassMatcher getSystemClasses() + { + return new org.eclipse.jetty.ee9.webapp.ClassMatcher(getProtectedClasses()); + } + + /** + * @deprecated use {@link #getHiddenClasses()} instead + */ + @Deprecated(since = "12.0.8", forRemoval = true) + default org.eclipse.jetty.ee9.webapp.ClassMatcher getServerClasses() + { + return new org.eclipse.jetty.ee9.webapp.ClassMatcher(getHiddenClasses()); + } + /** * Set up for configuration. *

diff --git a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/WebAppClassLoader.java b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/WebAppClassLoader.java index f474fa96ceda..4bcdfdb926ee 100644 --- a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/WebAppClassLoader.java +++ b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/WebAppClassLoader.java @@ -20,28 +20,24 @@ import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; -import java.nio.file.Files; import java.nio.file.Path; import java.security.CodeSource; import java.security.PermissionCollection; import java.security.PrivilegedExceptionAction; import java.util.ArrayList; import java.util.Collections; -import java.util.Comparator; import java.util.Enumeration; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.StringTokenizer; import java.util.concurrent.CopyOnWriteArrayList; -import java.util.stream.Stream; import org.eclipse.jetty.util.ClassVisibilityChecker; import org.eclipse.jetty.util.FileID; import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.TypeUtil; -import org.eclipse.jetty.util.URIUtil; import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.resource.ResourceCollators; import org.eclipse.jetty.util.resource.ResourceFactory; @@ -115,9 +111,33 @@ public interface Context extends ClassVisibilityChecker List getExtraClasspath(); - boolean isServerResource(String name, URL parentUrl); + /** + * @deprecated use {@link #isHiddenResource(String, URL)} + */ + @Deprecated(since = "12.0.8", forRemoval = true) + default boolean isServerResource(String name, URL parentUrl) + { + return isHiddenResource(name, parentUrl); + } + + /** + * @deprecated use {@link #isProtectedResource(String, URL)} + */ + @Deprecated(since = "12.0.8", forRemoval = true) + default boolean isSystemResource(String name, URL webappUrl) + { + return isProtectedResource(name, webappUrl); + } - boolean isSystemResource(String name, URL webappUrl); + default boolean isHiddenResource(String name, URL parentUrl) + { + return false; + } + + default boolean isProtectedResource(String name, URL webappUrl) + { + return false; + } } /** @@ -306,7 +326,7 @@ public Enumeration getResources(String name) throws IOException while (urls != null && urls.hasMoreElements()) { URL url = urls.nextElement(); - if (Boolean.TRUE.equals(__loadServerClasses.get()) || !_context.isServerResource(name, url)) + if (Boolean.TRUE.equals(__loadServerClasses.get()) || !_context.isHiddenResource(name, url)) fromParent.add(url); } @@ -314,7 +334,7 @@ public Enumeration getResources(String name) throws IOException while (urls != null && urls.hasMoreElements()) { URL url = urls.nextElement(); - if (!_context.isSystemResource(name, url) || fromParent.isEmpty()) + if (!_context.isProtectedResource(name, url) || fromParent.isEmpty()) fromWebapp.add(url); } @@ -355,7 +375,7 @@ public URL getResource(String name) // return if we have a url the webapp is allowed to see if (parentUrl != null && (Boolean.TRUE.equals(__loadServerClasses.get()) || - !_context.isServerResource(name, parentUrl))) + !_context.isHiddenResource(name, parentUrl))) resource = parentUrl; else { @@ -374,7 +394,7 @@ public URL getResource(String name) { URL webappUrl = this.findResource(name); - if (webappUrl != null && !_context.isSystemResource(name, webappUrl)) + if (webappUrl != null && !_context.isProtectedResource(name, webappUrl)) resource = webappUrl; else { @@ -383,7 +403,7 @@ public URL getResource(String name) URL parentUrl = _parent.getResource(name); if (parentUrl != null && (Boolean.TRUE.equals(__loadServerClasses.get()) || - !_context.isServerResource(name, parentUrl))) + !_context.isHiddenResource(name, parentUrl))) resource = parentUrl; // We couldn't find a parent resource, so OK to return a webapp one if it exists // and we just couldn't see it before @@ -528,7 +548,7 @@ protected Class loadAsResource(final String name, boolean checkSystemResource String path = TypeUtil.toClassReference(name); URL webappUrl = findResource(path); - if (webappUrl != null && (!checkSystemResource || !_context.isSystemResource(name, webappUrl))) + if (webappUrl != null && (!checkSystemResource || !_context.isProtectedResource(name, webappUrl))) { webappClass = this.foundClass(name, webappUrl); diff --git a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/WebAppContext.java b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/WebAppContext.java index 574cd0969a6e..79af73cd1f54 100644 --- a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/WebAppContext.java +++ b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/WebAppContext.java @@ -116,8 +116,8 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL public static final org.eclipse.jetty.ee9.webapp.ClassMatcher __dftServerClasses = new org.eclipse.jetty.ee9.webapp.ClassMatcher(WebAppClassLoading.DEFAULT_HIDDEN_CLASSES); - private final ClassMatcher _systemClasses = new ClassMatcher(WebAppClassLoading.getProtectedClasses(ServletContextHandler.ENVIRONMENT)); - private final ClassMatcher _serverClasses = new ClassMatcher(WebAppClassLoading.getHiddenClasses(ServletContextHandler.ENVIRONMENT)); + private final ClassMatcher _protectedClasses = new ClassMatcher(WebAppClassLoading.getProtectedClasses(ServletContextHandler.ENVIRONMENT)); + private final ClassMatcher _hiddenClasses = new ClassMatcher(WebAppClassLoading.getHiddenClasses(ServletContextHandler.ENVIRONMENT)); private Configurations _configurations; private String _defaultsDescriptor = WEB_DEFAULTS_XML; @@ -461,7 +461,7 @@ public void preConfigure() throws Exception // Add the known server class inclusions for all known configurations for (Configuration configuration : Configurations.getKnown()) { - _serverClasses.include(configuration.getServerClasses().getInclusions()); + _hiddenClasses.include(configuration.getHiddenClasses().getInclusions()); } // Setup Configuration classes for this webapp! @@ -469,8 +469,8 @@ public void preConfigure() throws Exception _configurations.sort(); for (Configuration configuration : _configurations) { - _systemClasses.add(configuration.getSystemClasses().getPatterns()); - _serverClasses.exclude(configuration.getServerClasses().getExclusions()); + _protectedClasses.add(configuration.getProtectedClasses().getPatterns()); + _hiddenClasses.exclude(configuration.getHiddenClasses().getExclusions()); } // Configure classloader @@ -671,107 +671,197 @@ public PermissionCollection getPermissions() } /** - * Set the server classes patterns. + * Set the hidden (server) classes patterns. *

- * Server classes/packages are classes used to implement the server and are hidden + * These classes/packages are used to implement the server and are hidden * from the context. If the context needs to load these classes, it must have its * own copy of them in WEB-INF/lib or WEB-INF/classes. * - * @param serverClasses the server classes pattern + * @param hiddenClasses the server classes pattern */ - public void setServerClassMatcher(ClassMatcher serverClasses) + public void setHiddenClassMatcher(ClassMatcher hiddenClasses) { - _serverClasses.clear(); - _serverClasses.add(serverClasses.getPatterns()); + _hiddenClasses.clear(); + _hiddenClasses.add(hiddenClasses.getPatterns()); } /** - * Set the system classes patterns. + * Set the protected (system) classes patterns. *

- * System classes/packages are classes provided by the JVM and that + * These classes/packages are provided by the JVM and * cannot be replaced by classes of the same name from WEB-INF, * regardless of the value of {@link #setParentLoaderPriority(boolean)}. * - * @param systemClasses the system classes pattern + * @param protectedClasses the system classes pattern */ - public void setSystemClassMatcher(ClassMatcher systemClasses) + public void setProtectedClassMatcher(ClassMatcher protectedClasses) { - _systemClasses.clear(); - _systemClasses.add(systemClasses.getPatterns()); + _protectedClasses.clear(); + _protectedClasses.add(protectedClasses.getPatterns()); } /** - * Add a ClassMatcher for server classes by combining with + * Add a ClassMatcher for hidden (server) classes by combining with * any existing matcher. * - * @param serverClasses The class matcher of patterns to add to the server ClassMatcher + * @param hiddenClasses The class matcher of patterns to add to the server ClassMatcher */ - public void addServerClassMatcher(ClassMatcher serverClasses) + public void addHiddenClassMatcher(ClassMatcher hiddenClasses) { - _serverClasses.add(serverClasses.getPatterns()); + _hiddenClasses.add(hiddenClasses.getPatterns()); } /** - * Add a ClassMatcher for system classes by combining with + * Add a ClassMatcher for protected (system) classes by combining with * any existing matcher. * - * @param systemClasses The class matcher of patterns to add to the system ClassMatcher + * @param protectedClasses The class matcher of patterns to add to the system ClassMatcher */ - public void addSystemClassMatcher(ClassMatcher systemClasses) + public void addProtectedClassMatcher(ClassMatcher protectedClasses) { - _systemClasses.add(systemClasses.getPatterns()); + _protectedClasses.add(protectedClasses.getPatterns()); } /** * @return The ClassMatcher used to match System (protected) classes */ - public ClassMatcher getSystemClassMatcher() + public ClassMatcher getProtectedClassMatcher() { - return _systemClasses; + return _protectedClasses; } /** * @return The ClassMatcher used to match Server (hidden) classes */ - public ClassMatcher getServerClassMatcher() + public ClassMatcher getHiddenClassMatcher() { - return _serverClasses; + return _hiddenClasses; } @ManagedAttribute(value = "classes and packages protected by context classloader", readonly = true) - public String[] getSystemClasses() + public String[] getProtectedClasses() { - return _systemClasses.getPatterns(); + return _protectedClasses.getPatterns(); } @ManagedAttribute(value = "classes and packages hidden by the context classloader", readonly = true) - public String[] getServerClasses() + public String[] getHiddenClasses() { - return _serverClasses.getPatterns(); + return _hiddenClasses.getPatterns(); } @Override public boolean isHiddenClass(Class clazz) { - return _serverClasses.match(clazz); + return _hiddenClasses.match(clazz); } @Override public boolean isProtectedClass(Class clazz) { - return _systemClasses.match(clazz); + return _protectedClasses.match(clazz); } @Override - public boolean isServerResource(String name, URL url) + public boolean isHiddenResource(String name, URL url) { - return _serverClasses.match(name, url); + return _hiddenClasses.match(name, url); } @Override - public boolean isSystemResource(String name, URL url) + public boolean isProtectedResource(String name, URL url) + { + return _protectedClasses.match(name, url); + } + + /** + * @deprecated use {@link #setHiddenClassMatcher(ClassMatcher)} + */ + @Deprecated(since = "12.0.8", forRemoval = true) + public void setServerClassMatcher(org.eclipse.jetty.ee9.webapp.ClassMatcher serverClasses) + { + setHiddenClassMatcher(serverClasses); + } + + /** + * @deprecated use {@link #setProtectedClassMatcher(ClassMatcher)} + */ + @Deprecated(since = "12.0.8", forRemoval = true) + public void setSystemClassMatcher(org.eclipse.jetty.ee9.webapp.ClassMatcher systemClasses) + { + setProtectedClassMatcher(systemClasses); + } + + /** + * @deprecated use {@link #addHiddenClassMatcher(ClassMatcher)} + */ + @Deprecated(since = "12.0.8", forRemoval = true) + public void addServerClassMatcher(org.eclipse.jetty.ee9.webapp.ClassMatcher serverClasses) + { + addHiddenClassMatcher(serverClasses); + } + + /** + * @deprecated use {@link #addProtectedClassMatcher(ClassMatcher)} + */ + @Deprecated(since = "12.0.8", forRemoval = true) + public void addSystemClassMatcher(org.eclipse.jetty.ee9.webapp.ClassMatcher systemClasses) + { + addProtectedClassMatcher(systemClasses); + } + + /** + * @deprecated use {@link #getProtectedClassMatcher()} + */ + @Deprecated(since = "12.0.8", forRemoval = true) + public org.eclipse.jetty.ee9.webapp.ClassMatcher getSystemClassMatcher() + { + return new org.eclipse.jetty.ee9.webapp.ClassMatcher(getProtectedClassMatcher()); + } + + /** + * @deprecated use {@link #getHiddenClassMatcher()} + */ + @Deprecated(since = "12.0.8", forRemoval = true) + public org.eclipse.jetty.ee9.webapp.ClassMatcher getServerClassMatcher() + { + return new org.eclipse.jetty.ee9.webapp.ClassMatcher(getHiddenClassMatcher()); + } + + /** + * @deprecated use {@link #getProtectedClasses()} + */ + @Deprecated(since = "12.0.8", forRemoval = true) + public String[] getSystemClasses() + { + return getProtectedClasses(); + } + + /** + * @deprecated use {@link #getHiddenClasses()} + */ + @Deprecated(since = "12.0.8", forRemoval = true) + public String[] getServerClasses() + { + return getHiddenClasses(); + } + + /** + * @deprecated use {@link #isHiddenClass(Class)} + */ + @Deprecated(since = "12.0.8", forRemoval = true) + public boolean isServerClass(Class clazz) + { + return isHiddenClass(clazz); + } + + /** + * @deprecated use {@link #isProtectedClass(Class)} + */ + @Deprecated(since = "12.0.8", forRemoval = true) + public boolean isSystemClass(Class clazz) { - return _systemClasses.match(name, url); + return isProtectedClass(clazz); } @Override @@ -780,8 +870,8 @@ public void setServer(Server server) super.setServer(server); if (server != null) { - _systemClasses.add(WebAppClassLoading.getProtectedClasses(server).getPatterns()); - _serverClasses.add(WebAppClassLoading.getHiddenClasses(server).getPatterns()); + _protectedClasses.add(WebAppClassLoading.getProtectedClasses(server).getPatterns()); + _hiddenClasses.add(WebAppClassLoading.getHiddenClasses(server).getPatterns()); } } @@ -893,16 +983,16 @@ public String toString() public void dump(Appendable out, String indent) throws IOException { List systemClasses = null; - if (_systemClasses != null) + if (_protectedClasses != null) { - systemClasses = new ArrayList<>(_systemClasses); + systemClasses = new ArrayList<>(_protectedClasses); Collections.sort(systemClasses); } List serverClasses = null; - if (_serverClasses != null) + if (_hiddenClasses != null) { - serverClasses = new ArrayList<>(_serverClasses); + serverClasses = new ArrayList<>(_hiddenClasses); Collections.sort(serverClasses); } @@ -1480,8 +1570,8 @@ public MetaData getMetaData() * Add a Server Class pattern to use for all ee9 WebAppContexts. * @param attributes The {@link Server} instance to add classes to * @param patterns the patterns to use - * @see #getServerClassMatcher() - * @see #getServerClasses() + * @see #getHiddenClassMatcher() + * @see #getHiddenClasses() * @deprecated use {@link WebAppClassLoading#addProtectedClasses(Server, String...)} */ @Deprecated(since = "12.0.8", forRemoval = true) @@ -1494,8 +1584,8 @@ public static void addServerClasses(Attributes attributes, String... patterns) * Add a System Class pattern to use for all ee9 WebAppContexts. * @param attributes The {@link Server} instance to add classes to * @param patterns the patterns to use - * @see #getSystemClassMatcher() - * @see #getSystemClasses() + * @see #getProtectedClassMatcher() + * @see #getProtectedClasses() * @deprecated use {@link WebAppClassLoading#addHiddenClasses(Server, String...)} */ @Deprecated(since = "12.0.8", forRemoval = true) diff --git a/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/WebAppClassLoaderTest.java b/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/WebAppClassLoaderTest.java index af4e50031f41..64baae738836 100644 --- a/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/WebAppClassLoaderTest.java +++ b/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/WebAppClassLoaderTest.java @@ -210,11 +210,11 @@ public byte[] transform(ClassLoader loader, String className, Class classBein @Test public void testExposedClassDeprecated() throws Exception { - String[] oldSC = _context.getServerClasses(); + String[] oldSC = _context.getHiddenClasses(); String[] newSC = new String[oldSC.length + 1]; newSC[0] = "-org.eclipse.jetty.ee9.webapp.Configuration"; System.arraycopy(oldSC, 0, newSC, 1, oldSC.length); - _context.setServerClassMatcher(new ClassMatcher(newSC)); + _context.setHiddenClassMatcher(new ClassMatcher(newSC)); assertCanLoadClass("org.acme.webapp.ClassInJarA"); assertCanLoadClass("org.acme.webapp.ClassInJarB"); @@ -227,7 +227,7 @@ public void testExposedClassDeprecated() throws Exception @Test public void testExposedClass() throws Exception { - _context.getServerClassMatcher().exclude("org.eclipse.jetty.ee9.webapp.Configuration"); + _context.getHiddenClassMatcher().exclude("org.eclipse.jetty.ee9.webapp.Configuration"); assertCanLoadClass("org.acme.webapp.ClassInJarA"); assertCanLoadClass("org.acme.webapp.ClassInJarB"); @@ -240,18 +240,18 @@ public void testExposedClass() throws Exception @Test public void testSystemServerClassDeprecated() throws Exception { - String[] oldServC = _context.getServerClasses(); + String[] oldServC = _context.getHiddenClasses(); String[] newServC = new String[oldServC.length + 1]; newServC[0] = "org.eclipse.jetty.ee9.webapp.Configuration"; System.arraycopy(oldServC, 0, newServC, 1, oldServC.length); - _context.setServerClassMatcher(new ClassMatcher(newServC)); + _context.setHiddenClassMatcher(new ClassMatcher(newServC)); - String[] oldSysC = _context.getSystemClasses(); + String[] oldSysC = _context.getProtectedClasses(); String[] newSysC = new String[oldSysC.length + 1]; newSysC[0] = "org.eclipse.jetty.ee9.webapp."; System.arraycopy(oldSysC, 0, newSysC, 1, oldSysC.length); - _context.setSystemClassMatcher(new ClassMatcher(newSysC)); + _context.setHiddenClassMatcher(new ClassMatcher(newSysC)); assertCanLoadClass("org.acme.webapp.ClassInJarA"); assertCanLoadClass("org.acme.webapp.ClassInJarB"); @@ -259,28 +259,28 @@ public void testSystemServerClassDeprecated() throws Exception assertCantLoadClass("org.eclipse.jetty.ee9.webapp.Configuration"); assertCantLoadClass("org.eclipse.jetty.ee9.webapp.JarScanner"); - oldSysC = _context.getSystemClasses(); + oldSysC = _context.getProtectedClasses(); newSysC = new String[oldSysC.length + 1]; newSysC[0] = "org.acme.webapp.ClassInJarA"; System.arraycopy(oldSysC, 0, newSysC, 1, oldSysC.length); - _context.setSystemClassMatcher(new ClassMatcher(newSysC)); + _context.setProtectedClassMatcher(new ClassMatcher(newSysC)); assertCanLoadResource("org/acme/webapp/ClassInJarA.class"); - _context.setSystemClassMatcher(new ClassMatcher(oldSysC)); + _context.setProtectedClassMatcher(new ClassMatcher(oldSysC)); - oldServC = _context.getServerClasses(); + oldServC = _context.getHiddenClasses(); newServC = new String[oldServC.length + 1]; newServC[0] = "org.acme.webapp.ClassInJarA"; System.arraycopy(oldServC, 0, newServC, 1, oldServC.length); - _context.setServerClassMatcher(new ClassMatcher(newServC)); + _context.setHiddenClassMatcher(new ClassMatcher(newServC)); assertCanLoadResource("org/acme/webapp/ClassInJarA.class"); } @Test public void testSystemServerClass() throws Exception { - _context.getServerClassMatcher().add("org.eclipse.jetty.ee9.webapp.Configuration"); - _context.getSystemClassMatcher().add("org.eclipse.jetty.ee9.webapp."); + _context.getHiddenClassMatcher().add("org.eclipse.jetty.ee9.webapp.Configuration"); + _context.getProtectedClassMatcher().add("org.eclipse.jetty.ee9.webapp."); assertCanLoadClass("org.acme.webapp.ClassInJarA"); assertCanLoadClass("org.acme.webapp.ClassInJarB"); @@ -288,11 +288,11 @@ public void testSystemServerClass() throws Exception assertCantLoadClass("org.eclipse.jetty.ee9.webapp.Configuration"); assertCantLoadClass("org.eclipse.jetty.ee9.webapp.JarScanner"); - _context.getSystemClassMatcher().add("org.acme.webapp.ClassInJarA"); + _context.getProtectedClassMatcher().add("org.acme.webapp.ClassInJarA"); assertCanLoadResource("org/acme/webapp/ClassInJarA.class"); - _context.getSystemClassMatcher().remove("org.acme.webapp.ClassInJarA"); + _context.getProtectedClassMatcher().remove("org.acme.webapp.ClassInJarA"); - _context.getServerClassMatcher().add("org.acme.webapp.ClassInJarA"); + _context.getHiddenClassMatcher().add("org.acme.webapp.ClassInJarA"); assertCanLoadResource("org/acme/webapp/ClassInJarA.class"); } @@ -339,11 +339,11 @@ public void testResources() throws Exception // assertEquals(0,resources.get(1).toString().indexOf("jar:file:")); // assertEquals(-1,resources.get(2).toString().indexOf("test-classes")); - String[] oldServC = _context.getServerClasses(); + String[] oldServC = _context.getHiddenClasses(); String[] newServC = new String[oldServC.length + 1]; newServC[0] = "org.acme."; System.arraycopy(oldServC, 0, newServC, 1, oldServC.length); - _context.setServerClassMatcher(new ClassMatcher(newServC)); + _context.setHiddenClassMatcher(new ClassMatcher(newServC)); _context.setParentLoaderPriority(true); // dump(_context); @@ -360,12 +360,12 @@ public void testResources() throws Exception // assertEquals(0,resources.get(0).toString().indexOf("jar:file:")); // assertEquals(0,resources.get(1).toString().indexOf("file:")); - _context.setServerClassMatcher(new ClassMatcher(oldServC)); - String[] oldSysC = _context.getSystemClasses(); + _context.setHiddenClassMatcher(new ClassMatcher(oldServC)); + String[] oldSysC = _context.getProtectedClasses(); String[] newSysC = new String[oldSysC.length + 1]; newSysC[0] = "org.acme."; System.arraycopy(oldSysC, 0, newSysC, 1, oldSysC.length); - _context.setSystemClassMatcher(new ClassMatcher(newSysC)); + _context.setProtectedClassMatcher(new ClassMatcher(newSysC)); _context.setParentLoaderPriority(true); // dump(_context); diff --git a/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/WebAppContextTest.java b/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/WebAppContextTest.java index 9e9ee0bd01b3..ad3bcc434464 100644 --- a/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/WebAppContextTest.java +++ b/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/WebAppContextTest.java @@ -870,7 +870,7 @@ public void testAddServerClasses() throws Exception server.setHandler(context); server.start(); - List serverClasses = List.of(context.getServerClasses()); + List serverClasses = List.of(context.getHiddenClasses()); assertThat("Should have environment specific test pattern", serverClasses, hasItem(testPattern)); assertThat("Should have pattern from defaults", serverClasses, hasItem("org.eclipse.jetty.")); assertThat("Should have pattern from JaasConfiguration", serverClasses, hasItem("-org.eclipse.jetty.security.jaas.")); @@ -898,7 +898,7 @@ public void testAddSystemClasses() throws Exception server.setHandler(context); server.start(); - List systemClasses = List.of(context.getSystemClasses()); + List systemClasses = List.of(context.getProtectedClasses()); assertThat("Should have environment specific test pattern", systemClasses, hasItem(testPattern)); assertThat("Should have pattern from defaults", systemClasses, hasItem("javax.")); assertThat("Should have pattern from defaults", systemClasses, hasItem("jakarta."));