From eecded58b2a5e187622664d02830f7fe958f2672 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Fri, 31 May 2024 10:48:15 +1000 Subject: [PATCH 1/7] Issue #11847 implement environment context xml --- .../deploy/providers/ContextProvider.java | 108 +++++++++++++----- .../providers/ContextProviderStartupTest.java | 47 +++++++- .../src/test/resources/etc/core-context.xml | 22 ++++ .../org/eclipse/jetty/server/Deployable.java | 1 + 4 files changed, 148 insertions(+), 30 deletions(-) create mode 100644 jetty-core/jetty-deploy/src/test/resources/etc/core-context.xml diff --git a/jetty-core/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ContextProvider.java b/jetty-core/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ContextProvider.java index 82d905b2155c..e85b040e1a47 100644 --- a/jetty-core/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ContextProvider.java +++ b/jetty-core/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ContextProvider.java @@ -21,6 +21,7 @@ import java.net.URLClassLoader; import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -341,32 +342,42 @@ public ContextHandler createContextHandler(final App app) throws Exception // prepare properties Map properties = new HashMap<>(); + + //add in properties from start mechanism properties.putAll(getProperties()); - properties.putAll(app.getProperties()); - // Handle a context XML file - if (FileID.isXml(path)) + Object context = null; + + //add in environment-specific properties + String env = app.getEnvironmentName() == null ? "" : app.getEnvironmentName(); + Path envProperties = app.getPath().getParent().resolve(env + ".properties"); + if (Files.exists(envProperties)) { - XmlConfiguration xmlc = new XmlConfiguration(ResourceFactory.of(this).newResource(path), null, properties) + try (InputStream stream = Files.newInputStream(envProperties)) { - @Override - public void initializeDefaults(Object context) - { - super.initializeDefaults(context); - ContextProvider.this.initializeContextHandler(context, path, properties); - } - }; + Properties p = new Properties(); + p.load(stream); + p.stringPropertyNames().forEach(k -> properties.put(k, p.getProperty(k))); + } - xmlc.getIdMap().put("Environment", environment); - xmlc.setJettyStandardIdsAndProperties(getDeploymentManager().getServer(), path); + String str = properties.get(Deployable.ENVIRONMENT_XML); + if (!StringUtil.isEmpty(str)) + { + Path envXmlPath = Paths.get(str); + if (!envXmlPath.isAbsolute()) + envXmlPath = getMonitoredDirResource().getPath().getParent().resolve(envXmlPath); - // If it is a core context environment, then look for a classloader - ClassLoader coreContextClassLoader = Environment.CORE.equals(environment) ? findCoreContextClassLoader(path) : null; - if (coreContextClassLoader != null) - Thread.currentThread().setContextClassLoader(coreContextClassLoader); + context = applyXml(null, envXmlPath, env, properties); + } + } - // Create the context by running the configuration - Object context = xmlc.configure(); + //add in properties specific to the deployable + properties.putAll(app.getProperties()); + + // Handle a context XML file + if (FileID.isXml(path)) + { + context = applyXml(context, path, env, properties); // Look for the contextHandler itself ContextHandler contextHandler = null; @@ -382,27 +393,33 @@ else if (context instanceof Supplier supplier) throw new IllegalStateException("Unknown context type of " + context); // Set the classloader if we have a coreContextClassLoader + ClassLoader coreContextClassLoader = Environment.CORE.equals(environment) ? findCoreContextClassLoader(path) : null; if (coreContextClassLoader != null) contextHandler.setClassLoader(coreContextClassLoader); return contextHandler; } + // Otherwise it must be a directory or an archive else if (!Files.isDirectory(path) && !FileID.isWebArchive(path)) { throw new IllegalStateException("unable to create ContextHandler for " + app); } - // Build the web application - String contextHandlerClassName = (String)environment.getAttribute("contextHandlerClass"); - if (StringUtil.isBlank(contextHandlerClassName)) - throw new IllegalStateException("No ContextHandler classname for " + app); - Class contextHandlerClass = Loader.loadClass(contextHandlerClassName); - if (contextHandlerClass == null) - throw new IllegalStateException("Unknown ContextHandler class " + contextHandlerClassName + " for " + app); - - Object context = contextHandlerClass.getDeclaredConstructor().newInstance(); - properties.put(Deployable.WAR, path.toString()); + // Build the web application if necessary + if (context == null) + { + String contextHandlerClassName = (String)environment.getAttribute("contextHandlerClass"); + if (StringUtil.isBlank(contextHandlerClassName)) + throw new IllegalStateException("No ContextHandler classname for " + app); + Class contextHandlerClass = Loader.loadClass(contextHandlerClassName); + if (contextHandlerClass == null) + throw new IllegalStateException("Unknown ContextHandler class " + contextHandlerClassName + " for " + app); + + context = contextHandlerClass.getDeclaredConstructor().newInstance(); + properties.put(Deployable.WAR, path.toString()); + } + return initializeContextHandler(context, path, properties); } finally @@ -411,6 +428,39 @@ else if (!Files.isDirectory(path) && !FileID.isWebArchive(path)) } } + protected Object applyXml(Object context, Path xml, String environment, Map properties) throws Exception + { + if (!FileID.isXml(xml)) + return null; + + + XmlConfiguration xmlc = new XmlConfiguration(ResourceFactory.of(this).newResource(xml), null, properties) + { + @Override + public void initializeDefaults(Object context) + { + super.initializeDefaults(context); + ContextProvider.this.initializeContextHandler(context, xml, properties); + } + }; + + xmlc.getIdMap().put("Environment", environment); + xmlc.setJettyStandardIdsAndProperties(getDeploymentManager().getServer(), xml); + + // If it is a core context environment, then look for a classloader + ClassLoader coreContextClassLoader = Environment.CORE.equals(environment) ? findCoreContextClassLoader(xml) : null; + if (coreContextClassLoader != null) + Thread.currentThread().setContextClassLoader(coreContextClassLoader); + + // Create or configure the context + if (context == null) + return xmlc.configure(); + + return xmlc.configure(context); + + + } + protected ClassLoader findCoreContextClassLoader(Path path) throws IOException { Path webapps = path.getParent(); diff --git a/jetty-core/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ContextProviderStartupTest.java b/jetty-core/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ContextProviderStartupTest.java index 573b4d558d14..821ea0054ded 100644 --- a/jetty-core/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ContextProviderStartupTest.java +++ b/jetty-core/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ContextProviderStartupTest.java @@ -15,6 +15,8 @@ import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.StandardCopyOption; +import java.nio.file.StandardOpenOption; import java.time.Duration; import java.util.HashMap; import java.util.List; @@ -26,10 +28,12 @@ import org.eclipse.jetty.deploy.AppProvider; import org.eclipse.jetty.deploy.DeploymentManager; import org.eclipse.jetty.deploy.test.XmlConfiguredJetty; +import org.eclipse.jetty.server.Deployable; import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.toolchain.test.FS; +import org.eclipse.jetty.toolchain.test.MavenPaths; import org.eclipse.jetty.toolchain.test.jupiter.WorkDir; import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension; import org.eclipse.jetty.util.Scanner; @@ -43,6 +47,7 @@ import static org.awaitility.Awaitility.await; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -77,7 +82,10 @@ public void setupEnvironment() throws Exception // Should not throw an Exception jetty.load(); + } + public void startJetty() throws Exception + { // Start it jetty.start(); } @@ -89,9 +97,46 @@ public void teardownEnvironment() throws Exception } @Test - public void testStartupContext() + public void testStartupContext() throws Exception { + startJetty(); + // Check Server for Handlers jetty.assertContextHandlerExists("/bar"); + + } + + @Test + public void testStartupWithRelativeEnvironmentContext() throws Exception + { + Path jettyBase = jetty.getJettyBasePath(); + Path propsFile = Files.writeString(jettyBase.resolve("webapps/core.properties"), Deployable.ENVIRONMENT_XML + " = etc/core-context.xml", StandardOpenOption.CREATE_NEW); + assertTrue(Files.exists(propsFile)); + Files.copy(MavenPaths.findTestResourceFile("etc/core-context.xml"), jettyBase.resolve("etc/core-context.xml"), StandardCopyOption.REPLACE_EXISTING); + + startJetty(); + + //check environment context xml was applied to the produced context + ContextHandler context = jetty.getContextHandler("/bar"); + assertNotNull(context); + assertThat(context.getAttribute("somename"), equalTo("somevalue")); + + } + + @Test + public void testStartupWithAbsoluteEnvironmentContext() throws Exception + { + Path jettyBase = jetty.getJettyBasePath(); + Path propsFile = Files.writeString(jettyBase.resolve("webapps/core.properties"), Deployable.ENVIRONMENT_XML + " = " + + MavenPaths.findTestResourceFile("etc/core-context.xml"), StandardOpenOption.CREATE_NEW); + assertTrue(Files.exists(propsFile)); + Files.copy(MavenPaths.findTestResourceFile("etc/core-context.xml"), jettyBase.resolve("etc/core-context.xml"), StandardCopyOption.REPLACE_EXISTING); + + startJetty(); + + //check environment context xml was applied to the produced context + ContextHandler context = jetty.getContextHandler("/bar"); + assertNotNull(context); + assertThat(context.getAttribute("somename"), equalTo("somevalue")); } } diff --git a/jetty-core/jetty-deploy/src/test/resources/etc/core-context.xml b/jetty-core/jetty-deploy/src/test/resources/etc/core-context.xml new file mode 100644 index 000000000000..1eb453c75991 --- /dev/null +++ b/jetty-core/jetty-deploy/src/test/resources/etc/core-context.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + /global + + somename + somevalue + + diff --git a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/Deployable.java b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/Deployable.java index 9beedc42b221..a6a2466517ce 100644 --- a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/Deployable.java +++ b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/Deployable.java @@ -58,6 +58,7 @@ public interface Deployable String CONTEXT_PATH = "jetty.deploy.contextPath"; String DEFAULTS_DESCRIPTOR = "jetty.deploy.defaultsDescriptor"; String ENVIRONMENT = "environment"; + String ENVIRONMENT_XML = "jetty.deploy.environmentXml"; String EXTRACT_WARS = "jetty.deploy.extractWars"; String PARENT_LOADER_PRIORITY = "jetty.deploy.parentLoaderPriority"; String SCI_EXCLUSION_PATTERN = "jetty.deploy.servletContainerInitializerExclusionPattern"; From 87ef93e20f73cae5f3eb1b589a0c02b40ab596ec Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Wed, 12 Jun 2024 18:06:51 +1000 Subject: [PATCH 2/7] Add optional jetty.deploy.contextHandlerClass to webapp properties. --- .../deploy/providers/ContextProvider.java | 10 +++++++-- .../jetty/deploy/BarContextHandler.java | 20 +++++++++++++++++ .../providers/ContextProviderStartupTest.java | 22 +++++-------------- .../webapps/bar-core-context.properties | 2 ++ .../org/eclipse/jetty/server/Deployable.java | 1 + 5 files changed, 36 insertions(+), 19 deletions(-) create mode 100644 jetty-core/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/BarContextHandler.java create mode 100644 jetty-core/jetty-deploy/src/test/resources/webapps/bar-core-context.properties diff --git a/jetty-core/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ContextProvider.java b/jetty-core/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ContextProvider.java index e85b040e1a47..daeed0af8e8b 100644 --- a/jetty-core/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ContextProvider.java +++ b/jetty-core/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ContextProvider.java @@ -347,6 +347,12 @@ public ContextHandler createContextHandler(final App app) throws Exception properties.putAll(getProperties()); Object context = null; + //check if there is a specific ContextHandler type to create set in the + //properties associated with the webapp. If there is, we create it _before_ + //applying the environment xml file. + String contextHandlerClassName = app.getProperties().get(Deployable.CONTEXT_HANDLER_CLASS); + if (contextHandlerClassName != null) + context = Class.forName(contextHandlerClassName).getDeclaredConstructor().newInstance(); //add in environment-specific properties String env = app.getEnvironmentName() == null ? "" : app.getEnvironmentName(); @@ -367,7 +373,7 @@ public ContextHandler createContextHandler(final App app) throws Exception if (!envXmlPath.isAbsolute()) envXmlPath = getMonitoredDirResource().getPath().getParent().resolve(envXmlPath); - context = applyXml(null, envXmlPath, env, properties); + context = applyXml(context, envXmlPath, env, properties); } } @@ -409,7 +415,7 @@ else if (!Files.isDirectory(path) && !FileID.isWebArchive(path)) // Build the web application if necessary if (context == null) { - String contextHandlerClassName = (String)environment.getAttribute("contextHandlerClass"); + contextHandlerClassName = (String)environment.getAttribute("contextHandlerClass"); if (StringUtil.isBlank(contextHandlerClassName)) throw new IllegalStateException("No ContextHandler classname for " + app); Class contextHandlerClass = Loader.loadClass(contextHandlerClassName); diff --git a/jetty-core/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/BarContextHandler.java b/jetty-core/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/BarContextHandler.java new file mode 100644 index 000000000000..8d3de661c283 --- /dev/null +++ b/jetty-core/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/BarContextHandler.java @@ -0,0 +1,20 @@ +// +// ======================================================================== +// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others. +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License v. 2.0 which is available at +// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +// which is available at https://www.apache.org/licenses/LICENSE-2.0. +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// ======================================================================== +// + +package org.eclipse.jetty.deploy; + +import org.eclipse.jetty.server.handler.ContextHandler; + +public class BarContextHandler extends ContextHandler +{ +} diff --git a/jetty-core/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ContextProviderStartupTest.java b/jetty-core/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ContextProviderStartupTest.java index 821ea0054ded..c9072312e461 100644 --- a/jetty-core/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ContextProviderStartupTest.java +++ b/jetty-core/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ContextProviderStartupTest.java @@ -17,29 +17,16 @@ import java.nio.file.Path; import java.nio.file.StandardCopyOption; import java.nio.file.StandardOpenOption; -import java.time.Duration; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingDeque; -import java.util.concurrent.TimeUnit; - -import org.eclipse.jetty.deploy.AppProvider; -import org.eclipse.jetty.deploy.DeploymentManager; + +import org.eclipse.jetty.deploy.BarContextHandler; import org.eclipse.jetty.deploy.test.XmlConfiguredJetty; import org.eclipse.jetty.server.Deployable; -import org.eclipse.jetty.server.Handler; -import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.toolchain.test.FS; import org.eclipse.jetty.toolchain.test.MavenPaths; import org.eclipse.jetty.toolchain.test.jupiter.WorkDir; import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension; -import org.eclipse.jetty.util.Scanner; -import org.eclipse.jetty.util.component.Container; import org.eclipse.jetty.util.component.LifeCycle; -import org.eclipse.jetty.util.resource.Resource; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -113,13 +100,14 @@ public void testStartupWithRelativeEnvironmentContext() throws Exception Path propsFile = Files.writeString(jettyBase.resolve("webapps/core.properties"), Deployable.ENVIRONMENT_XML + " = etc/core-context.xml", StandardOpenOption.CREATE_NEW); assertTrue(Files.exists(propsFile)); Files.copy(MavenPaths.findTestResourceFile("etc/core-context.xml"), jettyBase.resolve("etc/core-context.xml"), StandardCopyOption.REPLACE_EXISTING); - + jetty.copyWebapp("bar-core-context.properties", "bar.properties"); startJetty(); //check environment context xml was applied to the produced context ContextHandler context = jetty.getContextHandler("/bar"); assertNotNull(context); assertThat(context.getAttribute("somename"), equalTo("somevalue")); + assertTrue(context instanceof BarContextHandler); } @@ -131,7 +119,7 @@ public void testStartupWithAbsoluteEnvironmentContext() throws Exception MavenPaths.findTestResourceFile("etc/core-context.xml"), StandardOpenOption.CREATE_NEW); assertTrue(Files.exists(propsFile)); Files.copy(MavenPaths.findTestResourceFile("etc/core-context.xml"), jettyBase.resolve("etc/core-context.xml"), StandardCopyOption.REPLACE_EXISTING); - + jetty.copyWebapp("bar-core-context.properties", "bar-core-context.properties"); startJetty(); //check environment context xml was applied to the produced context diff --git a/jetty-core/jetty-deploy/src/test/resources/webapps/bar-core-context.properties b/jetty-core/jetty-deploy/src/test/resources/webapps/bar-core-context.properties new file mode 100644 index 000000000000..2ad513333744 --- /dev/null +++ b/jetty-core/jetty-deploy/src/test/resources/webapps/bar-core-context.properties @@ -0,0 +1,2 @@ +environment: core +jetty.deploy.contextHandlerClass: org.eclipse.jetty.deploy.BarContextHandler \ No newline at end of file diff --git a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/Deployable.java b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/Deployable.java index a6a2466517ce..d08275f8cccb 100644 --- a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/Deployable.java +++ b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/Deployable.java @@ -56,6 +56,7 @@ public interface Deployable String CONFIGURATION_CLASSES = "jetty.deploy.configurationClasses"; String CONTAINER_SCAN_JARS = "jetty.deploy.containerScanJarPattern"; String CONTEXT_PATH = "jetty.deploy.contextPath"; + String CONTEXT_HANDLER_CLASS = "jetty.deploy.contextHandlerClass"; String DEFAULTS_DESCRIPTOR = "jetty.deploy.defaultsDescriptor"; String ENVIRONMENT = "environment"; String ENVIRONMENT_XML = "jetty.deploy.environmentXml"; From cb5d1371a5044358851be5975a08cae9ee178087 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Thu, 13 Jun 2024 09:34:17 +1000 Subject: [PATCH 3/7] Remove tab char --- .../org/eclipse/jetty/deploy/providers/ContextProvider.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jetty-core/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ContextProvider.java b/jetty-core/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ContextProvider.java index daeed0af8e8b..58205dca57be 100644 --- a/jetty-core/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ContextProvider.java +++ b/jetty-core/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ContextProvider.java @@ -352,7 +352,7 @@ public ContextHandler createContextHandler(final App app) throws Exception //applying the environment xml file. String contextHandlerClassName = app.getProperties().get(Deployable.CONTEXT_HANDLER_CLASS); if (contextHandlerClassName != null) - context = Class.forName(contextHandlerClassName).getDeclaredConstructor().newInstance(); + context = Class.forName(contextHandlerClassName).getDeclaredConstructor().newInstance(); //add in environment-specific properties String env = app.getEnvironmentName() == null ? "" : app.getEnvironmentName(); From 8bb2d5e45d5ec700be7b26b3501abe1f2eb3ed80 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Thu, 13 Jun 2024 10:49:41 +1000 Subject: [PATCH 4/7] Checkstyle --- .../jetty/deploy/providers/ContextProvider.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/jetty-core/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ContextProvider.java b/jetty-core/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ContextProvider.java index 58205dca57be..37e7f7f6ff19 100644 --- a/jetty-core/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ContextProvider.java +++ b/jetty-core/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ContextProvider.java @@ -78,8 +78,8 @@ *

For XML configured contexts, the ID map will contain a reference to the {@link Server} instance called "Server" and * properties for the webapp file such as "jetty.webapp" and directory as "jetty.webapps". * The properties will be initialized with:

    - *
  • The properties set on the application via {@link App#getProperties()}; otherwise:
  • - *
  • The properties set on this provider via {@link #getProperties()}
  • + *
  • The properties set on the application via {@link App#getProperties()}; otherwise:
  • + *
  • The properties set on this provider via {@link #getProperties()}
  • *
*/ @ManagedObject("Provider for start-up deployment of webapps based on presence in directory") @@ -244,6 +244,7 @@ public void setDefaultsDescriptor(String defaultsDescriptor) /** * This is equivalent to setting the {@link Deployable#CONFIGURATION_CLASSES} property. + * * @param configurations The configuration class names as a comma separated list */ public void setConfigurationClasses(String configurations) @@ -253,6 +254,7 @@ public void setConfigurationClasses(String configurations) /** * This is equivalent to setting the {@link Deployable#CONFIGURATION_CLASSES} property. + * * @param configurations The configuration class names. */ public void setConfigurationClasses(String[] configurations) @@ -263,8 +265,8 @@ public void setConfigurationClasses(String[] configurations) } /** - * * This is equivalent to getting the {@link Deployable#CONFIGURATION_CLASSES} property. + * * @return The configuration class names. */ @ManagedAttribute("configuration classes for webapps to be processed through") @@ -383,7 +385,7 @@ public ContextHandler createContextHandler(final App app) throws Exception // Handle a context XML file if (FileID.isXml(path)) { - context = applyXml(context, path, env, properties); + context = applyXml(context, path, env, properties); // Look for the contextHandler itself ContextHandler contextHandler = null; @@ -425,7 +427,7 @@ else if (!Files.isDirectory(path) && !FileID.isWebArchive(path)) context = contextHandlerClass.getDeclaredConstructor().newInstance(); properties.put(Deployable.WAR, path.toString()); } - + return initializeContextHandler(context, path, properties); } finally @@ -439,7 +441,6 @@ protected Object applyXml(Object context, Path xml, String environment, Map Date: Thu, 13 Jun 2024 11:53:39 +1000 Subject: [PATCH 5/7] Fix license header --- .../eclipse/jetty/deploy/BarContextHandler.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/jetty-core/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/BarContextHandler.java b/jetty-core/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/BarContextHandler.java index 8d3de661c283..0ccd1dc10ff5 100644 --- a/jetty-core/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/BarContextHandler.java +++ b/jetty-core/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/BarContextHandler.java @@ -1,14 +1,14 @@ // -// ======================================================================== -// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others. +// ======================================================================== +// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others. // -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License v. 2.0 which is available at -// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License v. 2.0 which is available at +// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +// which is available at https://www.apache.org/licenses/LICENSE-2.0. // -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// ======================================================================== +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// ======================================================================== // package org.eclipse.jetty.deploy; From 6ed752af3e7d79adc845edd3393699af8b15aaa0 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Thu, 13 Jun 2024 12:05:16 +1000 Subject: [PATCH 6/7] License. --- .../test/java/org/eclipse/jetty/deploy/BarContextHandler.java | 1 + 1 file changed, 1 insertion(+) diff --git a/jetty-core/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/BarContextHandler.java b/jetty-core/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/BarContextHandler.java index 0ccd1dc10ff5..e6f0b1c81349 100644 --- a/jetty-core/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/BarContextHandler.java +++ b/jetty-core/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/BarContextHandler.java @@ -11,6 +11,7 @@ // ======================================================================== // + package org.eclipse.jetty.deploy; import org.eclipse.jetty.server.handler.ContextHandler; From a865698edf2934621bcbb58bbe14c005da4c9834 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Thu, 13 Jun 2024 12:30:22 +1000 Subject: [PATCH 7/7] Checkstyle --- .../test/java/org/eclipse/jetty/deploy/BarContextHandler.java | 1 - 1 file changed, 1 deletion(-) diff --git a/jetty-core/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/BarContextHandler.java b/jetty-core/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/BarContextHandler.java index e6f0b1c81349..0ccd1dc10ff5 100644 --- a/jetty-core/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/BarContextHandler.java +++ b/jetty-core/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/BarContextHandler.java @@ -11,7 +11,6 @@ // ======================================================================== // - package org.eclipse.jetty.deploy; import org.eclipse.jetty.server.handler.ContextHandler;