org.apereo.cas.config.CasRedisEventsAutoConfiguration Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cas-server-support-events-redis Show documentation
Show all versions of cas-server-support-events-redis Show documentation
cas-server-support-events-redis
The newest version!
package org.apereo.cas.config;
import org.apereo.cas.authentication.CasSSLContext;
import org.apereo.cas.configuration.CasConfigurationProperties;
import org.apereo.cas.configuration.features.CasFeatureModule;
import org.apereo.cas.redis.core.CasRedisTemplate;
import org.apereo.cas.redis.core.RedisObjectFactory;
import org.apereo.cas.support.events.CasEventRepository;
import org.apereo.cas.support.events.CasEventRepositoryFilter;
import org.apereo.cas.support.events.redis.RedisCasEventRepository;
import org.apereo.cas.util.spring.boot.ConditionalOnFeatureEnabled;
import lombok.val;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
import org.springframework.data.redis.connection.RedisConnectionFactory;
/**
* This is {@link CasRedisEventsAutoConfiguration}.
*
* @author Misagh Moayyed
* @since 6.4.0
*/
@EnableConfigurationProperties(CasConfigurationProperties.class)
@ConditionalOnFeatureEnabled(feature = CasFeatureModule.FeatureCatalog.Events, module = "redis")
@AutoConfiguration
public class CasRedisEventsAutoConfiguration {
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
@Bean
public PersistenceExceptionTranslationPostProcessor persistenceExceptionTranslationPostProcessor() {
return new PersistenceExceptionTranslationPostProcessor();
}
@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
@ConditionalOnMissingBean(name = "redisEventConnectionFactory")
public RedisConnectionFactory redisEventConnectionFactory(
@Qualifier(CasSSLContext.BEAN_NAME)
final CasSSLContext casSslContext,
final CasConfigurationProperties casProperties) throws Exception {
val redis = casProperties.getEvents().getRedis();
return RedisObjectFactory.newRedisConnectionFactory(redis, casSslContext);
}
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
@Bean
@ConditionalOnMissingBean(name = "redisEventTemplate")
public CasRedisTemplate redisEventTemplate(
@Qualifier("redisEventConnectionFactory")
final RedisConnectionFactory redisEventConnectionFactory) {
return RedisObjectFactory.newRedisTemplate(redisEventConnectionFactory);
}
@ConditionalOnMissingBean(name = "redisEventRepositoryFilter")
@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
public CasEventRepositoryFilter redisEventRepositoryFilter() {
return CasEventRepositoryFilter.noOp();
}
@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
public CasEventRepository casEventRepository(
@Qualifier("redisEventTemplate")
final CasRedisTemplate redisEventTemplate,
@Qualifier("redisEventRepositoryFilter")
final CasEventRepositoryFilter redisEventRepositoryFilter,
final CasConfigurationProperties casProperties) {
return new RedisCasEventRepository(redisEventRepositoryFilter, redisEventTemplate,
casProperties.getEvents().getRedis().getScanCount());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy