From 509da3be5a1c5c487170465f0ce905100e181b92 Mon Sep 17 00:00:00 2001 From: Oliver Drotbohm Date: Fri, 14 Feb 2025 15:31:02 +0100 Subject: [PATCH] GH-108 - Re-introduce PluginRegistryFactoryBean to implement ApplicationContextAware and Initializing bean. We now implement the aforementioned interfaces again in deprecated form to allow the new arrangement to be a drop-in replacement for the old approach. --- .../support/PluginRegistryFactoryBean.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/springframework/plugin/core/support/PluginRegistryFactoryBean.java b/core/src/main/java/org/springframework/plugin/core/support/PluginRegistryFactoryBean.java index c10bef2..fcdd934 100644 --- a/core/src/main/java/org/springframework/plugin/core/support/PluginRegistryFactoryBean.java +++ b/core/src/main/java/org/springframework/plugin/core/support/PluginRegistryFactoryBean.java @@ -26,7 +26,10 @@ import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.beans.factory.FactoryBean; +import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.ListableBeanFactory; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; import org.springframework.lang.NonNull; import org.springframework.lang.Nullable; import org.springframework.plugin.core.OrderAwarePluginRegistry; @@ -39,7 +42,7 @@ import org.springframework.plugin.core.PluginRegistry; * @author Oliver Gierke */ public class PluginRegistryFactoryBean, S> - implements FactoryBean>, BeanFactoryAware { + implements FactoryBean>, BeanFactoryAware, ApplicationContextAware, InitializingBean { private Collection> exclusions = Collections.emptySet(); private @Nullable Class type; @@ -77,6 +80,16 @@ public class PluginRegistryFactoryBean, S> this.factory = factory; } + /** + * @see ApplicationContextAware#setApplicationContext(ApplicationContext) + * @deprecated since 4.0, in favor of {@link #setBeanFactory(BeanFactory)}. + */ + @Override + @Deprecated + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + setBeanFactory(applicationContext); + } + /* * (non-Javadoc) * @see org.springframework.beans.factory.FactoryBean#getObject() @@ -113,4 +126,14 @@ public class PluginRegistryFactoryBean, S> public boolean isSingleton() { return true; } + + /** + * @see InitializingBean#afterPropertiesSet() + * @deprecated since 4.0, not needed anymore. + */ + @Override + @Deprecated + public void afterPropertiesSet() { + // Only here for backwards-compatibility + } }