use of org.springframework.data.redis.connection.jedis.JedisConnectionFactory in project camel by apache.
the class RedisConfiguration method createDefaultConnectionFactory.
private RedisConnectionFactory createDefaultConnectionFactory() {
JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
managedConnectionFactory = true;
if (host != null) {
jedisConnectionFactory.setHostName(host);
}
if (port != null) {
jedisConnectionFactory.setPort(port);
}
jedisConnectionFactory.afterPropertiesSet();
connectionFactory = jedisConnectionFactory;
return jedisConnectionFactory;
}
use of org.springframework.data.redis.connection.jedis.JedisConnectionFactory in project spring-cloud-connectors by spring-cloud.
the class RedisConnectionFactoryCreator method create.
@Override
public RedisConnectionFactory create(RedisServiceInfo serviceInfo, ServiceConnectorConfig serviceConnectorConfig) {
if (hasClass(JEDIS_CLASS_NAME)) {
RedisConnectionFactoryConfigurer configurer = new RedisConnectionFactoryConfigurer();
JedisConnectionFactory connectionFactory = new JedisConnectionFactory();
connectionFactory.setHostName(serviceInfo.getHost());
connectionFactory.setPort(serviceInfo.getPort());
connectionFactory.setPassword(serviceInfo.getPassword());
if (serviceConnectorConfig instanceof RedisConnectionFactoryConfig) {
configurer.configure(connectionFactory, (RedisConnectionFactoryConfig) serviceConnectorConfig);
} else {
configurer.configure(connectionFactory, (PooledServiceConnectorConfig) serviceConnectorConfig);
}
connectionFactory.afterPropertiesSet();
return connectionFactory;
} else if (hasClass(LETTUCE_CLASS_NAME)) {
RedisLettuceConnectionFactoryConfigurer configurer = new RedisLettuceConnectionFactoryConfigurer();
LettuceConnectionFactory connectionFactory = new LettuceConnectionFactory();
connectionFactory.setHostName(serviceInfo.getHost());
connectionFactory.setPort(serviceInfo.getPort());
connectionFactory.setPassword(serviceInfo.getPassword());
configurer.configure(connectionFactory, (RedisConnectionFactoryConfig) serviceConnectorConfig);
connectionFactory.afterPropertiesSet();
return connectionFactory;
} else {
throw new ServiceConnectorCreationException(String.format("Failed to create cloud Redis connection factory " + "for %s service. No client implementation classes " + " of jedis or lettuce clients implementation (%s, %s) not found", serviceInfo.getId(), JEDIS_CLASS_NAME, LETTUCE_CLASS_NAME));
}
}
use of org.springframework.data.redis.connection.jedis.JedisConnectionFactory in project OpenClinica by OpenClinica.
the class DistributedSessionConfig method jedisConnectionFactory.
@Bean
public JedisConnectionFactory jedisConnectionFactory() throws Exception {
String port = null;
String host = null;
String password = null;
try {
// Redis URL should be of the format redis://h:<PASSWORD>@<HOSTNAME>:<PORT>
String redisUrl = environment.getProperty(REDIS_URL);
port = redisUrl.substring(redisUrl.lastIndexOf(":") + 1, redisUrl.length());
host = redisUrl.substring(redisUrl.lastIndexOf("@") + 1, redisUrl.lastIndexOf(":"));
password = redisUrl.substring(redisUrl.indexOf("h:") + 2, redisUrl.lastIndexOf("@"));
if (port == null || port.equals("") || host == null || host.equals("") || password == null || password.equals(""))
throw new Exception();
} catch (Exception e) {
throw new Exception("Error: REDIS_URL environment variable not defined or improperly formatted.");
}
JedisConnectionFactory jedisConnFactory = new JedisConnectionFactory();
jedisConnFactory.setHostName(host);
jedisConnFactory.setPort(Integer.valueOf(port));
jedisConnFactory.setPassword(password);
return jedisConnFactory;
}
Aggregations