org.zodiac.autoconfigure.lock.redis.reactive.ReactiveRedissonLockAutoConfiguration Maven / Gradle / Ivy
package org.zodiac.autoconfigure.lock.redis.reactive;
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.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.zodiac.autoconfigure.lock.LockAutoConfiguration;
import org.zodiac.commons.constants.SystemPropertiesConstants;
import org.zodiac.lock.base.LockFactory;
import org.zodiac.lock.redis.RedissonLockFactory;
import org.zodiac.lock.redis.RedissonLockHandler;
@AutoConfigureBefore(value = {LockAutoConfiguration.class})
@ConditionalOnClass(value = {org.zodiac.lock.base.LockFactory.class, org.redisson.api.RedissonClient.class})
@ConditionalOnProperty(value = SystemPropertiesConstants.Zodiac.SPRING_LOCK_TYPE, havingValue = "redisson")
public class ReactiveRedissonLockAutoConfiguration {
@Configuration
@ConditionalOnMissingBean(name = LockFactory.DEFAULT_LOCK_FACTORY_BEAN)
@ConditionalOnBean(org.redisson.api.RedissonClient.class)
public static class LockFactoryAutoConfiguration {
@Bean
public RedissonLockHandler redissonLockHandler() {
return new RedissonLockHandler();
}
@Bean(name = LockFactory.DEFAULT_LOCK_FACTORY_BEAN)
public RedissonLockFactory redissonLockFactory(org.redisson.api.RedissonClient redissonClient,
RedissonLockHandler redissonLockHandler) {
return new RedissonLockFactory(redissonClient, redissonLockHandler);
}
}
}