diff --git a/jetty-core/jetty-deploy/src/test/resources/etc/webdefault.xml b/jetty-core/jetty-deploy/src/test/resources/etc/webdefault.xml index 3cfe11a75aa..761af36150b 100644 --- a/jetty-core/jetty-deploy/src/test/resources/etc/webdefault.xml +++ b/jetty-core/jetty-deploy/src/test/resources/etc/webdefault.xml @@ -94,17 +94,17 @@ * gzip content encoded if a matching resource is * found ending with ".gz" * - * resourceBase Set to replace the context resource base + * baseResource Set to replace the context resource base * * resourceCache If set, this is a context attribute name, which the servlet * will use to look for a shared ResourceCache instance. * - * relativeResourceBase + * relativeBaseResource * Set with a pathname relative to the base of the * servlet context root. Useful for only serving static content out * of only specific subdirectories. * - * pathInfoOnly If true, only the path info will be applied to the resourceBase + * pathInfoOnly If true, only the path info will be applied to the baseResource * * stylesheet Set with the location of an optional stylesheet that will be used * to decorate the directory listing html. diff --git a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/AllowedResourceAliasChecker.java b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/AllowedResourceAliasChecker.java index d2471fca033..dc4deb6225f 100644 --- a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/AllowedResourceAliasChecker.java +++ b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/AllowedResourceAliasChecker.java @@ -54,7 +54,7 @@ public class AllowedResourceAliasChecker extends AbstractLifeCycle implements Co */ public AllowedResourceAliasChecker(ContextHandler contextHandler) { - this(contextHandler, contextHandler::getResourceBase); + this(contextHandler, contextHandler::getBaseResource); } public AllowedResourceAliasChecker(ContextHandler contextHandler, Resource baseResource) diff --git a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java index 3e37a6cc468..3db35bb64d5 100644 --- a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java +++ b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java @@ -88,7 +88,7 @@ public class ContextHandler extends Handler.Wrapper implements Attributes, Grace private String _displayName; private String _contextPath = "/"; - private Resource _resourceBase; + private Resource _baseResource; private ClassLoader _classLoader; private Request.Processor _errorProcessor; private boolean _allowNullPathInContext; @@ -675,9 +675,9 @@ public class ContextHandler extends Handler.Wrapper implements Attributes, Grace * @return Returns the base resource as a string. */ @ManagedAttribute("document root for context") - public Resource getResourceBase() + public Resource getBaseResource() { - return _resourceBase; + return _baseResource; } /** @@ -689,10 +689,9 @@ public class ContextHandler extends Handler.Wrapper implements Attributes, Grace { if (isStarted()) throw new IllegalStateException(getState()); - _resourceBase = resourceBase; + _baseResource = resourceBase; } - // TODO inline this ??? public void setBaseResource(Path path) { setBaseResource(path == null ? null : ResourceFactory.root().newResource(path)); @@ -740,7 +739,7 @@ public class ContextHandler extends Handler.Wrapper implements Attributes, Grace if (getDisplayName() != null) b.append(getDisplayName()).append(','); b.append(getContextPath()); - b.append(",b=").append(getResourceBase()); + b.append(",b=").append(getBaseResource()); b.append(",a=").append(_availability.get()); if (!vhosts.isEmpty()) @@ -833,7 +832,7 @@ public class ContextHandler extends Handler.Wrapper implements Attributes, Grace @Override public Resource getBaseResource() { - return _resourceBase; + return _baseResource; } @Override diff --git a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java index 00fd46db81c..08fe78ec6b5 100644 --- a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java +++ b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java @@ -123,7 +123,7 @@ public class ResourceHandler extends Handler.Wrapper /** * @return Returns the resourceBase. */ - public Resource getResourceBase() + public Resource getBaseResource() { return _resourceBase; } diff --git a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/jmx/AbstractHandlerMBean.java b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/jmx/AbstractHandlerMBean.java index 8b17ff34a35..d6dbe2ff35b 100644 --- a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/jmx/AbstractHandlerMBean.java +++ b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/jmx/AbstractHandlerMBean.java @@ -13,7 +13,6 @@ package org.eclipse.jetty.server.jmx; -import java.io.IOException; import java.util.List; import org.eclipse.jetty.jmx.ObjectMBean; @@ -71,8 +70,8 @@ public class AbstractHandlerMBean extends ObjectMBean name = "ROOT"; } - if (name == null && context.getResourceBase() != null) - name = context.getResourceBase().getPath().getFileName().toString(); + if (name == null && context.getBaseResource() != null) + name = context.getBaseResource().getPath().getFileName().toString(); List vhosts = context.getVirtualHosts(); if (vhosts.size() > 0) diff --git a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ResourceHandlerTest.java b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ResourceHandlerTest.java index 64c287aa404..445e793a7a1 100644 --- a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ResourceHandlerTest.java +++ b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ResourceHandlerTest.java @@ -1810,7 +1810,7 @@ public class ResourceHandlerTest _rootResourceHandler.stop(); _rootResourceHandler.setBaseResource(Resource.combine( ResourceFactory.root().newResource(MavenTestingUtils.getTestResourcePathDir("layer0/")), - _rootResourceHandler.getResourceBase())); + _rootResourceHandler.getBaseResource())); _rootResourceHandler.start(); HttpTester.Response response = HttpTester.parseResponse( @@ -1872,7 +1872,7 @@ public class ResourceHandlerTest _rootResourceHandler.setBaseResource(Resource.combine( ResourceFactory.root().newResource(MavenTestingUtils.getTestResourcePathDir("layer0/")), ResourceFactory.root().newResource(MavenTestingUtils.getTestResourcePathDir("layer1/")), - _rootResourceHandler.getResourceBase())); + _rootResourceHandler.getBaseResource())); _rootResourceHandler.start(); HttpTester.Response response = HttpTester.parseResponse( diff --git a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/main/resources/demo/webdefault-ee10.xml b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/main/resources/demo/webdefault-ee10.xml index 377cc8ca828..ce3e9359124 100644 --- a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/main/resources/demo/webdefault-ee10.xml +++ b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/main/resources/demo/webdefault-ee10.xml @@ -102,17 +102,17 @@ * If set to a boolean True, then a default set of compressed formats * will be used, otherwise no precompressed formats. * - * resourceBase Set to replace the context resource base + * baseResource Set to replace the context resource base * * resourceCache If set, this is a context attribute name, which the servlet * will use to look for a shared ResourceCache instance. * - * relativeResourceBase + * relativeBaseResource * Set with a pathname relative to the base of the * servlet context root. Useful for only serving static content out * of only specific subdirectories. * - * pathInfoOnly If true, only the path info will be applied to the resourceBase + * pathInfoOnly If true, only the path info will be applied to the baseResource * * stylesheet Set with the location of an optional stylesheet that will be used * to decorate the directory listing html. diff --git a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-jetty-webapp/src/main/assembly/embedded-jetty-web-for-webbundle.xml b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-jetty-webapp/src/main/assembly/embedded-jetty-web-for-webbundle.xml index e618f7b729e..5d21ea6a539 100644 --- a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-jetty-webapp/src/main/assembly/embedded-jetty-web-for-webbundle.xml +++ b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-jetty-webapp/src/main/assembly/embedded-jetty-web-for-webbundle.xml @@ -16,7 +16,7 @@ detected. - + / /webapps/test.war diff --git a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-jetty-webapp/src/main/config/modules/demo.d/ee10-demo-jetty.xml b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-jetty-webapp/src/main/config/modules/demo.d/ee10-demo-jetty.xml index 388295ace33..7ac1a3c58ae 100644 --- a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-jetty-webapp/src/main/config/modules/demo.d/ee10-demo-jetty.xml +++ b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-jetty-webapp/src/main/config/modules/demo.d/ee10-demo-jetty.xml @@ -10,7 +10,7 @@ Configure and deploy the test web application - + /ee10-test /ee10-demo-jetty.war diff --git a/jetty-ee10/jetty-ee10-maven-plugin/src/main/java/org/eclipse/jetty/ee10/maven/plugin/AbstractUnassembledWebAppMojo.java b/jetty-ee10/jetty-ee10-maven-plugin/src/main/java/org/eclipse/jetty/ee10/maven/plugin/AbstractUnassembledWebAppMojo.java index ca9c5b4da0f..423662cddec 100644 --- a/jetty-ee10/jetty-ee10-maven-plugin/src/main/java/org/eclipse/jetty/ee10/maven/plugin/AbstractUnassembledWebAppMojo.java +++ b/jetty-ee10/jetty-ee10-maven-plugin/src/main/java/org/eclipse/jetty/ee10/maven/plugin/AbstractUnassembledWebAppMojo.java @@ -126,7 +126,7 @@ public abstract class AbstractUnassembledWebAppMojo extends AbstractWebAppMojo //The first time we run, remember the original base dir if (originalBaseResource == null) { - if (webApp.getResourceBase() == null) + if (webApp.getBaseResource() == null) { //Use the default static resource location if (!webAppSourceDirectory.exists()) @@ -134,7 +134,7 @@ public abstract class AbstractUnassembledWebAppMojo extends AbstractWebAppMojo originalBaseResource = ResourceFactory.of(webApp).newResource(webAppSourceDirectory.getCanonicalPath()); } else - originalBaseResource = webApp.getResourceBase(); + originalBaseResource = webApp.getBaseResource(); } //On every subsequent re-run set it back to the original base dir before @@ -175,11 +175,11 @@ public abstract class AbstractUnassembledWebAppMojo extends AbstractWebAppMojo } //Still don't have a web.xml file: try the resourceBase of the webapp, if it is set - if (webApp.getDescriptor() == null && webApp.getResourceBase() != null) + if (webApp.getDescriptor() == null && webApp.getBaseResource() != null) { // TODO: should never return from WEB-INF/lib/foo.jar!/WEB-INF/web.xml // TODO: should also never return from a META-INF/versions/#/WEB-INF/web.xml location - Resource r = webApp.getResourceBase().resolve("WEB-INF/web.xml"); + Resource r = webApp.getBaseResource().resolve("WEB-INF/web.xml"); if (r.exists() && !r.isDirectory()) { webApp.setDescriptor(r.toString()); diff --git a/jetty-ee10/jetty-ee10-maven-plugin/src/main/java/org/eclipse/jetty/ee10/maven/plugin/MavenQuickStartConfiguration.java b/jetty-ee10/jetty-ee10-maven-plugin/src/main/java/org/eclipse/jetty/ee10/maven/plugin/MavenQuickStartConfiguration.java index e4882127b2a..aaa93f70a6f 100644 --- a/jetty-ee10/jetty-ee10-maven-plugin/src/main/java/org/eclipse/jetty/ee10/maven/plugin/MavenQuickStartConfiguration.java +++ b/jetty-ee10/jetty-ee10-maven-plugin/src/main/java/org/eclipse/jetty/ee10/maven/plugin/MavenQuickStartConfiguration.java @@ -46,7 +46,7 @@ public class MavenQuickStartConfiguration extends QuickStartConfiguration //Iterate over all of the resource bases and ignore any that were original bases, just //deleting the overlays - Resource res = context.getResourceBase(); + Resource res = context.getBaseResource(); if (res instanceof ResourceCollection) { for (Resource r : ((ResourceCollection)res).getResources()) diff --git a/jetty-ee10/jetty-ee10-maven-plugin/src/main/java/org/eclipse/jetty/ee10/maven/plugin/OverlayManager.java b/jetty-ee10/jetty-ee10-maven-plugin/src/main/java/org/eclipse/jetty/ee10/maven/plugin/OverlayManager.java index 28372bf039d..e5a11be69eb 100644 --- a/jetty-ee10/jetty-ee10-maven-plugin/src/main/java/org/eclipse/jetty/ee10/maven/plugin/OverlayManager.java +++ b/jetty-ee10/jetty-ee10-maven-plugin/src/main/java/org/eclipse/jetty/ee10/maven/plugin/OverlayManager.java @@ -47,21 +47,21 @@ public class OverlayManager for (Overlay o : getOverlays()) { //can refer to the current project in list of overlays for ordering purposes - if (o.getConfig() != null && o.getConfig().isCurrentProject() && webApp.getResourceBase().exists()) + if (o.getConfig() != null && o.getConfig().isCurrentProject() && webApp.getBaseResource().exists()) { - resourceBases.add(webApp.getResourceBase()); + resourceBases.add(webApp.getBaseResource()); continue; } //add in the selectively unpacked overlay in the correct order to the webapp's resource base resourceBases.add(unpackOverlay(o)); } - if (!resourceBases.contains(webApp.getResourceBase()) && webApp.getResourceBase().exists()) + if (!resourceBases.contains(webApp.getBaseResource()) && webApp.getBaseResource().exists()) { if (webApp.getBaseAppFirst()) - resourceBases.add(0, webApp.getResourceBase()); + resourceBases.add(0, webApp.getBaseResource()); else - resourceBases.add(webApp.getResourceBase()); + resourceBases.add(webApp.getBaseResource()); } webApp.setBaseResource(Resource.combine(resourceBases)); diff --git a/jetty-ee10/jetty-ee10-maven-plugin/src/main/java/org/eclipse/jetty/ee10/maven/plugin/WebAppPropertyConverter.java b/jetty-ee10/jetty-ee10-maven-plugin/src/main/java/org/eclipse/jetty/ee10/maven/plugin/WebAppPropertyConverter.java index 4cc62c9880d..21c431b8d5f 100644 --- a/jetty-ee10/jetty-ee10-maven-plugin/src/main/java/org/eclipse/jetty/ee10/maven/plugin/WebAppPropertyConverter.java +++ b/jetty-ee10/jetty-ee10-maven-plugin/src/main/java/org/eclipse/jetty/ee10/maven/plugin/WebAppPropertyConverter.java @@ -105,11 +105,11 @@ public class WebAppPropertyConverter props.put(TMP_DIR_PERSIST, Boolean.toString(webApp.isPersistTempDirectory())); //send over the calculated resource bases that includes unpacked overlays - Resource baseResource = webApp.getResourceBase(); + Resource baseResource = webApp.getBaseResource(); if (baseResource instanceof ResourceCollection) - props.put(BASE_DIRS, toCSV(((ResourceCollection)webApp.getResourceBase()).getResources())); + props.put(BASE_DIRS, toCSV(((ResourceCollection)webApp.getBaseResource()).getResources())); else if (baseResource instanceof Resource) - props.put(BASE_DIRS, webApp.getResourceBase().toString()); + props.put(BASE_DIRS, webApp.getBaseResource().toString()); //if there is a war file, use that if (webApp.getWar() != null) diff --git a/jetty-ee10/jetty-ee10-maven-plugin/src/test/java/org/eclipse/jetty/ee10/maven/plugin/TestWebAppPropertyConverter.java b/jetty-ee10/jetty-ee10-maven-plugin/src/test/java/org/eclipse/jetty/ee10/maven/plugin/TestWebAppPropertyConverter.java index 06c1215f25f..090fdbbc631 100644 --- a/jetty-ee10/jetty-ee10-maven-plugin/src/test/java/org/eclipse/jetty/ee10/maven/plugin/TestWebAppPropertyConverter.java +++ b/jetty-ee10/jetty-ee10-maven-plugin/src/test/java/org/eclipse/jetty/ee10/maven/plugin/TestWebAppPropertyConverter.java @@ -152,9 +152,9 @@ public class TestWebAppPropertyConverter assertEquals(true, webApp.isPersistTempDirectory()); assertEquals(war.getAbsolutePath(), webApp.getWar()); assertEquals(webXml.getAbsolutePath(), webApp.getDescriptor()); - assertThat(webApp.getResourceBase(), instanceOf(ResourceCollection.class)); + assertThat(webApp.getBaseResource(), instanceOf(ResourceCollection.class)); - ResourceCollection resourceCollection = (ResourceCollection)webApp.getResourceBase(); + ResourceCollection resourceCollection = (ResourceCollection)webApp.getBaseResource(); List actual = resourceCollection.getResources().stream().filter(Objects::nonNull).map(Resource::getURI).toList(); URI[] expected = new URI[]{base1.toURI(), base2.toURI()}; assertThat(actual, containsInAnyOrder(expected)); diff --git a/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/config/etc/webdefault-ee10.xml b/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/config/etc/webdefault-ee10.xml index 312e54a799e..221dde048d9 100644 --- a/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/config/etc/webdefault-ee10.xml +++ b/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/config/etc/webdefault-ee10.xml @@ -94,17 +94,17 @@ * gzip content encoded if a matching resource is * found ending with ".gz" * - * resourceBase Set to replace the context resource base + * baseResource Set to replace the context resource base * * resourceCache If set, this is a context attribute name, which the servlet * will use to look for a shared ResourceCache instance. * - * relativeResourceBase + * relativeBaseResource * Set with a pathname relative to the base of the * servlet context root. Useful for only serving static content out * of only specific subdirectories. * - * pathInfoOnly If true, only the path info will be applied to the resourceBase + * pathInfoOnly If true, only the path info will be applied to the baseResource * * stylesheet Set with the location of an optional stylesheet that will be used * to decorate the directory listing html. diff --git a/jetty-ee10/jetty-ee10-quickstart/src/main/java/org/eclipse/jetty/ee10/quickstart/QuickStartConfiguration.java b/jetty-ee10/jetty-ee10-quickstart/src/main/java/org/eclipse/jetty/ee10/quickstart/QuickStartConfiguration.java index 656f9cfe23f..3ded680e3f2 100644 --- a/jetty-ee10/jetty-ee10-quickstart/src/main/java/org/eclipse/jetty/ee10/quickstart/QuickStartConfiguration.java +++ b/jetty-ee10/jetty-ee10-quickstart/src/main/java/org/eclipse/jetty/ee10/quickstart/QuickStartConfiguration.java @@ -18,7 +18,6 @@ import java.nio.file.Files; import java.util.HashSet; import java.util.Set; -import org.eclipse.jetty.ee10.annotations.AnnotationConfiguration; import org.eclipse.jetty.ee10.annotations.AnnotationDecorator; import org.eclipse.jetty.ee10.webapp.AbstractConfiguration; import org.eclipse.jetty.ee10.webapp.Configuration; @@ -96,7 +95,7 @@ public class QuickStartConfiguration extends AbstractConfiguration //check that webapp is suitable for quick start - it is not a packed war String war = context.getWar(); - if (war == null || war.length() <= 0 || !context.getResourceBase().isDirectory()) + if (war == null || war.length() <= 0 || !context.getBaseResource().isDirectory()) throw new IllegalStateException("Bad Quickstart location"); //look for quickstart-web.xml in WEB-INF of webapp @@ -233,7 +232,7 @@ public class QuickStartConfiguration extends AbstractConfiguration Resource webInf = context.getWebInf(); if (webInf == null || !webInf.exists()) { - Files.createDirectories(context.getResourceBase().getPath().resolve("WEB-INF")); + Files.createDirectories(context.getBaseResource().getPath().resolve("WEB-INF")); webInf = context.getWebInf(); } diff --git a/jetty-ee10/jetty-ee10-quickstart/src/main/java/org/eclipse/jetty/ee10/quickstart/QuickStartDescriptorProcessor.java b/jetty-ee10/jetty-ee10-quickstart/src/main/java/org/eclipse/jetty/ee10/quickstart/QuickStartDescriptorProcessor.java index 0f17e46ee01..0459b00e162 100644 --- a/jetty-ee10/jetty-ee10-quickstart/src/main/java/org/eclipse/jetty/ee10/quickstart/QuickStartDescriptorProcessor.java +++ b/jetty-ee10/jetty-ee10-quickstart/src/main/java/org/eclipse/jetty/ee10/quickstart/QuickStartDescriptorProcessor.java @@ -151,7 +151,7 @@ public class QuickStartDescriptorProcessor extends IterativeDescriptorProcessor default -> values.add(value); } - AttributeNormalizer normalizer = new AttributeNormalizer(context.getResourceBase()); + AttributeNormalizer normalizer = new AttributeNormalizer(context.getBaseResource()); // handle values switch (name) { @@ -240,7 +240,7 @@ public class QuickStartDescriptorProcessor extends IterativeDescriptorProcessor //also add to base resource of webapp List collection = new ArrayList<>(); - collection.add(context.getResourceBase()); + collection.add(context.getBaseResource()); collection.addAll(metaInfResources); context.setBaseResource(Resource.combine(collection)); } diff --git a/jetty-ee10/jetty-ee10-quickstart/src/main/java/org/eclipse/jetty/ee10/quickstart/QuickStartGeneratorConfiguration.java b/jetty-ee10/jetty-ee10-quickstart/src/main/java/org/eclipse/jetty/ee10/quickstart/QuickStartGeneratorConfiguration.java index 4ac1f66f4da..9941c661c98 100644 --- a/jetty-ee10/jetty-ee10-quickstart/src/main/java/org/eclipse/jetty/ee10/quickstart/QuickStartGeneratorConfiguration.java +++ b/jetty-ee10/jetty-ee10-quickstart/src/main/java/org/eclipse/jetty/ee10/quickstart/QuickStartGeneratorConfiguration.java @@ -142,7 +142,7 @@ public class QuickStartGeneratorConfiguration extends AbstractConfiguration _originAttribute = DEFAULT_ORIGIN_ATTRIBUTE_NAME; context.getMetaData().getOrigins(); - if (context.getResourceBase() == null) + if (context.getBaseResource() == null) throw new IllegalArgumentException("No base resource for " + this); MetaData md = context.getMetaData(); @@ -166,7 +166,7 @@ public class QuickStartGeneratorConfiguration extends AbstractConfiguration // Set some special context parameters // The location of the war file on disk - AttributeNormalizer normalizer = new AttributeNormalizer(context.getResourceBase()); + AttributeNormalizer normalizer = new AttributeNormalizer(context.getBaseResource()); // The library order addContextParamFromAttribute(context, out, ServletContext.ORDERED_LIBS); diff --git a/jetty-ee10/jetty-ee10-quickstart/src/test/resources/context.xml b/jetty-ee10/jetty-ee10-quickstart/src/test/resources/context.xml index 84e1b4071f5..5d9dcdf07ac 100644 --- a/jetty-ee10/jetty-ee10-quickstart/src/test/resources/context.xml +++ b/jetty-ee10/jetty-ee10-quickstart/src/test/resources/context.xml @@ -16,7 +16,7 @@ detected. - + /test diff --git a/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/DefaultServlet.java b/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/DefaultServlet.java index 7d1ddbc7a1d..8a0991c0cf3 100644 --- a/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/DefaultServlet.java +++ b/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/DefaultServlet.java @@ -73,6 +73,9 @@ import org.eclipse.jetty.util.resource.ResourceFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +/** + * TODO restore javadoc + */ public class DefaultServlet extends HttpServlet { private static final Logger LOG = LoggerFactory.getLogger(DefaultServlet.class); @@ -94,8 +97,8 @@ public class DefaultServlet extends HttpServlet _resourceService = new ServletResourceService(servletContextHandler); _resourceService.setWelcomeFactory(_resourceService); - _baseResource = servletContextHandler.getResourceBase(); - String rb = getInitParameter("resourceBase"); + _baseResource = servletContextHandler.getBaseResource(); + String rb = getInitParameter("baseResource", "resourceBase"); if (rb != null) { try @@ -105,7 +108,7 @@ public class DefaultServlet extends HttpServlet } catch (Exception e) { - LOG.warn("Unable to create resourceBase from {}", rb, e); + LOG.warn("Unable to create baseResource from {}", rb, e); throw new UnavailableException(e.toString()); } } @@ -225,6 +228,25 @@ public class DefaultServlet extends HttpServlet LOG.debug("base resource = {}", _baseResource); } + private String getInitParameter(String name, String... deprecated) + { + String value = super.getInitParameter(name); + if (value != null) + return value; + + for (String d : deprecated) + { + value = super.getInitParameter(d); + if (value != name) + { + LOG.warn("Deprecated {} used instead of {}", d, name); + return value; + } + } + + return null; + } + @Override public void destroy() { diff --git a/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletContextHandler.java b/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletContextHandler.java index 28caf71e247..549f99c2343 100644 --- a/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletContextHandler.java +++ b/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletContextHandler.java @@ -853,7 +853,7 @@ public class ServletContextHandler extends ContextHandler implements Graceful if (pathInContext == null || !pathInContext.startsWith(URIUtil.SLASH)) throw new MalformedURLException(pathInContext); - Resource baseResource = getResourceBase(); + Resource baseResource = getBaseResource(); if (baseResource == null) return null; @@ -1235,7 +1235,7 @@ public class ServletContextHandler extends ContextHandler implements Graceful if (getContextPath() == null) throw new IllegalStateException("Null contextPath"); - Resource baseResource = getResourceBase(); + Resource baseResource = getBaseResource(); if (baseResource != null && baseResource.isAlias()) LOG.warn("BaseResource {} is aliased to {} in {}. May not be supported in future releases.", baseResource, baseResource.getAlias(), this); diff --git a/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletTester.java b/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletTester.java index d4e02bceef1..a67667b2a30 100644 --- a/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletTester.java +++ b/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletTester.java @@ -197,7 +197,7 @@ public class ServletTester extends ContainerLifeCycle public Resource getResourceBase() { - return _context.getResourceBase(); + return _context.getBaseResource(); } public void setResourceBase(Resource base) diff --git a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-integration/src/test/resources/DefaultHandler.xml b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-integration/src/test/resources/DefaultHandler.xml index e23d89e6d0e..0ec3df1ae6c 100644 --- a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-integration/src/test/resources/DefaultHandler.xml +++ b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-integration/src/test/resources/DefaultHandler.xml @@ -29,7 +29,7 @@ /tests - /default + /default diff --git a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-integration/src/test/resources/RFC2616Base.xml b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-integration/src/test/resources/RFC2616Base.xml index 54208e5f369..27203314f2b 100644 --- a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-integration/src/test/resources/RFC2616Base.xml +++ b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-integration/src/test/resources/RFC2616Base.xml @@ -47,7 +47,7 @@ VirtualHost - /virtualhost + /virtualhost virtual @@ -55,7 +55,7 @@ /tests - /default + /default default diff --git a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-integration/src/test/resources/webdefault-ee10.xml b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-integration/src/test/resources/webdefault-ee10.xml index 312e54a799e..221dde048d9 100644 --- a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-integration/src/test/resources/webdefault-ee10.xml +++ b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-integration/src/test/resources/webdefault-ee10.xml @@ -94,17 +94,17 @@ * gzip content encoded if a matching resource is * found ending with ".gz" * - * resourceBase Set to replace the context resource base + * baseResource Set to replace the context resource base * * resourceCache If set, this is a context attribute name, which the servlet * will use to look for a shared ResourceCache instance. * - * relativeResourceBase + * relativeBaseResource * Set with a pathname relative to the base of the * servlet context root. Useful for only serving static content out * of only specific subdirectories. * - * pathInfoOnly If true, only the path info will be applied to the resourceBase + * pathInfoOnly If true, only the path info will be applied to the baseResource * * stylesheet Set with the location of an optional stylesheet that will be used * to decorate the directory listing html. diff --git a/jetty-ee10/jetty-ee10-webapp/src/main/config/etc/webdefault-ee10.xml b/jetty-ee10/jetty-ee10-webapp/src/main/config/etc/webdefault-ee10.xml index f7bfb84bd2f..5acd5b0a0af 100644 --- a/jetty-ee10/jetty-ee10-webapp/src/main/config/etc/webdefault-ee10.xml +++ b/jetty-ee10/jetty-ee10-webapp/src/main/config/etc/webdefault-ee10.xml @@ -94,17 +94,17 @@ * If set to a boolean True, then a default set of compressed formats * will be used, otherwise no precompressed formats. * - * resourceBase Set to replace the context resource base + * baseResource Set to replace the context resource base * * resourceCache If set, this is a context attribute name, which the servlet * will use to look for a shared ResourceCache instance. * - * relativeResourceBase + * relativeBaseResource * Set with a pathname relative to the base of the * servlet context root. Useful for only serving static content out * of only specific subdirectories. * - * pathInfoOnly If true, only the path info will be applied to the resourceBase + * pathInfoOnly If true, only the path info will be applied to the baseResource * * stylesheet Set with the location of an optional stylesheet that will be used * to decorate the directory listing html. diff --git a/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/MetaInfConfiguration.java b/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/MetaInfConfiguration.java index 01bf105e0dd..bd1fd7e4156 100644 --- a/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/MetaInfConfiguration.java +++ b/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/MetaInfConfiguration.java @@ -264,7 +264,7 @@ public class MetaInfConfiguration extends AbstractConfiguration if (resources != null && !resources.isEmpty()) { List collection = new ArrayList<>(); - collection.add(context.getResourceBase()); + collection.add(context.getBaseResource()); collection.addAll(resources); context.setBaseResource(Resource.combine(collection)); } 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 47748aba171..220ed0135ff 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 @@ -786,7 +786,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL /** * @return Returns the war as a file or URL string (Resource). - * The war may be different to the @link {@link #getResourceBase()} + * The war may be different to the @link {@link #getBaseResource()} * if the war has been expanded and/or copied. */ @ManagedAttribute(value = "war file location", readonly = true) @@ -794,9 +794,9 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL { if (_war == null) { - if (getResourceBase() != null) + if (getBaseResource() != null) { - Path warPath = getResourceBase().getPath(); + Path warPath = getBaseResource().getPath(); if (warPath != null) _war = warPath.toUri().toASCIIString(); } @@ -806,7 +806,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL public Resource getWebInf() throws IOException { - if (getResourceBase() == null) + if (getBaseResource() == null) return null; // Is there a WEB-INF directory anywhere in the Resource Base? @@ -814,7 +814,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL // The result could be a ResourceCollection with multiple WEB-INF directories // Can return from WEB-INF/lib/foo.jar!/WEB-INF // Can also never return from a META-INF/versions/#/WEB-INF location - Resource webInf = getResourceBase().resolve("WEB-INF/"); + Resource webInf = getBaseResource().resolve("WEB-INF/"); if (!webInf.exists() || !webInf.isDirectory()) return null; @@ -929,9 +929,9 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL else name = _war; } - else if (getResourceBase() != null) + else if (getBaseResource() != null) { - name = getResourceBase().getURI().toASCIIString(); + name = getBaseResource().getURI().toASCIIString(); int webapps = name.indexOf("/webapps/"); if (webapps >= 0) name = name.substring(webapps + 8); diff --git a/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/WebInfConfiguration.java b/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/WebInfConfiguration.java index b47bd4b9218..6fc08556f5f 100644 --- a/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/WebInfConfiguration.java +++ b/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/WebInfConfiguration.java @@ -281,9 +281,9 @@ public class WebInfConfiguration extends AbstractConfiguration public void unpack(WebAppContext context) throws IOException { - Resource webApp = context.getResourceBase(); + Resource webApp = context.getBaseResource(); _resourceFactory = ResourceFactory.closeable(); - _preUnpackBaseResource = context.getResourceBase(); + _preUnpackBaseResource = context.getBaseResource(); if (webApp == null) { @@ -291,7 +291,7 @@ public class WebInfConfiguration extends AbstractConfiguration if (war != null && war.length() > 0) webApp = context.newResource(war); else - webApp = context.getResourceBase(); + webApp = context.getBaseResource(); if (webApp == null) throw new IllegalStateException("No resourceBase or war set for context"); @@ -516,7 +516,7 @@ public class WebInfConfiguration extends AbstractConfiguration // Resource base try { - Resource resource = context.getResourceBase(); + Resource resource = context.getBaseResource(); if (resource == null) { if (context.getWar() == null || context.getWar().length() == 0) diff --git a/jetty-ee8/jetty-ee8-demos/jetty-ee8-demo-jetty-webapp/src/main/assembly/embedded-jetty-web-for-webbundle.xml b/jetty-ee8/jetty-ee8-demos/jetty-ee8-demo-jetty-webapp/src/main/assembly/embedded-jetty-web-for-webbundle.xml index 55919330e3a..3db8c129e55 100644 --- a/jetty-ee8/jetty-ee8-demos/jetty-ee8-demo-jetty-webapp/src/main/assembly/embedded-jetty-web-for-webbundle.xml +++ b/jetty-ee8/jetty-ee8-demos/jetty-ee8-demo-jetty-webapp/src/main/assembly/embedded-jetty-web-for-webbundle.xml @@ -16,7 +16,7 @@ detected. - + / /webapps/ee9-demo-jetty.war diff --git a/jetty-ee8/jetty-ee8-demos/jetty-ee8-demo-jetty-webapp/src/main/config/modules/demo.d/ee8-demo-jetty.xml b/jetty-ee8/jetty-ee8-demos/jetty-ee8-demo-jetty-webapp/src/main/config/modules/demo.d/ee8-demo-jetty.xml index e0a737857e9..edfa351d2dc 100644 --- a/jetty-ee8/jetty-ee8-demos/jetty-ee8-demo-jetty-webapp/src/main/config/modules/demo.d/ee8-demo-jetty.xml +++ b/jetty-ee8/jetty-ee8-demos/jetty-ee8-demo-jetty-webapp/src/main/config/modules/demo.d/ee8-demo-jetty.xml @@ -10,7 +10,7 @@ Configure and deploy the test web application - + /ee8-test /ee8-demo-jetty.war diff --git a/jetty-ee8/jetty-ee8-webapp/src/main/config/etc/webdefault-ee8.xml b/jetty-ee8/jetty-ee8-webapp/src/main/config/etc/webdefault-ee8.xml index e47018b3dca..68ee15f48ee 100644 --- a/jetty-ee8/jetty-ee8-webapp/src/main/config/etc/webdefault-ee8.xml +++ b/jetty-ee8/jetty-ee8-webapp/src/main/config/etc/webdefault-ee8.xml @@ -102,17 +102,17 @@ * If set to a boolean True, then a default set of compressed formats * will be used, otherwise no precompressed formats. * - * resourceBase Set to replace the context resource base + * baseResource Set to replace the context resource base * * resourceCache If set, this is a context attribute name, which the servlet * will use to look for a shared ResourceCache instance. * - * relativeResourceBase + * relativeBaseResource * Set with a pathname relative to the base of the * servlet context root. Useful for only serving static content out * of only specific subdirectories. * - * pathInfoOnly If true, only the path info will be applied to the resourceBase + * pathInfoOnly If true, only the path info will be applied to the baseResource * * stylesheet Set with the location of an optional stylesheet that will be used * to decorate the directory listing html. diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/main/resources/demo/webdefault-ee9.xml b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/main/resources/demo/webdefault-ee9.xml index 303478184d7..0afd5b3cec6 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/main/resources/demo/webdefault-ee9.xml +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/main/resources/demo/webdefault-ee9.xml @@ -102,17 +102,17 @@ * If set to a boolean True, then a default set of compressed formats * will be used, otherwise no precompressed formats. * - * resourceBase Set to replace the context resource base + * baseResource Set to replace the context resource base * * resourceCache If set, this is a context attribute name, which the servlet * will use to look for a shared ResourceCache instance. * - * relativeResourceBase + * relativeBaseResource * Set with a pathname relative to the base of the * servlet context root. Useful for only serving static content out * of only specific subdirectories. * - * pathInfoOnly If true, only the path info will be applied to the resourceBase + * pathInfoOnly If true, only the path info will be applied to the baseResource * * stylesheet Set with the location of an optional stylesheet that will be used * to decorate the directory listing html. diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-jetty-webapp/src/main/assembly/embedded-jetty-web-for-webbundle.xml b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-jetty-webapp/src/main/assembly/embedded-jetty-web-for-webbundle.xml index 55919330e3a..3db8c129e55 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-jetty-webapp/src/main/assembly/embedded-jetty-web-for-webbundle.xml +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-jetty-webapp/src/main/assembly/embedded-jetty-web-for-webbundle.xml @@ -16,7 +16,7 @@ detected. - + / /webapps/ee9-demo-jetty.war diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-jetty-webapp/src/main/config/modules/demo.d/ee9-demo-jetty.xml b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-jetty-webapp/src/main/config/modules/demo.d/ee9-demo-jetty.xml index 4affa81a4e5..ab43e5a7df5 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-jetty-webapp/src/main/config/modules/demo.d/ee9-demo-jetty.xml +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-jetty-webapp/src/main/config/modules/demo.d/ee9-demo-jetty.xml @@ -10,7 +10,7 @@ Configure and deploy the test web application - + /ee9-test /ee9-demo-jetty.war diff --git a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/AllowedResourceAliasChecker.java b/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/AllowedResourceAliasChecker.java index 1b4554d25a1..3f0cd439f47 100644 --- a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/AllowedResourceAliasChecker.java +++ b/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/AllowedResourceAliasChecker.java @@ -61,7 +61,7 @@ public class AllowedResourceAliasChecker extends AbstractLifeCycle implements Co protected void initialize() { - _base = _contextHandler.getCoreContextHandler().getResourceBase().getPath(); + _base = _contextHandler.getCoreContextHandler().getBaseResource().getPath(); if (_base == null) return; diff --git a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/ContextHandler.java b/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/ContextHandler.java index 1119ba984ea..ba56b599fb2 100644 --- a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/ContextHandler.java +++ b/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/ContextHandler.java @@ -1144,7 +1144,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu */ public Resource getBaseResource() { - return _coreContextHandler.getResourceBase(); + return _coreContextHandler.getBaseResource(); } /** @@ -1153,7 +1153,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu @ManagedAttribute("document root for context") public String getResourceBase() { - Resource resourceBase = _coreContextHandler.getResourceBase(); + Resource resourceBase = _coreContextHandler.getBaseResource(); return resourceBase == null ? null : resourceBase.toString(); } @@ -1168,12 +1168,25 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu _coreContextHandler.setBaseResource(base); } + /** + * Set the base resource for this context. + * + * @param base The resource used as the base for all static content of this context. + * @see #setResourceBase(String) + */ + public void setBaseResource(Path base) + { + _coreContextHandler.setBaseResource(base); + } + /** * Set the base resource for this context. * * @param resourceBase A string representing the base resource for the context. Any string accepted by {@link ResourceFactory#newResource(String)} may be passed and the * call is equivalent to setBaseResource(newResource(resourceBase)); + * @deprecated use #setBaseResource */ + @Deprecated public void setResourceBase(String resourceBase) { try @@ -1398,7 +1411,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu if (pathInContext == null || !pathInContext.startsWith(URIUtil.SLASH)) throw new MalformedURLException(pathInContext); - Resource baseResource = _coreContextHandler.getResourceBase(); + Resource baseResource = _coreContextHandler.getBaseResource(); if (baseResource == null) return null; diff --git a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/ResourceHandler.java b/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/ResourceHandler.java index 2a865e98912..290649a90ee 100644 --- a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/ResourceHandler.java +++ b/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/ResourceHandler.java @@ -15,6 +15,7 @@ package org.eclipse.jetty.ee9.nested; import java.io.IOException; import java.net.URI; +import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -193,6 +194,7 @@ public class ResourceHandler extends HandlerWrapper implements ResourceFactory, /** * @return Returns the base resource as a string. */ + @Deprecated public String getResourceBase() { if (_baseResource == null) @@ -319,6 +321,15 @@ public class ResourceHandler extends HandlerWrapper implements ResourceFactory, _baseResource = base; } + /** + * @param basePath The resourceBase to server content from. If null the + * context resource base is used. + */ + public void setBaseResource(Path basePath) + { + setBaseResource(ResourceFactory.root().newResource(basePath)); + } + /** * @param cacheControl the cacheControl header to set on all static content. */ @@ -395,7 +406,9 @@ public class ResourceHandler extends HandlerWrapper implements ResourceFactory, /** * @param resourceBase The base resource as a string. + * @deprecated use {@link #setBaseResource(Resource)} */ + @Deprecated public void setResourceBase(String resourceBase) { try diff --git a/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/config/etc/webdefault-ee9.xml b/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/config/etc/webdefault-ee9.xml index dd0520f1934..c7ad85ca0db 100644 --- a/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/config/etc/webdefault-ee9.xml +++ b/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/config/etc/webdefault-ee9.xml @@ -94,17 +94,17 @@ * gzip content encoded if a matching resource is * found ending with ".gz" * - * resourceBase Set to replace the context resource base + * baseResource Set to replace the context resource base * * resourceCache If set, this is a context attribute name, which the servlet * will use to look for a shared ResourceCache instance. * - * relativeResourceBase + * relativeBaseResource * Set with a pathname relative to the base of the * servlet context root. Useful for only serving static content out * of only specific subdirectories. * - * pathInfoOnly If true, only the path info will be applied to the resourceBase + * pathInfoOnly If true, only the path info will be applied to the baseResource * * stylesheet Set with the location of an optional stylesheet that will be used * to decorate the directory listing html. diff --git a/jetty-ee9/jetty-ee9-quickstart/src/main/java/org/eclipse/jetty/ee9/quickstart/PreconfigureQuickStartWar.java b/jetty-ee9/jetty-ee9-quickstart/src/main/java/org/eclipse/jetty/ee9/quickstart/PreconfigureQuickStartWar.java index 096a4ad1bcc..4a743f4fb10 100644 --- a/jetty-ee9/jetty-ee9-quickstart/src/main/java/org/eclipse/jetty/ee9/quickstart/PreconfigureQuickStartWar.java +++ b/jetty-ee9/jetty-ee9-quickstart/src/main/java/org/eclipse/jetty/ee9/quickstart/PreconfigureQuickStartWar.java @@ -125,7 +125,7 @@ public class PreconfigureQuickStartWar XmlConfiguration xmlConfiguration = new XmlConfiguration(xml); xmlConfiguration.configure(webapp); } - webapp.setResourceBase(dir.getPath().toAbsolutePath().toString()); + webapp.setBaseResource(dir.getPath().toAbsolutePath()); server.setHandler(webapp); try { diff --git a/jetty-ee9/jetty-ee9-quickstart/src/test/resources/context.xml b/jetty-ee9/jetty-ee9-quickstart/src/test/resources/context.xml index d111e8e459a..f4282b080f9 100644 --- a/jetty-ee9/jetty-ee9-quickstart/src/test/resources/context.xml +++ b/jetty-ee9/jetty-ee9-quickstart/src/test/resources/context.xml @@ -16,7 +16,7 @@ detected. - + /test diff --git a/jetty-ee9/jetty-ee9-servlet/src/main/java/org/eclipse/jetty/ee9/servlet/DefaultServlet.java b/jetty-ee9/jetty-ee9-servlet/src/main/java/org/eclipse/jetty/ee9/servlet/DefaultServlet.java index 734557405c9..7512e13156e 100644 --- a/jetty-ee9/jetty-ee9-servlet/src/main/java/org/eclipse/jetty/ee9/servlet/DefaultServlet.java +++ b/jetty-ee9/jetty-ee9-servlet/src/main/java/org/eclipse/jetty/ee9/servlet/DefaultServlet.java @@ -83,17 +83,17 @@ import org.slf4j.LoggerFactory; * If set to a boolean True, then a default set of compressed formats * will be used, otherwise no precompressed formats. * - * resourceBase Set to replace the context resource base + * baseResource Set to replace the context resource base * * resourceCache If set, this is a context attribute name, which the servlet * will use to look for a shared ResourceCache instance. * - * relativeResourceBase + * relativeBaseResource * Set with a pathname relative to the base of the * servlet context root. Useful for only serving static content out * of only specific subdirectories. * - * pathInfoOnly If true, only the path info will be applied to the resourceBase + * pathInfoOnly If true, only the path info will be applied to the baseResource * * stylesheet Set with the location of an optional stylesheet that will be used * to decorate the directory listing html. @@ -136,7 +136,7 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory, Welc private boolean _welcomeServlets = false; private boolean _welcomeExactServlets = false; - private Resource _resourceBase; + private Resource _baseResource; private CachedContentFactory _cache; private MimeTypes _mimeTypes; @@ -144,7 +144,7 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory, Welc private ResourceFactory.Closeable _resourceFactory; private Resource _stylesheet; private boolean _useFileMappedBuffer = false; - private String _relativeResourceBase; + private String _relativeBaseResource; private ServletHandler _servletHandler; public DefaultServlet(ResourceService resourceService) @@ -188,20 +188,20 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory, Welc _useFileMappedBuffer = getInitBoolean("useFileMappedBuffer", _useFileMappedBuffer); - _relativeResourceBase = getInitParameter("relativeResourceBase"); + _relativeBaseResource = getInitParameter("relativeBaseResource", "relativeResourceBase"); - String rb = getInitParameter("resourceBase"); - if (rb != null) + String br = getInitParameter("baseResource", "resourceBase"); + if (br != null) { - if (_relativeResourceBase != null) - throw new UnavailableException("resourceBase & relativeResourceBase"); + if (_relativeBaseResource != null) + throw new UnavailableException("baseResource & relativeBaseResource"); try { - _resourceBase = _contextHandler.newResource(rb); + _baseResource = _contextHandler.newResource(br); } catch (Exception e) { - LOG.warn("Unable to create resourceBase from {}", rb, e); + LOG.warn("Unable to create baseResource from {}", br, e); throw new UnavailableException(e.toString()); } } @@ -248,7 +248,7 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory, Welc { if (maxCacheSize != -1 || maxCachedFileSize != -2 || maxCachedFiles != -2) LOG.debug("ignoring resource cache configuration, using resourceCache attribute"); - if (_relativeResourceBase != null || _resourceBase != null) + if (_relativeBaseResource != null || _baseResource != null) throw new UnavailableException("resourceCache specified with resource bases"); _cache = (CachedContentFactory)_servletContext.getAttribute(resourceCache); } @@ -305,7 +305,26 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory, Welc _servletHandler = _contextHandler.getChildHandlerByClass(ServletHandler.class); if (LOG.isDebugEnabled()) - LOG.debug("resource base = {}", _resourceBase); + LOG.debug("resource base = {}", _baseResource); + } + + private String getInitParameter(String name, String... deprecated) + { + String value = super.getInitParameter(name); + if (value != null) + return value; + + for (String d : deprecated) + { + value = super.getInitParameter(d); + if (value != name) + { + LOG.warn("Deprecated {} used instead of {}", d, name); + return value; + } + } + + return null; } private CompressedContentFormat[] parsePrecompressedFormats(String precompressed, Boolean gzip, CompressedContentFormat[] dft) @@ -431,14 +450,14 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory, Welc subUriPath = URIUtil.encodePath(subUriPath); Resource r = null; - if (_relativeResourceBase != null) - subUriPath = URIUtil.addPaths(_relativeResourceBase, subUriPath); + if (_relativeBaseResource != null) + subUriPath = URIUtil.addPaths(_relativeBaseResource, subUriPath); try { - if (_resourceBase != null) + if (_baseResource != null) { - r = _resourceBase.resolve(subUriPath); + r = _baseResource.resolve(subUriPath); if (!_contextHandler.checkAlias(subUriPath, r)) r = null; } diff --git a/jetty-ee9/jetty-ee9-servlet/src/main/java/org/eclipse/jetty/ee9/servlet/ServletTester.java b/jetty-ee9/jetty-ee9-servlet/src/main/java/org/eclipse/jetty/ee9/servlet/ServletTester.java index 941d7733a95..28d099f0916 100644 --- a/jetty-ee9/jetty-ee9-servlet/src/main/java/org/eclipse/jetty/ee9/servlet/ServletTester.java +++ b/jetty-ee9/jetty-ee9-servlet/src/main/java/org/eclipse/jetty/ee9/servlet/ServletTester.java @@ -203,11 +203,13 @@ public class ServletTester extends ContainerLifeCycle _context.setBaseResource(resource); } + @Deprecated public String getResourceBase() { return _context.getResourceBase(); } + @Deprecated public void setResourceBase(String resourceBase) { _context.setResourceBase(resourceBase); diff --git a/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/DispatcherTest.java b/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/DispatcherTest.java index 0127bfd92dd..5d47b9deed7 100644 --- a/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/DispatcherTest.java +++ b/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/DispatcherTest.java @@ -94,7 +94,7 @@ public class DispatcherTest _contextHandler.setContextPath("/context"); _contextCollection.addHandler(_contextHandler); _resourceHandler = new ResourceHandler(); - _resourceHandler.setResourceBase(MavenTestingUtils.getTargetFile("test-classes/dispatchResourceTest").getAbsolutePath()); + _resourceHandler.setBaseResource(MavenTestingUtils.getTargetFile("test-classes/dispatchResourceTest").toPath()); _resourceHandler.setPathInfoOnly(true); ContextHandler resourceContextHandler = new ContextHandler("/resource"); resourceContextHandler.setHandler(_resourceHandler); diff --git a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/resources/DefaultHandler.xml b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/resources/DefaultHandler.xml index e23d89e6d0e..0ec3df1ae6c 100644 --- a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/resources/DefaultHandler.xml +++ b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/resources/DefaultHandler.xml @@ -29,7 +29,7 @@ /tests - /default + /default diff --git a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/resources/RFC2616Base.xml b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/resources/RFC2616Base.xml index 54208e5f369..d274407a4fd 100644 --- a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/resources/RFC2616Base.xml +++ b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/resources/RFC2616Base.xml @@ -47,7 +47,7 @@ VirtualHost - /virtualhost + /virtualhost virtual @@ -55,7 +55,7 @@ /tests - /default + /default default diff --git a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/resources/webdefault-ee9.xml b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/resources/webdefault-ee9.xml index dd0520f1934..c7ad85ca0db 100644 --- a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/resources/webdefault-ee9.xml +++ b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/resources/webdefault-ee9.xml @@ -94,17 +94,17 @@ * gzip content encoded if a matching resource is * found ending with ".gz" * - * resourceBase Set to replace the context resource base + * baseResource Set to replace the context resource base * * resourceCache If set, this is a context attribute name, which the servlet * will use to look for a shared ResourceCache instance. * - * relativeResourceBase + * relativeBaseResource * Set with a pathname relative to the base of the * servlet context root. Useful for only serving static content out * of only specific subdirectories. * - * pathInfoOnly If true, only the path info will be applied to the resourceBase + * pathInfoOnly If true, only the path info will be applied to the baseResource * * stylesheet Set with the location of an optional stylesheet that will be used * to decorate the directory listing html. diff --git a/jetty-ee9/jetty-ee9-webapp/src/main/config/etc/webdefault-ee9.xml b/jetty-ee9/jetty-ee9-webapp/src/main/config/etc/webdefault-ee9.xml index 0fc14a43085..6cb8b908d7b 100644 --- a/jetty-ee9/jetty-ee9-webapp/src/main/config/etc/webdefault-ee9.xml +++ b/jetty-ee9/jetty-ee9-webapp/src/main/config/etc/webdefault-ee9.xml @@ -102,17 +102,17 @@ * If set to a boolean True, then a default set of compressed formats * will be used, otherwise no precompressed formats. * - * resourceBase Set to replace the context resource base + * baseResource Set to replace the context resource base * * resourceCache If set, this is a context attribute name, which the servlet * will use to look for a shared ResourceCache instance. * - * relativeResourceBase + * relativeBaseResource * Set with a pathname relative to the base of the * servlet context root. Useful for only serving static content out * of only specific subdirectories. * - * pathInfoOnly If true, only the path info will be applied to the resourceBase + * pathInfoOnly If true, only the path info will be applied to the baseResource * * stylesheet Set with the location of an optional stylesheet that will be used * to decorate the directory listing html. diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-tests/src/main/java/org/eclipse/jetty/ee9/websocket/jakarta/tests/WSServer.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-tests/src/main/java/org/eclipse/jetty/ee9/websocket/jakarta/tests/WSServer.java index d8d4346977a..91fa46c77a3 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-tests/src/main/java/org/eclipse/jetty/ee9/websocket/jakarta/tests/WSServer.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-tests/src/main/java/org/eclipse/jetty/ee9/websocket/jakarta/tests/WSServer.java @@ -100,7 +100,7 @@ public class WSServer extends LocalServer implements LocalFuzzer.Provider context = new WebAppContext(); context.setContextPath("/" + contextName); context.setInitParameter("org.eclipse.jetty.ee9.servlet.Default.dirAllowed", "false"); - context.setResourceBase(contextDir.toAbsolutePath().toString()); + context.setBaseResource(contextDir.toAbsolutePath()); context.setAttribute("org.eclipse.jetty.websocket.jakarta", Boolean.TRUE); context.addConfiguration(new JakartaWebSocketConfiguration()); }