From a8d008b8516dc606fcb970c4a535262d7d8b23df Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Mon, 10 Jun 2019 08:19:59 -0500 Subject: [PATCH] Issue #3743 - Making new ConfigurationProcessor interface default Signed-off-by: Joakim Erdfelt --- .../jetty/xml/ConfigurationProcessor.java | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/jetty-xml/src/main/java/org/eclipse/jetty/xml/ConfigurationProcessor.java b/jetty-xml/src/main/java/org/eclipse/jetty/xml/ConfigurationProcessor.java index 59ed6f38b0c..bded5d54470 100644 --- a/jetty-xml/src/main/java/org/eclipse/jetty/xml/ConfigurationProcessor.java +++ b/jetty-xml/src/main/java/org/eclipse/jetty/xml/ConfigurationProcessor.java @@ -18,6 +18,7 @@ package org.eclipse.jetty.xml; +import java.net.MalformedURLException; import java.net.URL; import org.eclipse.jetty.util.resource.Resource; @@ -37,14 +38,29 @@ public interface ConfigurationProcessor * @deprecated use {@link #init(Resource, XmlParser.Node, XmlConfiguration)} instead */ @Deprecated - default void init(URL url, XmlParser.Node root, XmlConfiguration configuration) + void init(URL url, XmlParser.Node root, XmlConfiguration configuration); + + /** + * Initialize a ConfigurationProcessor from provided Resource and XML + * + * @param resource the resource being read + * @param root the parsed XML root node for the resource + * @param configuration the configuration being used (typically for ref IDs) + */ + default void init(Resource resource, XmlParser.Node root, XmlConfiguration configuration) { // Moving back and forth between URL and File/FileSystem/Path/Resource is known to cause escaping issues. - init(Resource.newResource(url), root, configuration); + try + { + init(resource.getURI().toURL(), root, configuration); + } + catch (MalformedURLException e) + { + throw new IllegalStateException("Unable to convert Resource to URL", e); + } } - void init(Resource resource, XmlParser.Node root, XmlConfiguration configuration); + Object configure(Object obj) throws Exception; - Object configure( Object obj) throws Exception; Object configure() throws Exception; }