Search in sources :

Example 11 with ListableBeanFactory

use of org.springframework.beans.factory.ListableBeanFactory in project ignite by apache.

the class GridJobLoadTest method startNode.

/**
 * Starts new grid node.
 *
 * @param igniteInstanceName name of new node.
 * @param springCfg file with spring configuration to use for this node.
 * @return a grid instance local to new node {@link org.apache.ignite.Ignition#start(org.apache.ignite.configuration.IgniteConfiguration)}.
 * @throws Exception if node run failed.
 */
protected Ignite startNode(String igniteInstanceName, File springCfg) throws Exception {
    assert springCfg != null;
    ListableBeanFactory springCtx = new FileSystemXmlApplicationContext("file:///" + springCfg.getAbsolutePath());
    Map cfgMap = springCtx.getBeansOfType(IgniteConfiguration.class);
    assert cfgMap != null;
    assert !cfgMap.isEmpty();
    IgniteConfiguration cfg = (IgniteConfiguration) cfgMap.values().iterator().next();
    cfg.setIgniteInstanceName(igniteInstanceName + "-" + getNextNodeNum());
    return G.start(cfg);
}
Also used : FileSystemXmlApplicationContext(org.springframework.context.support.FileSystemXmlApplicationContext) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Map(java.util.Map) ListableBeanFactory(org.springframework.beans.factory.ListableBeanFactory)

Example 12 with ListableBeanFactory

use of org.springframework.beans.factory.ListableBeanFactory in project camel by apache.

the class CamelCommandsPlugin method init.

@Override
public void init() {
    ListableBeanFactory beanFactory = (ListableBeanFactory) getContext().getAttributes().get("spring.beanfactory");
    this.facade = new CamelCommandsFacade(new CamelControllerImpl(beanFactory));
    setCamelPlugin(this);
}
Also used : ListableBeanFactory(org.springframework.beans.factory.ListableBeanFactory)

Example 13 with ListableBeanFactory

use of org.springframework.beans.factory.ListableBeanFactory in project spring-framework by spring-projects.

the class SchedulerAccessorBean method findScheduler.

protected Scheduler findScheduler(String schedulerName) throws SchedulerException {
    if (this.beanFactory instanceof ListableBeanFactory) {
        ListableBeanFactory lbf = (ListableBeanFactory) this.beanFactory;
        String[] beanNames = lbf.getBeanNamesForType(Scheduler.class);
        for (String beanName : beanNames) {
            Scheduler schedulerBean = (Scheduler) lbf.getBean(beanName);
            if (schedulerName.equals(schedulerBean.getSchedulerName())) {
                return schedulerBean;
            }
        }
    }
    Scheduler schedulerInRepo = SchedulerRepository.getInstance().lookup(schedulerName);
    if (schedulerInRepo == null) {
        throw new IllegalStateException("No Scheduler named '" + schedulerName + "' found");
    }
    return schedulerInRepo;
}
Also used : Scheduler(org.quartz.Scheduler) ListableBeanFactory(org.springframework.beans.factory.ListableBeanFactory)

Example 14 with ListableBeanFactory

use of org.springframework.beans.factory.ListableBeanFactory in project spring-boot by spring-projects.

the class ConfigurationPropertiesBindingPostProcessor method getSinglePropertySourcesPlaceholderConfigurer.

private PropertySourcesPlaceholderConfigurer getSinglePropertySourcesPlaceholderConfigurer() {
    // Take care not to cause early instantiation of all FactoryBeans
    if (this.beanFactory instanceof ListableBeanFactory) {
        ListableBeanFactory listableBeanFactory = (ListableBeanFactory) this.beanFactory;
        Map<String, PropertySourcesPlaceholderConfigurer> beans = listableBeanFactory.getBeansOfType(PropertySourcesPlaceholderConfigurer.class, false, false);
        if (beans.size() == 1) {
            return beans.values().iterator().next();
        }
        if (beans.size() > 1 && logger.isWarnEnabled()) {
            logger.warn("Multiple PropertySourcesPlaceholderConfigurer " + "beans registered " + beans.keySet() + ", falling back to Environment");
        }
    }
    return null;
}
Also used : PropertySourcesPlaceholderConfigurer(org.springframework.context.support.PropertySourcesPlaceholderConfigurer) ListableBeanFactory(org.springframework.beans.factory.ListableBeanFactory)

Example 15 with ListableBeanFactory

use of org.springframework.beans.factory.ListableBeanFactory in project spring-boot by spring-projects.

the class ResourceServerPropertiesTests method setListableBeanFactory.

private void setListableBeanFactory() {
    ListableBeanFactory beanFactory = new StaticWebApplicationContext() {

        @Override
        public String[] getBeanNamesForType(Class<?> type, boolean includeNonSingletons, boolean allowEagerInit) {
            if (type.isAssignableFrom(ResourceServerTokenServicesConfiguration.class)) {
                return new String[] { "ResourceServerTokenServicesConfiguration" };
            }
            return new String[0];
        }
    };
    this.properties.setBeanFactory(beanFactory);
}
Also used : StaticWebApplicationContext(org.springframework.web.context.support.StaticWebApplicationContext) ListableBeanFactory(org.springframework.beans.factory.ListableBeanFactory)

Aggregations

ListableBeanFactory (org.springframework.beans.factory.ListableBeanFactory)18 BeanFactory (org.springframework.beans.factory.BeanFactory)4 List (java.util.List)2 BeansException (org.springframework.beans.BeansException)2 FileSystemXmlApplicationContext (org.springframework.context.support.FileSystemXmlApplicationContext)2 PlatformTransactionManager (org.springframework.transaction.PlatformTransactionManager)2 BasicRefererInterfaceConfig (com.weibo.api.motan.config.BasicRefererInterfaceConfig)1 BasicServiceInterfaceConfig (com.weibo.api.motan.config.BasicServiceInterfaceConfig)1 XParam (io.leopard.web.xparam.XParam)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 DataSource (javax.sql.DataSource)1 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)1 Test (org.junit.Test)1 Scheduler (org.quartz.Scheduler)1 BeanClassLoaderAware (org.springframework.beans.factory.BeanClassLoaderAware)1 FactoryBean (org.springframework.beans.factory.FactoryBean)1 HierarchicalBeanFactory (org.springframework.beans.factory.HierarchicalBeanFactory)1 ConfigurableListableBeanFactory (org.springframework.beans.factory.config.ConfigurableListableBeanFactory)1 ListFactoryBean (org.springframework.beans.factory.config.ListFactoryBean)1