All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.zodiac.autoconfigure.lock.redis.reactive.ReactiveRedisTemplateLockAutoConfiguration Maven / Gradle / Ivy

There is a newer version: 1.6.8
Show newest version
package org.zodiac.autoconfigure.lock.redis.reactive;

import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
import org.springframework.context.annotation.Bean;
import org.zodiac.autoconfigure.lock.LockAutoConfiguration;
import org.zodiac.autoconfigure.lock.LockProperties;
import org.zodiac.commons.constants.SystemPropertiesConstants;
import org.zodiac.lock.base.LockFactory;
import org.zodiac.lock.redis.RedisTemplateLockHandler;
import org.zodiac.lock.redis.reactive.ReactiveRedisTemplateLockFactory;
import org.zodiac.lock.redis.reactive.ReactiveRedisTemplateLockHandler;

@ConditionalOnWebApplication(type = Type.REACTIVE)
@AutoConfigureBefore(value = {LockAutoConfiguration.class})
@ConditionalOnClass(value = {reactor.core.publisher.Mono.class, org.zodiac.lock.base.LockFactory.class,
    org.springframework.data.redis.core.ReactiveRedisTemplate.class})
@ConditionalOnProperty(value = SystemPropertiesConstants.Zodiac.SPRING_LOCK_TYPE, havingValue = "redistemplate")
public class ReactiveRedisTemplateLockAutoConfiguration {

    @SpringBootConfiguration
    @ConditionalOnWebApplication(type = Type.REACTIVE)
    @ConditionalOnMissingBean(name = LockFactory.DEFAULT_LOCK_FACTORY_BEAN)
    @ConditionalOnBean(org.springframework.data.redis.core.ReactiveRedisTemplate.class)
    protected static class LockFactoryAutoConfiguration {

        @Bean
        protected ReactiveRedisTemplateLockHandler redisTemplateLockHandler() {
            return new ReactiveRedisTemplateLockHandler();
        }

        @SuppressWarnings("rawtypes")
        @Bean(name = LockFactory.DEFAULT_LOCK_FACTORY_BEAN)
        protected ReactiveRedisTemplateLockFactory redisTemplateLock(
            org.springframework.data.redis.core.ReactiveRedisTemplate redisTemplate,
            RedisTemplateLockHandler redisLockHandler, LockProperties lockProperties) {
            return new ReactiveRedisTemplateLockFactory(redisTemplate, redisLockHandler,
                lockProperties.getScheduledPoolSize());
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy