|
|
|
@ -19,11 +19,10 @@ import org.redisson.Redisson;
|
|
|
|
|
import org.redisson.api.RedissonClient;
|
|
|
|
|
import org.redisson.api.RedissonReactiveClient;
|
|
|
|
|
import org.redisson.api.RedissonRxClient;
|
|
|
|
|
import org.redisson.config.ClusterServersConfig;
|
|
|
|
|
import org.redisson.config.Config;
|
|
|
|
|
import org.redisson.config.SentinelServersConfig;
|
|
|
|
|
import org.redisson.config.SingleServerConfig;
|
|
|
|
|
import org.redisson.config.*;
|
|
|
|
|
import org.redisson.spring.data.connection.RedissonConnectionFactory;
|
|
|
|
|
import org.springframework.beans.factory.BeanFactory;
|
|
|
|
|
import org.springframework.beans.factory.ObjectProvider;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
|
|
|
@ -32,6 +31,8 @@ import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
|
|
|
|
|
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
|
|
|
|
|
import org.springframework.boot.autoconfigure.data.redis.RedisProperties.Sentinel;
|
|
|
|
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
|
|
|
import org.springframework.boot.ssl.SslBundle;
|
|
|
|
|
import org.springframework.boot.ssl.SslBundles;
|
|
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
@ -204,6 +205,7 @@ public class RedissonAutoConfiguration {
|
|
|
|
|
if (connectTimeoutMethod != null && timeout != null) {
|
|
|
|
|
c.setTimeout(timeout);
|
|
|
|
|
}
|
|
|
|
|
initSSL(c);
|
|
|
|
|
} else if (clusterMethod != null && ReflectionUtils.invokeMethod(clusterMethod, redisProperties) != null) {
|
|
|
|
|
Object clusterObject = ReflectionUtils.invokeMethod(clusterMethod, redisProperties);
|
|
|
|
|
Method nodesMethod = ReflectionUtils.findMethod(clusterObject.getClass(), "getNodes");
|
|
|
|
@ -223,6 +225,7 @@ public class RedissonAutoConfiguration {
|
|
|
|
|
if (connectTimeoutMethod != null && timeout != null) {
|
|
|
|
|
c.setTimeout(timeout);
|
|
|
|
|
}
|
|
|
|
|
initSSL(c);
|
|
|
|
|
} else {
|
|
|
|
|
config = new Config();
|
|
|
|
|
|
|
|
|
@ -238,6 +241,7 @@ public class RedissonAutoConfiguration {
|
|
|
|
|
if (connectTimeoutMethod != null && timeout != null) {
|
|
|
|
|
c.setTimeout(timeout);
|
|
|
|
|
}
|
|
|
|
|
initSSL(c);
|
|
|
|
|
}
|
|
|
|
|
if (redissonAutoConfigurationCustomizers != null) {
|
|
|
|
|
for (RedissonAutoConfigurationCustomizer customizer : redissonAutoConfigurationCustomizers) {
|
|
|
|
@ -247,6 +251,32 @@ public class RedissonAutoConfiguration {
|
|
|
|
|
return Redisson.create(config);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void initSSL(BaseConfig<?> config) {
|
|
|
|
|
Method getSSLMethod = ReflectionUtils.findMethod(RedisProperties.class, "getSsl");
|
|
|
|
|
if (getSSLMethod == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RedisProperties.Ssl ssl = redisProperties.getSsl();
|
|
|
|
|
if (ssl.getBundle() == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ObjectProvider<SslBundles> provider = ctx.getBeanProvider(SslBundles.class);
|
|
|
|
|
SslBundles bundles = provider.getIfAvailable();
|
|
|
|
|
if (bundles == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
SslBundle b = bundles.getBundle(ssl.getBundle());
|
|
|
|
|
if (b == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
config.setSslCiphers(b.getOptions().getCiphers());
|
|
|
|
|
config.setSslProtocols(b.getOptions().getEnabledProtocols());
|
|
|
|
|
config.setSslTrustManagerFactory(b.getManagers().getTrustManagerFactory());
|
|
|
|
|
config.setSslKeyManagerFactory(b.getManagers().getKeyManagerFactory());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getPrefix() {
|
|
|
|
|
String prefix = REDIS_PROTOCOL_PREFIX;
|
|
|
|
|
Method isSSLMethod = ReflectionUtils.findMethod(RedisProperties.class, "isSsl");
|
|
|
|
|