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.
This commit is contained in:
Oliver Drotbohm
2025-02-14 15:31:02 +01:00
parent 06ffe3c046
commit 509da3be5a

View File

@@ -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<T extends Plugin<S>, S>
implements FactoryBean<PluginRegistry<T, S>>, BeanFactoryAware {
implements FactoryBean<PluginRegistry<T, S>>, BeanFactoryAware, ApplicationContextAware, InitializingBean {
private Collection<Class<?>> exclusions = Collections.emptySet();
private @Nullable Class<T> type;
@@ -77,6 +80,16 @@ public class PluginRegistryFactoryBean<T extends Plugin<S>, 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<T extends Plugin<S>, 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
}
}