From 9e444a910e06531421b1201ba06c3b203d907b09 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Mon, 16 Nov 2020 08:18:58 -0600 Subject: [PATCH] Remove dead /jetty-spring/ module Signed-off-by: Joakim Erdfelt --- Jenkinsfile | 2 +- javadoc/pom.xml | 6 - jetty-bom/pom.xml | 5 - .../asciidoc/old_docs/frameworks/chapter.adoc | 1 - .../old_docs/frameworks/spring-usage.adoc | 104 ----------- jetty-home/pom.xml | 37 +--- jetty-maven-plugin/pom.xml | 4 - jetty-spring/pom.xml | 81 --------- .../src/main/config/etc/jetty-spring.xml | 61 ------- .../src/main/config/modules/spring.mod | 16 -- jetty-spring/src/main/java/module-info.java | 32 ---- .../java/org/eclipse/jetty/spring/Main.java | 34 ---- .../spring/SpringConfigurationProcessor.java | 170 ------------------ .../SpringConfigurationProcessorFactory.java | 43 ----- .../eclipse/jetty/spring/package-info.java | 23 --- ...se.jetty.xml.ConfigurationProcessorFactory | 1 - .../spring/SpringXmlConfigurationTest.java | 163 ----------------- .../jetty/spring/TestConfiguration.java | 154 ---------------- .../org/eclipse/jetty/spring/configure.xml | 34 ---- .../org/eclipse/jetty/spring/jetty.xml | 40 ----- pom.xml | 1 - 21 files changed, 3 insertions(+), 1009 deletions(-) delete mode 100644 jetty-documentation/src/main/asciidoc/old_docs/frameworks/spring-usage.adoc delete mode 100644 jetty-spring/pom.xml delete mode 100644 jetty-spring/src/main/config/etc/jetty-spring.xml delete mode 100644 jetty-spring/src/main/config/modules/spring.mod delete mode 100644 jetty-spring/src/main/java/module-info.java delete mode 100644 jetty-spring/src/main/java/org/eclipse/jetty/spring/Main.java delete mode 100644 jetty-spring/src/main/java/org/eclipse/jetty/spring/SpringConfigurationProcessor.java delete mode 100644 jetty-spring/src/main/java/org/eclipse/jetty/spring/SpringConfigurationProcessorFactory.java delete mode 100644 jetty-spring/src/main/java/org/eclipse/jetty/spring/package-info.java delete mode 100644 jetty-spring/src/main/resources/META-INF/services/org.eclipse.jetty.xml.ConfigurationProcessorFactory delete mode 100644 jetty-spring/src/test/java/org/eclipse/jetty/spring/SpringXmlConfigurationTest.java delete mode 100644 jetty-spring/src/test/java/org/eclipse/jetty/spring/TestConfiguration.java delete mode 100644 jetty-spring/src/test/resources/org/eclipse/jetty/spring/configure.xml delete mode 100644 jetty-spring/src/test/resources/org/eclipse/jetty/spring/jetty.xml diff --git a/Jenkinsfile b/Jenkinsfile index 96b6e718233a..fbe1da1cdecf 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -25,7 +25,7 @@ pipeline { ',**/org/eclipse/jetty/demo/**' + // special environments / late integrations ',**/org/eclipse/jetty/gcloud/**' + ',**/org/eclipse/jetty/infinispan/**' + - ',**/org/eclipse/jetty/osgi/**' + ',**/org/eclipse/jetty/spring/**' + + ',**/org/eclipse/jetty/osgi/**' + ',**/org/eclipse/jetty/http/spi/**' + // test classes ',**/org/eclipse/jetty/tests/**' + ',**/org/eclipse/jetty/test/**', diff --git a/javadoc/pom.xml b/javadoc/pom.xml index 387f5c15da8f..1402daf873fe 100644 --- a/javadoc/pom.xml +++ b/javadoc/pom.xml @@ -330,12 +330,6 @@ ${project.version} provided - - org.eclipse.jetty - jetty-spring - ${project.version} - provided - org.eclipse.jetty jetty-start diff --git a/jetty-bom/pom.xml b/jetty-bom/pom.xml index 1b57992da501..ad8357a1e855 100644 --- a/jetty-bom/pom.xml +++ b/jetty-bom/pom.xml @@ -292,11 +292,6 @@ jetty-servlets 10.0.0-SNAPSHOT - - org.eclipse.jetty - jetty-spring - 10.0.0-SNAPSHOT - org.eclipse.jetty jetty-unixsocket-common diff --git a/jetty-documentation/src/main/asciidoc/old_docs/frameworks/chapter.adoc b/jetty-documentation/src/main/asciidoc/old_docs/frameworks/chapter.adoc index cccdd7d6f49d..46aef5f4d025 100644 --- a/jetty-documentation/src/main/asciidoc/old_docs/frameworks/chapter.adoc +++ b/jetty-documentation/src/main/asciidoc/old_docs/frameworks/chapter.adoc @@ -21,6 +21,5 @@ include::cdi.adoc[] include::weld.adoc[] -include::spring-usage.adoc[] include::osgi.adoc[] include::metro.adoc[] diff --git a/jetty-documentation/src/main/asciidoc/old_docs/frameworks/spring-usage.adoc b/jetty-documentation/src/main/asciidoc/old_docs/frameworks/spring-usage.adoc deleted file mode 100644 index 2888c22a6b78..000000000000 --- a/jetty-documentation/src/main/asciidoc/old_docs/frameworks/spring-usage.adoc +++ /dev/null @@ -1,104 +0,0 @@ -// -// ======================================================================== -// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. -// -// This program and the accompanying materials are made available under -// the terms of the Eclipse Public License 2.0 which is available at -// https://www.eclipse.org/legal/epl-2.0 -// -// This Source Code may also be made available under the following -// Secondary Licenses when the conditions for such availability set -// forth in the Eclipse Public License, v. 2.0 are satisfied: -// the Apache License v2.0 which is available at -// https://www.apache.org/licenses/LICENSE-2.0 -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// ======================================================================== -// - -[[framework-jetty-spring]] -=== Spring Setup - -You can assemble and configure Jetty in code or with almost any IoC style framework including Spring. -If all you want to do is setup a Jetty server in your stock Spring usage, simply look at the xml snippet below as an example. -If you want to replace the jetty-xml being used to start the normal Jetty distribution with spring, you may do so however currently it will not leverage the rest of the module system. - -==== Jetty-Spring Module - -The skeleton of a jetty spring module can be enabled from the jetty-distribution via the link:#startup-modules[module mechanism]. -For example: - -[source, screen, subs="{sub-order}"] -.... -$ java -jar start.jar --add-to-start=spring -.... - -This (or the alternative link:#start-jar[--add-to-start]=spring command) creates a `${jetty.home}/lib/spring` directory and populates it with the jetty-spring integration jar. -It does NOT supply the spring jars and their dependencies. -You will need to download these and place them into jetty's classpath - you can use the `${jetty.home}/lib/spring` directory created by spring.mod for this purpose. - -==== Using Spring to Configure Jetty - -Configuring Jetty via Spring is simply a matter of calling the API as Spring beans. -The following is an example mimicking the default jetty startup configuration. - -[source, xml, subs="{sub-order}"] ----- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ----- diff --git a/jetty-home/pom.xml b/jetty-home/pom.xml index 0397b02b90cf..595cb10fda81 100644 --- a/jetty-home/pom.xml +++ b/jetty-home/pom.xml @@ -126,7 +126,7 @@ org.eclipse.jetty.orbit,org.eclipse.jetty.http2,org.eclipse.jetty.websocket,org.eclipse.jetty.fcgi,org.eclipse.jetty.toolchain,org.apache.taglibs - apache-jsp,apache-jstl,jetty-start,jetty-spring,jetty-slf4j-impl + apache-jsp,apache-jstl,jetty-start,jetty-slf4j-impl jar ${assembly-directory}/lib @@ -144,7 +144,7 @@ org.eclipse.jetty.orbit,org.eclipse.jetty.http2,org.eclipse.jetty.websocket,org.eclipse.jetty.fcgi,org.eclipse.jetty.toolchain,org.apache.taglibs - apache-jsp,apache-jstl,jetty-start,jetty-spring + apache-jsp,apache-jstl,jetty-start jar sources @@ -282,33 +282,6 @@ ${source-assembly-directory}/lib/fcgi - - copy-lib-spring-deps - generate-resources - - copy-dependencies - - - org.eclipse.jetty - jetty-spring - jar - ${assembly-directory}/lib/spring - - - - copy-lib-spring-src-deps - generate-resources - - copy-dependencies - - - org.eclipse.jetty - jetty-spring - jar - sources - ${source-assembly-directory}/lib/spring - - copy-servlet-api-deps generate-resources @@ -702,12 +675,6 @@ ${project.version} true - - org.eclipse.jetty - jetty-spring - ${project.version} - true - org.jboss.logging jboss-logging diff --git a/jetty-maven-plugin/pom.xml b/jetty-maven-plugin/pom.xml index 0220b1df2dd6..7f7da35f21d4 100644 --- a/jetty-maven-plugin/pom.xml +++ b/jetty-maven-plugin/pom.xml @@ -308,10 +308,6 @@ org.eclipse.jetty.fcgi fcgi-server - - org.eclipse.jetty - jetty-spring - org.eclipse.jetty jetty-start diff --git a/jetty-spring/pom.xml b/jetty-spring/pom.xml deleted file mode 100644 index 301c2d795345..000000000000 --- a/jetty-spring/pom.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - org.eclipse.jetty - jetty-project - 10.0.0-SNAPSHOT - - - 4.0.0 - jetty-spring - Example :: Jetty Spring - - - target/dependencies - ${project.groupId}.spring - - - - install - - - org.jacoco - jacoco-maven-plugin - - true - - - - org.apache.felix - maven-bundle-plugin - true - - - osgi.extender; filter:="(osgi.extender=osgi.serviceloader.registrar)";resolution:=optional - - - osgi.serviceloader;osgi.serviceloader=org.eclipse.jetty.xml.ConfigurationProcessorFactory - - - - - - - - - org.eclipse.jetty - jetty-xml - ${project.version} - - - org.eclipse.jetty - jetty-util - ${project.version} - - - org.springframework - spring-beans - ${spring-version} - - - org.slf4j - slf4j-api - - - org.eclipse.jetty - jetty-server - ${project.version} - test - - - - org.eclipse.jetty - jetty-slf4j-impl - test - - - org.eclipse.jetty.toolchain - jetty-test-helper - test - - - diff --git a/jetty-spring/src/main/config/etc/jetty-spring.xml b/jetty-spring/src/main/config/etc/jetty-spring.xml deleted file mode 100644 index 40a5e7cf1bb4..000000000000 --- a/jetty-spring/src/main/config/etc/jetty-spring.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jetty-spring/src/main/config/modules/spring.mod b/jetty-spring/src/main/config/modules/spring.mod deleted file mode 100644 index 5e50bf5c22ce..000000000000 --- a/jetty-spring/src/main/config/modules/spring.mod +++ /dev/null @@ -1,16 +0,0 @@ -# DO NOT EDIT - See: https://www.eclipse.org/jetty/documentation/current/startup-modules.html - -[description] -Enables Spring configuration processing of Jetty XML files. -All Jetty-style XML files can optionally be written as Spring beans.2 - -[depend] -server - -[lib] -lib/spring/*.jar - -[ini-template] -## See https://eclipse.org/jetty/documentation/current/frameworks.html#framework-jetty-spring -## for information on how to complete spring configuration - diff --git a/jetty-spring/src/main/java/module-info.java b/jetty-spring/src/main/java/module-info.java deleted file mode 100644 index 1ab02eee9671..000000000000 --- a/jetty-spring/src/main/java/module-info.java +++ /dev/null @@ -1,32 +0,0 @@ -// -// ======================================================================== -// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. -// -// This program and the accompanying materials are made available under -// the terms of the Eclipse Public License 2.0 which is available at -// https://www.eclipse.org/legal/epl-2.0 -// -// This Source Code may also be made available under the following -// Secondary Licenses when the conditions for such availability set -// forth in the Eclipse Public License, v. 2.0 are satisfied: -// the Apache License v2.0 which is available at -// https://www.apache.org/licenses/LICENSE-2.0 -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// ======================================================================== -// - -import org.eclipse.jetty.spring.SpringConfigurationProcessorFactory; -import org.eclipse.jetty.xml.ConfigurationProcessorFactory; - -module org.eclipse.jetty.spring -{ - exports org.eclipse.jetty.spring; - - requires transitive org.eclipse.jetty.xml; - requires org.slf4j; - requires spring.beans; - requires spring.core; - - provides ConfigurationProcessorFactory with SpringConfigurationProcessorFactory; -} diff --git a/jetty-spring/src/main/java/org/eclipse/jetty/spring/Main.java b/jetty-spring/src/main/java/org/eclipse/jetty/spring/Main.java deleted file mode 100644 index 56324a96bc35..000000000000 --- a/jetty-spring/src/main/java/org/eclipse/jetty/spring/Main.java +++ /dev/null @@ -1,34 +0,0 @@ -// -// ======================================================================== -// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. -// -// This program and the accompanying materials are made available under -// the terms of the Eclipse Public License 2.0 which is available at -// https://www.eclipse.org/legal/epl-2.0 -// -// This Source Code may also be made available under the following -// Secondary Licenses when the conditions for such availability set -// forth in the Eclipse Public License, v. 2.0 are satisfied: -// the Apache License v2.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.spring; - -import org.eclipse.jetty.util.resource.Resource; -import org.eclipse.jetty.xml.XmlConfiguration; - -/** - * Runs Jetty from a Spring configuration file passed as argument. - */ -public class Main -{ - public static void main(String[] args) throws Exception - { - Resource config = Resource.newResource(args.length == 1 ? args[0] : "etc/jetty-spring.xml"); - XmlConfiguration.main(config.getFile().getAbsolutePath()); - } -} diff --git a/jetty-spring/src/main/java/org/eclipse/jetty/spring/SpringConfigurationProcessor.java b/jetty-spring/src/main/java/org/eclipse/jetty/spring/SpringConfigurationProcessor.java deleted file mode 100644 index 82ecf83a5ee1..000000000000 --- a/jetty-spring/src/main/java/org/eclipse/jetty/spring/SpringConfigurationProcessor.java +++ /dev/null @@ -1,170 +0,0 @@ -// -// ======================================================================== -// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. -// -// This program and the accompanying materials are made available under -// the terms of the Eclipse Public License 2.0 which is available at -// https://www.eclipse.org/legal/epl-2.0 -// -// This Source Code may also be made available under the following -// Secondary Licenses when the conditions for such availability set -// forth in the Eclipse Public License, v. 2.0 are satisfied: -// the Apache License v2.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.spring; - -import java.nio.charset.StandardCharsets; -import java.util.Arrays; -import java.util.Map; -import java.util.ServiceLoader; - -import org.eclipse.jetty.xml.ConfigurationProcessor; -import org.eclipse.jetty.xml.ConfigurationProcessorFactory; -import org.eclipse.jetty.xml.XmlConfiguration; -import org.eclipse.jetty.xml.XmlParser; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.BeanWrapper; -import org.springframework.beans.PropertyValues; -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.beans.factory.support.DefaultListableBeanFactory; -import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.core.io.ByteArrayResource; -import org.springframework.core.io.Resource; -import org.springframework.core.io.UrlResource; - -/** - * Spring ConfigurationProcessor - *

- * A {@link ConfigurationProcessor} that uses a spring XML file to emulate the {@link XmlConfiguration} format. - *

- * {@link XmlConfiguration} expects a primary object that is either passed in to a call to {@link #configure(Object)} - * or that is constructed by a call to {@link #configure()}. This processor looks for a bean definition - * with an id, name or alias of "Main" as uses that as the primary bean. - *

- * The objects mapped by {@link XmlConfiguration#getIdMap()} are set as singletons before any configuration calls - * and if the spring configuration file contains a definition for the singleton id, the the singleton is updated - * with a call to {@link DefaultListableBeanFactory#configureBean(Object, String)}. - *

- * The property map obtained via {@link XmlConfiguration#getProperties()} is set as a singleton called "properties" - * and values can be accessed by somewhat verbose - * usage of {@link org.springframework.beans.factory.config.MethodInvokingFactoryBean}. - *

- * This processor is returned by the {@link SpringConfigurationProcessorFactory} for any XML document whos first - * element is "beans". The factory is discovered by a {@link ServiceLoader} for {@link ConfigurationProcessorFactory}. - */ -public class SpringConfigurationProcessor implements ConfigurationProcessor -{ - private static final Logger LOG = LoggerFactory.getLogger(SpringConfigurationProcessor.class); - - private XmlConfiguration _configuration; - private DefaultListableBeanFactory _beanFactory; - private String _main; - - @Override - public void init(org.eclipse.jetty.util.resource.Resource jettyResource, XmlParser.Node config, XmlConfiguration configuration) - { - try - { - _configuration = configuration; - - Resource springResource; - - if (jettyResource != null) - { - springResource = new UrlResource(jettyResource.getURI()); - } - else - { - springResource = new ByteArrayResource(( - "" + - "" + - config).getBytes(StandardCharsets.UTF_8)); - } - - _beanFactory = new DefaultListableBeanFactory() - { - @Override - protected void applyPropertyValues(String beanName, BeanDefinition mbd, BeanWrapper bw, PropertyValues pvs) - { - _configuration.initializeDefaults(bw.getWrappedInstance()); - super.applyPropertyValues(beanName, mbd, bw, pvs); - } - }; - - new XmlBeanDefinitionReader(_beanFactory).loadBeanDefinitions(springResource); - } - catch (Exception e) - { - throw new RuntimeException(e); - } - } - - @Override - public Object configure(Object obj) throws Exception - { - doConfigure(); - return _beanFactory.configureBean(obj, _main); - } - - /** - * Return a configured bean. If a bean has the id or alias of "Main", then it is returned, otherwise the first bean in the file is returned. - * - * @see org.eclipse.jetty.xml.ConfigurationProcessor#configure() - */ - @Override - public Object configure() throws Exception - { - doConfigure(); - return _beanFactory.getBean(_main); - } - - private void doConfigure() - { - _beanFactory.registerSingleton("properties", _configuration.getProperties()); - - // Look for the main bean; - for (String bean : _beanFactory.getBeanDefinitionNames()) - { - LOG.debug("{} - {}", bean, Arrays.asList(_beanFactory.getAliases(bean))); - String[] aliases = _beanFactory.getAliases(bean); - if ("Main".equals(bean) || aliases != null && Arrays.asList(aliases).contains("Main")) - { - _main = bean; - break; - } - } - if (_main == null) - _main = _beanFactory.getBeanDefinitionNames()[0]; - - // Register id beans as singletons - Map idMap = _configuration.getIdMap(); - LOG.debug("idMap {}", idMap); - for (String id : idMap.keySet()) - { - LOG.debug("register {}", id); - _beanFactory.registerSingleton(id, idMap.get(id)); - } - - // Apply configuration to existing singletons - for (String id : idMap.keySet()) - { - if (_beanFactory.containsBeanDefinition(id)) - { - LOG.debug("reconfigure {}", id); - _beanFactory.configureBean(idMap.get(id), id); - } - } - - // Extract id's for next time. - for (String id : _beanFactory.getSingletonNames()) - { - idMap.put(id, _beanFactory.getBean(id)); - } - } -} diff --git a/jetty-spring/src/main/java/org/eclipse/jetty/spring/SpringConfigurationProcessorFactory.java b/jetty-spring/src/main/java/org/eclipse/jetty/spring/SpringConfigurationProcessorFactory.java deleted file mode 100644 index cb03ef6a2d66..000000000000 --- a/jetty-spring/src/main/java/org/eclipse/jetty/spring/SpringConfigurationProcessorFactory.java +++ /dev/null @@ -1,43 +0,0 @@ -// -// ======================================================================== -// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. -// -// This program and the accompanying materials are made available under -// the terms of the Eclipse Public License 2.0 which is available at -// https://www.eclipse.org/legal/epl-2.0 -// -// This Source Code may also be made available under the following -// Secondary Licenses when the conditions for such availability set -// forth in the Eclipse Public License, v. 2.0 are satisfied: -// the Apache License v2.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.spring; - -import org.eclipse.jetty.xml.ConfigurationProcessor; -import org.eclipse.jetty.xml.ConfigurationProcessorFactory; -import org.eclipse.jetty.xml.XmlConfiguration; - -/** - * Spring ConfigurationProcessor Factory - *

- * Create a {@link SpringConfigurationProcessor} for XML documents with a "beans" element. - * The factory is discovered by a {@link java.util.ServiceLoader} for {@link ConfigurationProcessorFactory}. - * - * @see SpringConfigurationProcessor - * @see XmlConfiguration - */ -public class SpringConfigurationProcessorFactory implements ConfigurationProcessorFactory -{ - @Override - public ConfigurationProcessor getConfigurationProcessor(String dtd, String tag) - { - if ("beans".equals(tag)) - return new SpringConfigurationProcessor(); - return null; - } -} diff --git a/jetty-spring/src/main/java/org/eclipse/jetty/spring/package-info.java b/jetty-spring/src/main/java/org/eclipse/jetty/spring/package-info.java deleted file mode 100644 index d16ace03ff9b..000000000000 --- a/jetty-spring/src/main/java/org/eclipse/jetty/spring/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -// -// ======================================================================== -// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. -// -// This program and the accompanying materials are made available under -// the terms of the Eclipse Public License 2.0 which is available at -// https://www.eclipse.org/legal/epl-2.0 -// -// This Source Code may also be made available under the following -// Secondary Licenses when the conditions for such availability set -// forth in the Eclipse Public License, v. 2.0 are satisfied: -// the Apache License v2.0 which is available at -// https://www.apache.org/licenses/LICENSE-2.0 -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// ======================================================================== -// - -/** - * Jetty Spring : Spring IoC Configuration for Jetty - */ -package org.eclipse.jetty.spring; - diff --git a/jetty-spring/src/main/resources/META-INF/services/org.eclipse.jetty.xml.ConfigurationProcessorFactory b/jetty-spring/src/main/resources/META-INF/services/org.eclipse.jetty.xml.ConfigurationProcessorFactory deleted file mode 100644 index 0289454079c8..000000000000 --- a/jetty-spring/src/main/resources/META-INF/services/org.eclipse.jetty.xml.ConfigurationProcessorFactory +++ /dev/null @@ -1 +0,0 @@ -org.eclipse.jetty.spring.SpringConfigurationProcessorFactory diff --git a/jetty-spring/src/test/java/org/eclipse/jetty/spring/SpringXmlConfigurationTest.java b/jetty-spring/src/test/java/org/eclipse/jetty/spring/SpringXmlConfigurationTest.java deleted file mode 100644 index 3dc3353d3d4b..000000000000 --- a/jetty-spring/src/test/java/org/eclipse/jetty/spring/SpringXmlConfigurationTest.java +++ /dev/null @@ -1,163 +0,0 @@ -// -// ======================================================================== -// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. -// -// This program and the accompanying materials are made available under -// the terms of the Eclipse Public License 2.0 which is available at -// https://www.eclipse.org/legal/epl-2.0 -// -// This Source Code may also be made available under the following -// Secondary Licenses when the conditions for such availability set -// forth in the Eclipse Public License, v. 2.0 are satisfied: -// the Apache License v2.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.spring; - -import java.net.URL; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.util.resource.Resource; -import org.eclipse.jetty.xml.XmlConfiguration; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assumptions.assumeTrue; - -public class SpringXmlConfigurationTest -{ - protected String _configure = "org/eclipse/jetty/spring/configure.xml"; - - @BeforeEach - public void init() - { - // Jetty's XML configuration will make use of java.util.ServiceLoader - // to load the proper ConfigurationProcessorFactory, so these tests - // will always fail in JDK 5. - - String javaVersion = System.getProperty("java.version"); - Pattern regexp = Pattern.compile("1\\.(\\d{1})\\..*"); - Matcher matcher = regexp.matcher(javaVersion); - if (matcher.matches()) - { - String minor = matcher.group(1); - assumeTrue(Integer.parseInt(minor) > 5); - } - } - - @Test - public void testPassedObject() throws Exception - { - TestConfiguration.VALUE = 77; - - URL url = SpringXmlConfigurationTest.class.getClassLoader().getResource(_configure); - XmlConfiguration configuration = new XmlConfiguration(Resource.newResource(url)); - - Map properties = new HashMap<>(); - properties.put("test", "xxx"); - - TestConfiguration nested = new TestConfiguration(); - nested.setTestString0("nested"); - configuration.getIdMap().put("nested", nested); - - TestConfiguration tc = new TestConfiguration(); - tc.setTestString0("preconfig"); - tc.setTestInt0(42); - configuration.getProperties().putAll(properties); - - tc = (TestConfiguration)configuration.configure(tc); - - assertEquals("preconfig", tc.getTestString0()); - assertEquals(42, tc.getTestInt0()); - assertEquals("SetValue", tc.getTestString1()); - assertEquals(1, tc.getTestInt1()); - - assertEquals("nested", tc.getNested().getTestString0()); - assertEquals("nested", tc.getNested().getTestString1()); - assertEquals("default", tc.getNested().getNested().getTestString0()); - assertEquals("deep", tc.getNested().getNested().getTestString1()); - - assertEquals("deep", ((TestConfiguration)configuration.getIdMap().get("nestedDeep")).getTestString1()); - assertEquals(2, ((TestConfiguration)configuration.getIdMap().get("nestedDeep")).getTestInt2()); - - assertEquals("xxx", tc.getTestString2()); - } - - @Test - public void testNewObject() throws Exception - { - final String newDefaultValue = "NEW DEFAULT"; - TestConfiguration.VALUE = 71; - - URL url = SpringXmlConfigurationTest.class.getClassLoader().getResource(_configure); - final AtomicInteger count = new AtomicInteger(0); - XmlConfiguration configuration = new XmlConfiguration(Resource.newResource(url)) - { - @Override - public void initializeDefaults(Object object) - { - super.initializeDefaults(object); - if (object instanceof TestConfiguration) - { - count.incrementAndGet(); - ((TestConfiguration)object).setTestString0(newDefaultValue); - ((TestConfiguration)object).setTestString1("WILL BE OVERRIDDEN"); - } - } - }; - - Map properties = new HashMap(); - properties.put("test", "xxx"); - - TestConfiguration nested = new TestConfiguration(); - nested.setTestString0("nested"); - configuration.getIdMap().put("nested", nested); - - configuration.getProperties().putAll(properties); - TestConfiguration tc = (TestConfiguration)configuration.configure(); - - assertEquals(3, count.get()); - - assertEquals(newDefaultValue, tc.getTestString0()); - assertEquals(-1, tc.getTestInt0()); - assertEquals("SetValue", tc.getTestString1()); - assertEquals(1, tc.getTestInt1()); - - assertEquals(newDefaultValue, tc.getNested().getTestString0()); - assertEquals("nested", tc.getNested().getTestString1()); - assertEquals(newDefaultValue, tc.getNested().getNested().getTestString0()); - assertEquals("deep", tc.getNested().getNested().getTestString1()); - - assertEquals("deep", ((TestConfiguration)configuration.getIdMap().get("nestedDeep")).getTestString1()); - assertEquals(2, ((TestConfiguration)configuration.getIdMap().get("nestedDeep")).getTestInt2()); - - assertEquals("xxx", tc.getTestString2()); - } - - @Test - public void testJettyXml() throws Exception - { - URL url = SpringXmlConfigurationTest.class.getClassLoader().getResource("org/eclipse/jetty/spring/jetty.xml"); - XmlConfiguration configuration = new XmlConfiguration(Resource.newResource(url)); - - Server server = (Server)configuration.configure(); - - server.dumpStdErr(); - } - - @Test - public void xmlConfigurationMain() throws Exception - { - XmlConfiguration.main("src/test/resources/org/eclipse/jetty/spring/jetty.xml"); - } -} diff --git a/jetty-spring/src/test/java/org/eclipse/jetty/spring/TestConfiguration.java b/jetty-spring/src/test/java/org/eclipse/jetty/spring/TestConfiguration.java deleted file mode 100644 index 9490a6564e12..000000000000 --- a/jetty-spring/src/test/java/org/eclipse/jetty/spring/TestConfiguration.java +++ /dev/null @@ -1,154 +0,0 @@ -// -// ======================================================================== -// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. -// -// This program and the accompanying materials are made available under -// the terms of the Eclipse Public License 2.0 which is available at -// https://www.eclipse.org/legal/epl-2.0 -// -// This Source Code may also be made available under the following -// Secondary Licenses when the conditions for such availability set -// forth in the Eclipse Public License, v. 2.0 are satisfied: -// the Apache License v2.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.spring; - -import java.net.URL; - -import org.junit.jupiter.api.Disabled; - -@Disabled -public class TestConfiguration -{ - public static int VALUE = 77; - - public TestConfiguration nested; - public String testString0 = "default"; - public String testString1; - public String testString2; - public int testInt0 = -1; - public int testInt1; - public int testInt2; - public URL url; - public Object[] objArray; - public int[] intArray; - - public static int getVALUE() - { - return VALUE; - } - - public static void setVALUE(int vALUE) - { - VALUE = vALUE; - } - - public TestConfiguration() - { - } - - public TestConfiguration getNested() - { - return nested; - } - - public void setNested(TestConfiguration nested) - { - this.nested = nested; - } - - public String getTestString0() - { - return testString0; - } - - public void setTestString0(String testString0) - { - this.testString0 = testString0; - } - - public String getTestString1() - { - return testString1; - } - - public void setTestString1(String testString1) - { - this.testString1 = testString1; - } - - public String getTestString2() - { - return testString2; - } - - public void setTestString2(String testString2) - { - this.testString2 = testString2; - } - - public int getTestInt0() - { - return testInt0; - } - - public void setTestInt0(int testInt0) - { - this.testInt0 = testInt0; - } - - public int getTestInt1() - { - return testInt1; - } - - public void setTestInt1(int testInt1) - { - this.testInt1 = testInt1; - } - - public int getTestInt2() - { - return testInt2; - } - - public void setTestInt2(int testInt2) - { - this.testInt2 = testInt2; - } - - public URL getUrl() - { - return url; - } - - public void setUrl(URL url) - { - this.url = url; - } - - public Object[] getObjArray() - { - return objArray; - } - - public void setObjArray(Object[] objArray) - { - this.objArray = objArray; - } - - public int[] getIntArray() - { - return intArray; - } - - public void setIntArray(int[] intArray) - { - this.intArray = intArray; - } -} diff --git a/jetty-spring/src/test/resources/org/eclipse/jetty/spring/configure.xml b/jetty-spring/src/test/resources/org/eclipse/jetty/spring/configure.xml deleted file mode 100644 index 80ef2f7a04b2..000000000000 --- a/jetty-spring/src/test/resources/org/eclipse/jetty/spring/configure.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - test - - - - - - - - - - - - - - - - - - - - - diff --git a/jetty-spring/src/test/resources/org/eclipse/jetty/spring/jetty.xml b/jetty-spring/src/test/resources/org/eclipse/jetty/spring/jetty.xml deleted file mode 100644 index 57b87cc407b9..000000000000 --- a/jetty-spring/src/test/resources/org/eclipse/jetty/spring/jetty.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pom.xml b/pom.xml index 5044d8550cb8..dad91c5f77ac 100644 --- a/pom.xml +++ b/pom.xml @@ -126,7 +126,6 @@ jetty-jndi jetty-jaas jetty-cdi - jetty-spring jetty-client jetty-proxy jetty-jaspi