Example usage for org.springframework.data.redis.connection.jedis JedisConnectionFactory getConnection

List of usage examples for org.springframework.data.redis.connection.jedis JedisConnectionFactory getConnection

Introduction

In this page you can find the example usage for org.springframework.data.redis.connection.jedis JedisConnectionFactory getConnection.

Prototype

public RedisConnection getConnection() 

Source Link

Usage

From source file:locksdemo.RedisServer.java

/**
 * Try to obtain and validate a resource. Implementors should either set the
 * {@link #resource} field with a valid resource and return normally, or throw an
 * exception./*from w  w  w .  jav a  2 s . c o m*/
 */
protected JedisConnectionFactory obtainResource() throws Exception {
    JedisConnectionFactory resource = new JedisConnectionFactory();
    resource.afterPropertiesSet();
    resource.getConnection().close();
    return resource;
}

From source file:org.springframework.boot.redis.RedisTestServer.java

private void testConnection(JedisConnectionFactory connectionFactory) {
    connectionFactory.getConnection().close();
}

From source file:org.springframework.integration.redis.rules.RedisAvailableRule.java

public Statement apply(final Statement base, final FrameworkMethod method, Object target) {
    return new Statement() {

        @Override/*from  w  w  w  . java  2s .  c  om*/
        public void evaluate() throws Throwable {
            RedisAvailable redisAvailable = method.getAnnotation(RedisAvailable.class);
            if (redisAvailable != null) {
                try {

                    JedisConnectionFactory connectionFactory = new JedisConnectionFactory();
                    connectionFactory.setPort(REDIS_PORT);
                    connectionFactory.afterPropertiesSet();
                    connectionFactory.getConnection();
                } catch (Exception e) {
                    if (logger.isWarnEnabled()) {
                        logger.warn(String.format(
                                "Redis is not available on " + "port '%s'. Skipping the test.", REDIS_PORT));
                    }
                    return;
                }
            }
            base.evaluate();
        }
    };

}