diff --git a/core/src/main/java/org/springframework/plugin/core/config/PluginListDefinitionParser.java b/core/src/main/java/org/springframework/plugin/core/config/PluginListDefinitionParser.java deleted file mode 100644 index b2b29d7..0000000 --- a/core/src/main/java/org/springframework/plugin/core/config/PluginListDefinitionParser.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2008-2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.plugin.core.config; - -import org.springframework.beans.factory.support.AbstractBeanDefinition; -import org.springframework.beans.factory.support.BeanDefinitionBuilder; -import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser; -import org.springframework.beans.factory.xml.ParserContext; -import org.w3c.dom.Element; - -/** - * Bean definition parser to register {@code } elements from the plugin namespace. - * - * @author Oliver Gierke - */ -public class PluginListDefinitionParser extends AbstractBeanDefinitionParser { - - protected static final String PACKAGE = "org.springframework.plugin.core.support."; - - /** - * Returns the name of the {@link org.springframework.beans.factory.config.BeanFactoryPostProcessor} to be registered. - * - * @return - */ - protected String getPostProcessorName() { - return PACKAGE + "BeanListFactoryBean"; - } - - /* - * (non-Javadoc) - * @see org.springframework.beans.factory.xml.AbstractBeanDefinitionParser#parseInternal(org.w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext) - */ - @Override - protected AbstractBeanDefinition parseInternal(Element element, ParserContext context) { - - BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(getPostProcessorName()); - builder.addPropertyValue("type", element.getAttribute("class")); - - return getSourcedBeanDefinition(builder, element, context); - } - - /** - * Returns the bean definition prepared by the builder and has connected it to the {@code source} object. - * - * @param builder - * @param source - * @param context - * @return - */ - private AbstractBeanDefinition getSourcedBeanDefinition(BeanDefinitionBuilder builder, Object source, - ParserContext context) { - - AbstractBeanDefinition definition = builder.getRawBeanDefinition(); - definition.setSource(context.extractSource(source)); - - return definition; - } - - /* - * (non-Javadoc) - * @see org.springframework.beans.factory.xml.AbstractBeanDefinitionParser#shouldGenerateIdAsFallback() - */ - @Override - protected boolean shouldGenerateIdAsFallback() { - return true; - } -} diff --git a/core/src/main/java/org/springframework/plugin/core/config/PluginNamespaceHandler.java b/core/src/main/java/org/springframework/plugin/core/config/PluginNamespaceHandler.java deleted file mode 100644 index 22b4d23..0000000 --- a/core/src/main/java/org/springframework/plugin/core/config/PluginNamespaceHandler.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2008-2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.plugin.core.config; - -import org.springframework.beans.factory.xml.NamespaceHandlerSupport; - -/** - * Simple namespace handler for {@literal plugin-config} namespace. - * - * @author Oliver Gierke - */ -public class PluginNamespaceHandler extends NamespaceHandlerSupport { - - /* - * (non-Javadoc) - * @see org.springframework.beans.factory.xml.NamespaceHandler#init() - */ - public void init() { - registerBeanDefinitionParser("list", new PluginListDefinitionParser()); - registerBeanDefinitionParser("registry", new PluginRegistryDefinitionParser()); - } -} diff --git a/core/src/main/java/org/springframework/plugin/core/config/PluginRegistryDefinitionParser.java b/core/src/main/java/org/springframework/plugin/core/config/PluginRegistryDefinitionParser.java deleted file mode 100644 index f08d2af..0000000 --- a/core/src/main/java/org/springframework/plugin/core/config/PluginRegistryDefinitionParser.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2008-2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.plugin.core.config; - - -/** - * Simple extension of {@link PluginListDefinitionParser}. Simply registers a - * {@link PluginRegistryBeanFactoryPostProcessor} instead of the original class. - * - * @author Oliver Gierke - */ -public class PluginRegistryDefinitionParser extends PluginListDefinitionParser { - - /* - * (non-Javadoc) - * @see org.springframework.plugin.core.config.PluginListDefinitionParser#getPostProcessorName() - */ - @Override - protected String getPostProcessorName() { - return PACKAGE + "PluginRegistryFactoryBean"; - } -} diff --git a/core/src/main/resources/META-INF/spring.handlers b/core/src/main/resources/META-INF/spring.handlers deleted file mode 100644 index 99d9f28..0000000 --- a/core/src/main/resources/META-INF/spring.handlers +++ /dev/null @@ -1 +0,0 @@ -http\://www.springframework.org/schema/plugin=org.springframework.plugin.core.config.PluginNamespaceHandler \ No newline at end of file diff --git a/core/src/main/resources/META-INF/spring.schemas b/core/src/main/resources/META-INF/spring.schemas deleted file mode 100644 index 8094178..0000000 --- a/core/src/main/resources/META-INF/spring.schemas +++ /dev/null @@ -1 +0,0 @@ -http\://www.springframework.org/schema/plugin/spring-plugin.xsd=org/springframework/plugin/core/config/spring-plugin.xsd \ No newline at end of file diff --git a/core/src/main/resources/META-INF/spring.tooling b/core/src/main/resources/META-INF/spring.tooling deleted file mode 100644 index 998b903..0000000 --- a/core/src/main/resources/META-INF/spring.tooling +++ /dev/null @@ -1,4 +0,0 @@ -# Tooling related information for the Spring Plugin namespace -http\://www.springframework.org/schema/plugin@name=Spring Plugin Namespace -http\://www.springframework.org/schema/plugin@prefix=plugin -http\://www.springframework.org/schema/plugin@icon=org/springframework/beans/factory/xml/spring-beans.gif \ No newline at end of file diff --git a/core/src/main/resources/org/springframework/plugin/core/config/spring-plugin.xsd b/core/src/main/resources/org/springframework/plugin/core/config/spring-plugin.xsd deleted file mode 100644 index aca98f6..0000000 --- a/core/src/main/resources/org/springframework/plugin/core/config/spring-plugin.xsd +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - Collects all beans implementing the - configured interface and exposes them as list under the - configured id. Can be used in a nested manner, too. Will - regard the order of the collected beans if they either - implement Ordered or are annotated with @Order. - - - - - - - - - - - - - Creates a PluginRegistry for all beans - implementing the configured type. Thus the type - configured in the class attribute has to extend Plugin. - The registry will consider the order of the plugins if - they implement Ordered or are annotated with @Order. - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/core/src/test/java/org/springframework/plugin/core/config/PluginConfigurationIntegrationTest.java b/core/src/test/java/org/springframework/plugin/core/config/PluginConfigurationIntegrationTest.java index 513b291..89b468c 100644 --- a/core/src/test/java/org/springframework/plugin/core/config/PluginConfigurationIntegrationTest.java +++ b/core/src/test/java/org/springframework/plugin/core/config/PluginConfigurationIntegrationTest.java @@ -17,16 +17,15 @@ package org.springframework.plugin.core.config; import static org.assertj.core.api.Assertions.*; -import java.util.List; - import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; import org.springframework.plugin.core.PluginRegistry; import org.springframework.plugin.core.SamplePlugin; import org.springframework.plugin.core.SamplePluginHost; -import org.springframework.test.context.ContextConfiguration; +import org.springframework.plugin.core.SamplePluginImplementation; import org.springframework.test.context.junit.jupiter.SpringExtension; /** @@ -35,28 +34,35 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; * @author Oliver Gierke */ @ExtendWith(SpringExtension.class) -@ContextConfiguration(locations = "classpath:application-context.xml") class PluginConfigurationIntegrationTest { - @Autowired List samplePlugins; + @Configuration + @EnablePluginRegistries(SamplePlugin.class) + static class Config { - @Autowired @Qualifier("bar") PluginRegistry pluginRegistry; + @Bean + SamplePluginHost samplePluginHost(PluginRegistry registry) { - @Autowired @Qualifier("host") SamplePluginHost host; + var host = new SamplePluginHost(); + host.setRegistry(registry); - @Autowired @Qualifier("otherHost") SamplePluginHost otherHost; + return host; + } + @Bean + SamplePluginImplementation samplePluginImplementation() { + return new SamplePluginImplementation(); + } + } + + @Autowired PluginRegistry pluginRegistry; + @Autowired SamplePluginHost host; @Autowired SamplePlugin plugin; @Test void test() throws Exception { - assertThat(samplePlugins).isNotNull(); - assertThat(pluginRegistry).isSameAs(host.getRegistry()); - assertThat(pluginRegistry).isNotSameAs(otherHost.getRegistry()); - - assertThat(samplePlugins).contains(plugin); assertThat(pluginRegistry).contains(plugin); } } diff --git a/core/src/test/resources/application-context.xml b/core/src/test/resources/application-context.xml deleted file mode 100644 index 9e7458d..0000000 --- a/core/src/test/resources/application-context.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - -