use of org.springframework.beans.factory.config.ConfigurableListableBeanFactory in project spring-cloud-connectors by spring-cloud.
the class AbstractCloudServiceConnectorFactory method afterPropertiesSet.
@Override
public void afterPropertiesSet() throws Exception {
ConfigurableListableBeanFactory beanFactory = (ConfigurableListableBeanFactory) getBeanFactory();
if (cloud == null) {
if (beanFactory.getBeansOfType(CloudFactory.class).isEmpty()) {
beanFactory.registerSingleton(CLOUD_FACTORY_BEAN_NAME, new CloudFactory());
}
CloudFactory cloudFactory = beanFactory.getBeansOfType(CloudFactory.class).values().iterator().next();
cloud = cloudFactory.getCloud();
}
if (!StringUtils.hasText(serviceId)) {
List<? extends ServiceInfo> infos = cloud.getServiceInfos(serviceConnectorType);
if (infos.size() != 1) {
throw new CloudException("Expected 1 service matching " + serviceConnectorType.getName() + " type, but found " + infos.size());
}
serviceId = infos.get(0).getId();
}
super.afterPropertiesSet();
}
use of org.springframework.beans.factory.config.ConfigurableListableBeanFactory in project spring-boot by spring-projects.
the class OnExpressionCondition method getMatchOutcome.
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
String expression = (String) metadata.getAnnotationAttributes(ConditionalOnExpression.class.getName()).get("value");
expression = wrapIfNecessary(expression);
String rawExpression = expression;
expression = context.getEnvironment().resolvePlaceholders(expression);
ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
BeanExpressionResolver resolver = (beanFactory != null) ? beanFactory.getBeanExpressionResolver() : null;
BeanExpressionContext expressionContext = (beanFactory != null) ? new BeanExpressionContext(beanFactory, null) : null;
if (resolver == null) {
resolver = new StandardBeanExpressionResolver();
}
boolean result = (Boolean) resolver.evaluate(expression, expressionContext);
return new ConditionOutcome(result, ConditionMessage.forCondition(ConditionalOnExpression.class, "(" + rawExpression + ")").resultedIn(result));
}
use of org.springframework.beans.factory.config.ConfigurableListableBeanFactory in project spring-boot by spring-projects.
the class ServletWebServerApplicationContext method selfInitialize.
private void selfInitialize(ServletContext servletContext) throws ServletException {
prepareWebApplicationContext(servletContext);
ConfigurableListableBeanFactory beanFactory = getBeanFactory();
ExistingWebApplicationScopes existingScopes = new ExistingWebApplicationScopes(beanFactory);
WebApplicationContextUtils.registerWebApplicationScopes(beanFactory, getServletContext());
existingScopes.restore();
WebApplicationContextUtils.registerEnvironmentBeans(beanFactory, getServletContext());
for (ServletContextInitializer beans : getServletContextInitializerBeans()) {
beans.onStartup(servletContext);
}
}
use of org.springframework.beans.factory.config.ConfigurableListableBeanFactory in project spring-cloud-connectors by spring-cloud.
the class CloudScanHelper method initializeCloud.
private void initializeCloud(BeanDefinitionRegistry registry) {
if (cloud != null) {
return;
}
ConfigurableListableBeanFactory beanFactory = (ConfigurableListableBeanFactory) registry;
if (beanFactory.getBeansOfType(CloudFactory.class).isEmpty()) {
beanFactory.registerSingleton(CLOUD_FACTORY_BEAN_NAME, new CloudFactory());
}
CloudFactory cloudFactory = beanFactory.getBeansOfType(CloudFactory.class).values().iterator().next();
cloud = cloudFactory.getCloud();
}
use of org.springframework.beans.factory.config.ConfigurableListableBeanFactory in project spring-boot by spring-projects.
the class ServletWebServerApplicationContextTests method doesNotReplaceExistingScopes.
@Test
public void doesNotReplaceExistingScopes() throws Exception {
// gh-2082
Scope scope = mock(Scope.class);
ConfigurableListableBeanFactory factory = this.context.getBeanFactory();
factory.registerScope(WebApplicationContext.SCOPE_REQUEST, scope);
factory.registerScope(WebApplicationContext.SCOPE_SESSION, scope);
addWebServerFactoryBean();
this.context.refresh();
assertThat(factory.getRegisteredScope(WebApplicationContext.SCOPE_REQUEST)).isSameAs(scope);
assertThat(factory.getRegisteredScope(WebApplicationContext.SCOPE_SESSION)).isSameAs(scope);
}
Aggregations