org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory Java Examples

The following examples show how to use org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PluginManagerImpl.java    From webanno with Apache License 2.0 6 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception
{
    loadPlugins();
    startPlugins();

    AbstractAutowireCapableBeanFactory beanFactory = (AbstractAutowireCapableBeanFactory) 
            applicationContext.getAutowireCapableBeanFactory();
    ExtensionsInjector extensionsInjector = new ExtensionsInjector(this, beanFactory);
    extensionsInjector.injectExtensions();
    
    // Add child application contexts for every plugin
    for (PluginWrapper plugin : getStartedPlugins()) {
        Class pluginClass = plugin.getPlugin().getClass();
        LOG.info("Found plugin: {}", plugin.getDescriptor().getPluginId());
        
        // Attach the plugin application context to the main application context such that it
        // can access its beans for auto-wiring
        GenericApplicationContext pluginContext = (GenericApplicationContext) 
                ((Plugin) plugin.getPlugin()).getApplicationContext();
        pluginContext.setParent(applicationContext);
    }
}
 
Example #2
Source File: SpringPluginManager.java    From pf4j-spring with Apache License 2.0 5 votes vote down vote up
/**
 * This method load, start plugins and inject extensions in Spring
 */
@PostConstruct
public void init() {
    loadPlugins();
    startPlugins();

    AbstractAutowireCapableBeanFactory beanFactory = (AbstractAutowireCapableBeanFactory) applicationContext.getAutowireCapableBeanFactory();
    ExtensionsInjector extensionsInjector = new ExtensionsInjector(this, beanFactory);
    extensionsInjector.injectExtensions();
}
 
Example #3
Source File: SpringBootPlugin.java    From sbp with Apache License 2.0 4 votes vote down vote up
public void unregisterBeanFromMainContext(String beanName) {
    Assert.notNull(beanName, "bean must not be null");
    ((AbstractAutowireCapableBeanFactory) getMainApplicationContext().getBeanFactory())
            .destroySingleton(beanName);
}
 
Example #4
Source File: SpringBootPlugin.java    From sbp with Apache License 2.0 4 votes vote down vote up
public void unregisterBeanFromMainContext(Object bean) {
    Assert.notNull(bean, "bean must not be null");
    String beanName = bean.getClass().getName();
    ((AbstractAutowireCapableBeanFactory) getMainApplicationContext().getBeanFactory())
            .destroySingleton(beanName);
}
 
Example #5
Source File: ExtensionsInjector.java    From pf4j-spring with Apache License 2.0 4 votes vote down vote up
public ExtensionsInjector(PluginManager pluginManager, AbstractAutowireCapableBeanFactory beanFactory) {
    this.pluginManager = pluginManager;
    this.beanFactory = beanFactory;
}