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:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user