use of org.apereo.cas.util.spring.beans.BeanContainer in project cas by apereo.
the class MongoDbMonitoringConfiguration method mongoHealthIndicator.
@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
@ConditionalOnEnabledHealthIndicator("mongoHealthIndicator")
@ConditionalOnMissingBean(name = "mongoHealthIndicator")
public HealthIndicator mongoHealthIndicator(final CasConfigurationProperties casProperties, @Qualifier("mongoHealthIndicatorTemplate") final BeanContainer<CasMongoOperations> mongoHealthIndicatorTemplate) {
val warn = casProperties.getMonitor().getWarn();
val results = mongoHealthIndicatorTemplate.toList().stream().map(template -> new MongoDbHealthIndicator(template, warn.getEvictionThreshold(), warn.getThreshold())).collect(Collectors.toList());
return new CompositeHealthIndicator(results);
}
use of org.apereo.cas.util.spring.beans.BeanContainer in project cas by apereo.
the class RedisAuthenticationConfiguration method redisPersonAttributeDaos.
@ConditionalOnMissingBean(name = "redisPersonAttributeDaos")
@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
public BeanContainer<IPersonAttributeDao> redisPersonAttributeDaos(final ConfigurableApplicationContext applicationContext, @Qualifier(CasSSLContext.BEAN_NAME) final CasSSLContext casSslContext, final CasConfigurationProperties casProperties) {
return BeanSupplier.of(BeanContainer.class).when(CONDITION.given(applicationContext.getEnvironment())).supply(() -> {
val redis = casProperties.getAuthn().getAttributeRepository().getRedis();
return BeanContainer.of(redis.stream().filter(r -> StringUtils.isNotBlank(r.getHost())).map(r -> {
val conn = RedisObjectFactory.newRedisConnectionFactory(r, true, casSslContext);
val template = RedisObjectFactory.newRedisTemplate(conn);
template.initialize();
val cb = new RedisPersonAttributeDao(template);
cb.setOrder(r.getOrder());
FunctionUtils.doIfNotNull(r.getId(), cb::setId);
return cb;
}).collect(Collectors.toList()));
}).otherwise(BeanContainer::empty).get();
}
Aggregations