List of usage examples for org.springframework.beans.factory.config ConfigurableListableBeanFactory getBean
Object getBean(String name) throws BeansException;
From source file:com.payu.ratel.config.beans.RegistryBeanProviderFactory.java
protected RegistryStrategiesProvider doCreate(ConfigurableListableBeanFactory beanFactory) { final Environment environment = beanFactory.getBean(Environment.class); if (environment.containsProperty(SERVICE_DISCOVERY_ZK_HOST)) { return new ZookeeperRegistryBeanProvider(beanFactory); } else if (environment.containsProperty(SERVICE_DISCOVERY_ADDRESS)) { return new InMemoryRegistryBeanProviderFactory(beanFactory); }// w w w .j av a 2s . c o m throw new IllegalStateException(String.format("Provide one of props with registry either %s or %s", SERVICE_DISCOVERY_ZK_HOST, SERVICE_DISCOVERY_ADDRESS)); }
From source file:com.payu.ratel.config.beans.RegistryBeanProviderFactory.java
public RegistryStrategiesProvider create(ConfigurableListableBeanFactory beanFactory) { final Environment environment = beanFactory.getBean(Environment.class); if ("false".equals(environment.getProperty(RatelContextApplier.SERVICE_DISCOVERY_ENABLED))) { LOGGER.info("Ratel is disabled"); return null; }/*w w w . jav a 2s. com*/ LOGGER.info("Ratel is enabled"); RegistryStrategiesProvider registryBeanProvider; try { registryBeanProvider = beanFactory.getBean(RegistryStrategiesProvider.class); LOGGER.info("Ratel was already configured, skiping second initialization"); } catch (NoSuchBeanDefinitionException e) { registryBeanProvider = createAndRegisterStrategiesProvider(beanFactory); LOGGER.info("Ratel is configured"); } return registryBeanProvider; }
From source file:com.payu.ratel.config.beans.ServiceRegisterPostProcessorFactory.java
@SuppressWarnings("PMD.EmptyCatchBlock") public ServiceRegisterPostProcessor create(ConfigurableListableBeanFactory beanFactory, RegisterStrategy registerStrategy) { SelfAddressProviderChain selfAddressProvider = beanFactory.getBean(SelfAddressProviderChain.class); if (selfAddressProvider == null) { throw new IllegalStateException("No SelfAddressProvider bean in context"); }//from w w w. ja v a 2 s . c o m final HostAndPort hostAndPort = selfAddressProvider.getHostAndPort(); ServletContext servletContext = null; try { servletContext = beanFactory.getBean(ServletContext.class); } catch (NoSuchBeanDefinitionException e) { } final String contextRoot = servletContext != null ? servletContext.getContextPath() : ""; final String address = String.format("http://%s:%s%s%s", hostAndPort.getHostText(), hostAndPort.getPort(), contextRoot, RATEL_PATH); return new ServiceRegisterPostProcessor(beanFactory, registerStrategy, address); }
From source file:com.payu.ratel.client.AbstractClientProxyGenerator.java
public AbstractClientProxyGenerator(ConfigurableListableBeanFactory beanFactory) { super();//from ww w . j av a2s . c om this.beanFactory = beanFactory; this.env = beanFactory.getBean(Environment.class); }
From source file:me.j360.trace.example.consumer2.RegisterZipkinHealthIndicators.java
@Override public void onApplicationEvent(ApplicationEvent event) { if (!(event instanceof ApplicationReadyEvent)) return;//from www .j a v a 2 s .co m ConfigurableListableBeanFactory beanFactory = ((ApplicationReadyEvent) event).getApplicationContext() .getBeanFactory(); ZipkinHealthIndicator healthIndicator = beanFactory.getBean(ZipkinHealthIndicator.class); for (Component component : beanFactory.getBeansOfType(Component.class).values()) { healthIndicator.addComponent(component); } }
From source file:io.dohko.jdbi.spring.beans.factory.DBIRepositoryDefinitionBeanFactoryProcessor.java
/** * Defines an {@link IDBI} bean if and only if it is undefined. * <p> //from www.ja v a2s .c o m * * @param beanFactory the bean factory used by the application context */ private void defineIdbiBeanIfUndefined(ConfigurableListableBeanFactory beanFactory) { try { beanFactory.getBean(IDBI.class); } catch (NoSuchBeanDefinitionException undefinedIdbiBean) { try { beanFactory.getBean(DBI.class); } catch (NoSuchBeanDefinitionException undefinedDbiBean) { AbstractBeanDefinition beanDefinition = BeanDefinitionBuilder .rootBeanDefinition(DBIFactoryBean2.class) .addConstructorArgValue(beanFactory.getBean(DataSource.class)) .setAutowireMode(AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE) .setScope(BeanDefinition.SCOPE_SINGLETON).getBeanDefinition(); ((DefaultListableBeanFactory) beanFactory).registerBeanDefinition("dbi", beanDefinition); } } }
From source file:com.mmnaseri.dragonfly.runtime.session.impl.SessionPostProcessorHandler.java
private ModifiableEntityContext getEntityContext(ConfigurableListableBeanFactory beanFactory) { return entityContext = entityContext != null ? entityContext : beanFactory.getBean(ModifiableEntityContext.class); }
From source file:com.mmnaseri.dragonfly.runtime.session.impl.SessionPostProcessorHandler.java
private DatabaseDialect getDatabaseDialect(ConfigurableListableBeanFactory beanFactory) { return databaseDialect = databaseDialect != null ? databaseDialect : beanFactory.getBean(DatabaseDialect.class); }
From source file:com.mmnaseri.dragonfly.runtime.session.impl.SessionPostProcessorHandler.java
private StatementRegistry getStatementRegistry(ConfigurableListableBeanFactory beanFactory) { return statementRegistry = statementRegistry != null ? statementRegistry : beanFactory.getBean(StatementRegistry.class); }
From source file:com.mmnaseri.dragonfly.runtime.session.impl.SessionPostProcessorHandler.java
private TableMetadataRegistry getTableMetadataRegistry(ConfigurableListableBeanFactory beanFactory) { return tableMetadataRegistry = tableMetadataRegistry != null ? tableMetadataRegistry : beanFactory.getBean(TableMetadataRegistry.class); }