use of org.apereo.cas.monitor.PooledLdapConnectionFactoryHealthIndicator in project cas by apereo.
the class LdapMonitorConfiguration method pooledLdapConnectionFactoryHealthIndicator.
@Autowired
@Bean
public HealthIndicator pooledLdapConnectionFactoryHealthIndicator(@Qualifier("pooledConnectionFactoryMonitorExecutorService") final ExecutorService executor) {
final MonitorProperties.Ldap ldap = casProperties.getMonitor().getLdap();
final PooledConnectionFactory connectionFactory = LdapUtils.newLdaptivePooledConnectionFactory(ldap);
return new PooledLdapConnectionFactoryHealthIndicator(Beans.newDuration(ldap.getMaxWait()).toMillis(), connectionFactory, executor, new SearchValidator());
}
use of org.apereo.cas.monitor.PooledLdapConnectionFactoryHealthIndicator in project cas by apereo.
the class LdapMonitorConfiguration method pooledLdapConnectionFactoryHealthIndicator.
@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
@ConditionalOnEnabledHealthIndicator("pooledLdapConnectionFactoryHealthIndicator")
public CompositeHealthContributor pooledLdapConnectionFactoryHealthIndicator(final CasConfigurationProperties casProperties, @Qualifier("pooledLdapConnectionFactoryHealthIndicatorListFactoryBean") final ListFactoryBean factoryBean) throws Exception {
val ldaps = casProperties.getMonitor().getLdap();
val connectionFactoryList = Objects.requireNonNull(factoryBean.getObject());
val contributors = new LinkedHashMap<>();
ldaps.stream().filter(LdapMonitorProperties::isEnabled).map(Unchecked.function(ldap -> {
val executor = Beans.newThreadPoolExecutorFactoryBean(ldap.getPool());
val connectionFactory = LdapUtils.newLdaptivePooledConnectionFactory(ldap);
connectionFactoryList.add(connectionFactory);
val healthIndicator = new PooledLdapConnectionFactoryHealthIndicator(Beans.newDuration(ldap.getMaxWait()).toMillis(), connectionFactory, executor.getObject(), new SearchConnectionValidator());
val name = StringUtils.defaultIfBlank(ldap.getName(), UUID.randomUUID().toString());
return Pair.of(name, healthIndicator);
})).forEach(it -> contributors.put(it.getKey(), it.getValue()));
return CompositeHealthContributor.fromMap((Map) contributors);
}
Aggregations