当前位置: 首页>>代码示例>>Java>>正文


Java JedisConnectionFactory.afterPropertiesSet方法代码示例

本文整理汇总了Java中org.springframework.data.redis.connection.jedis.JedisConnectionFactory.afterPropertiesSet方法的典型用法代码示例。如果您正苦于以下问题:Java JedisConnectionFactory.afterPropertiesSet方法的具体用法?Java JedisConnectionFactory.afterPropertiesSet怎么用?Java JedisConnectionFactory.afterPropertiesSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.data.redis.connection.jedis.JedisConnectionFactory的用法示例。


在下文中一共展示了JedisConnectionFactory.afterPropertiesSet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildRedisTemplate

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
public static RedisTemplate buildRedisTemplate(byte[] redisProperties){
    JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory(
            RedisConfUtils.getClusterConfiguration(
                    (RedisProperties) Serializer.INSTANCE.deserialize(redisProperties)));
    RedisTemplate<String, Long> redisTemplate = new RedisTemplate<>();
    redisTemplate.setConnectionFactory(jedisConnectionFactory);
    jedisConnectionFactory.afterPropertiesSet();

    GenericJackson2JsonRedisSerializer genericJackson2JsonRedisSerializer = new GenericJackson2JsonRedisSerializer();
    StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
    redisTemplate.setKeySerializer(stringRedisSerializer);
    redisTemplate.setValueSerializer(genericJackson2JsonRedisSerializer);
    redisTemplate.setHashKeySerializer(stringRedisSerializer);
    redisTemplate.setHashValueSerializer(genericJackson2JsonRedisSerializer);
    redisTemplate.afterPropertiesSet();
    return redisTemplate;
}
 
开发者ID:Paleozoic,项目名称:storm_spring_boot_demo,代码行数:18,代码来源:RedisConfUtils.java

示例2: afterPropertiesSet

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
    int redisCount = Integer.parseInt(RedisProperties.getPropertie("redis.count").toString());
    factories = new ArrayList<JedisConnectionFactory>(redisCount);
    for (int i = 0; i < redisCount; i++) {
        int dbSize = 1;
        Object dbSizeObj = RedisProperties.getPropertie("redis.db.size" + i);
        if (dbSizeObj != null) {
            dbSize = Integer.valueOf(dbSizeObj.toString());
        }
        for (int j = 0; j < dbSize; j++) {
            JedisConnectionFactory factory = new JedisConnectionFactory(sentinelConfig,poolConfig);
            factory.setHostName(RedisProperties.getPropertie("redis.host" + i).toString());
            factory.setPort(Integer.parseInt(RedisProperties.getPropertie("redis.port" + i).toString()));
            factory.setPassword(RedisProperties.getPropertie("reids.passwd" + i).toString());
            factory.setTimeout(Integer.parseInt(RedisProperties.getPropertie("redis.timeout").toString()));
            factory.setDatabase(j);
            // 执行必要方法
            factory.afterPropertiesSet();
            factories.add(factory);
        }
    }
}
 
开发者ID:Fourwenwen,项目名称:consistent-hashing-redis,代码行数:24,代码来源:HwRedisConnectionFactory.java

示例3: createRedisConnection

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
protected void createRedisConnection(String name, String host, int port, String password) {
	JedisConnectionFactory connectionFactory = new JedisConnectionFactory();
	connectionFactory.setHostName(host);
	connectionFactory.setPort(port);
	if(!StringUtils.isEmpty(password))
		connectionFactory.setPassword(password);
	connectionFactory.afterPropertiesSet();
	RedisTemplate redisTemplate = new MyStringRedisTemplate();
	redisTemplate.setConnectionFactory(connectionFactory);
	redisTemplate.afterPropertiesSet();
	RedisApplication.redisTemplatesMap.put(name, redisTemplate);
	
	Map<String, Object> redisServerMap = new HashMap<String, Object>();
	redisServerMap.put("name", name);
	redisServerMap.put("host", host);
	redisServerMap.put("port", port);
	redisServerMap.put("password", password);
	RedisApplication.redisServerCache.add(redisServerMap);
	
	initRedisKeysCache(redisTemplate, name);
	
	RedisZtreeUtil.initRedisNavigateZtree(name);
}
 
开发者ID:mauersu,项目名称:redis-admin,代码行数:24,代码来源:RedisApplication.java

示例4: createJedisConnectionFactory

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
/**
 * 建立
 * 
 * i=0, port(6379)
 * 
 * i=1, port(6379)+i=6380
 * 
 * @param i
 * @param jedisPoolConfig
 * @return
 */
protected JedisConnectionFactory createJedisConnectionFactory(int i, JedisPoolConfig jedisPoolConfig)
		throws Exception {
	JedisConnectionFactory result = new JedisConnectionFactory();
	String hostName = extendedProperties.getString(HOSTNAME, DEFAULT_HOSTNAME);
	//
	int port = extendedProperties.getInt(PORT, DEFAULT_PORT);
	port += i;
	LOGGER.info("redis[" + i + "]: " + hostName + ":" + port);
	//
	result.setHostName(hostName);
	result.setPort(port);
	//
	result.setPassword(extendedProperties.getString(PASSWORD, DEFAULT_PASSWORD));
	//
	result.setPoolConfig(jedisPoolConfig);
	result.afterPropertiesSet();
	//
	return result;
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:31,代码来源:JedisConnectionFactoryFactorySupporter.java

示例5: redisConnectionFactory

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
@Bean
public JedisConnectionFactory redisConnectionFactory() {
    JedisPoolConfig poolConfig = new JedisPoolConfig();
    poolConfig.setMaxTotal(5);
    poolConfig.setTestOnBorrow(true);
    poolConfig.setTestOnReturn(true);
    JedisConnectionFactory ob = new JedisConnectionFactory(poolConfig);
    ob.setUsePool(true);
    String redishost = cacheProperties.getRedisHost(); //System.getenv("REDISCACHE_HOSTNAME");
    LOG.info("REDISCACHE_HOSTNAME={}", redishost);
    ob.setHostName(redishost);
    String redisport = cacheProperties.getRedisPort().toString(); //System.getenv("REDISCACHE_PORT");
    LOG.info("REDISCACHE_PORT= {}", redisport);
    try {
        ob.setPort(Integer.parseInt(  redisport));
    } catch (NumberFormatException e1) {
        // if the port is not in the ENV, use the default
        ob.setPort(6379);
    }
    String rediskey = cacheProperties.getPrimaryKey(); //System.getenv("REDISCACHE_PRIMARY_KEY");
    LOG.info("REDISCACHE_PRIMARY_KEY= {}", rediskey);
    ob.setPassword(rediskey);
    ob.afterPropertiesSet();
    RedisTemplate<Object,Object> tmp = new RedisTemplate<>();
    tmp.setConnectionFactory(ob);

    //make sure redis connection is working
    try {
        String msg = tmp.getConnectionFactory().getConnection().ping();
        LOG.info("redis ping response="+msg);
        //clear the cache before use
        tmp.getConnectionFactory().getConnection().flushAll();
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return ob;
}
 
开发者ID:Azure,项目名称:CityPower-Build-Sample,代码行数:39,代码来源:CacheConfig.java

示例6: redisConnectionFactory

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
@Bean
public RedisConnectionFactory redisConnectionFactory() {
    JedisConnectionFactory cf = new JedisConnectionFactory();
    cf.setHostName(getHost());
    cf.setPort(getPort());
    cf.afterPropertiesSet();
    return cf;
}
 
开发者ID:KonkerLabs,项目名称:konker-platform,代码行数:9,代码来源:RedisConfig.java

示例7: createDefaultConnectionFactory

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
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;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:15,代码来源:RedisConfiguration.java

示例8: createConnectionFactory

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
@Override
protected RedisConnectionFactory createConnectionFactory( RedisShardSpec shardSpec ) {
    JedisConnectionFactory factory = new JedisConnectionFactory();
    factory.setHostName(shardSpec.getHost());
    factory.setPort(shardSpec.getPort());
    factory.setDatabase(shardSpec.getDb());
    factory.afterPropertiesSet();
    return factory;
}
 
开发者ID:Dennyss,项目名称:sharded-spring-data-redis,代码行数:10,代码来源:JedisShardedConnectionFactoryProvider.java

示例9: setUp

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
@Before
public void setUp() {
	JedisConnectionFactory redisConnectionFactory = new JedisConnectionFactory();
	redisConnectionFactory.afterPropertiesSet();

	redisTemplate = new RedisTemplate<>();
	redisTemplate.setConnectionFactory(redisConnectionFactory);
	redisTemplate.setDefaultSerializer(new StringRedisSerializer());
	redisTemplate.afterPropertiesSet();
	productCategoryEnricher = new ProductCategoryEnricher(redisTemplate);

}
 
开发者ID:spring-projects,项目名称:spring-xd-samples,代码行数:13,代码来源:ProductCategoryEnricherTest.java

示例10: setUp

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
@Before
public void setUp() {
	JedisConnectionFactory redisConnectionFactory = new JedisConnectionFactory();
	redisConnectionFactory.afterPropertiesSet();

	redisTemplate = new RedisTemplate<>();
	redisTemplate.setConnectionFactory(redisConnectionFactory);
	redisTemplate.setDefaultSerializer(new StringRedisSerializer());
	redisTemplate.afterPropertiesSet();
	productCategoriesCounter = new ProductCategoriesCounter(redisTemplate);
}
 
开发者ID:spring-projects,项目名称:spring-xd-samples,代码行数:12,代码来源:ProductCategoriesCounterTest.java

示例11: setUp

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
@Before
public void setUp() {
	JedisConnectionFactory redisConnectionFactory = new JedisConnectionFactory();
	redisConnectionFactory.afterPropertiesSet();
	redisTemplate = new RedisTemplate<>();
	redisTemplate.setConnectionFactory(redisConnectionFactory);
	redisTemplate.setDefaultSerializer(new StringRedisSerializer());
	redisTemplate.afterPropertiesSet();
	userHistoryProcessor = new UserHistoryProcessor(redisTemplate);
}
 
开发者ID:spring-projects,项目名称:spring-xd-samples,代码行数:11,代码来源:UserHistoryProcessorTest.java

示例12: obtainResource

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
@Override
protected void obtainResource() throws Exception {
	resource = new JedisConnectionFactory();
	resource.afterPropertiesSet();
	resource.getConnection().close();
}
 
开发者ID:spring-projects,项目名称:spring-analytics,代码行数:7,代码来源:RedisTestSupport.java

示例13: createConnectionFactory

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
private JedisConnectionFactory createConnectionFactory() {
	JedisConnectionFactory connectionFactory = new JedisConnectionFactory();
	connectionFactory.afterPropertiesSet();
	testConnection(connectionFactory);
	return connectionFactory;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:7,代码来源:RedisTestServer.java

示例14: testRedisRoute

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
@Test
@SuppressWarnings("rawtypes")
public void testRedisRoute() throws Exception {

    Assume.assumeFalse("[#1701] Cannot start Redis server on Windows", EnvironmentUtils.isWindows());

    JedisConnectionFactory connectionFactory = new JedisConnectionFactory();
    connectionFactory.afterPropertiesSet();

    RedisTemplate redisTemplate = new RedisTemplate();
    redisTemplate.setConnectionFactory(connectionFactory);
    redisTemplate.afterPropertiesSet();

    CamelContextFactory contextFactory = ServiceLocator.getRequiredService(CamelContextFactory.class);
    WildFlyCamelContext camelctx = contextFactory.createCamelContext(getClass().getClassLoader());
    Context jndictx = camelctx.getNamingContext();
    jndictx.bind("redisTemplate", redisTemplate);

    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            int port = Integer.parseInt(AvailablePortFinder.readServerData("redis-port"));
            from("direct:start")
            .to("spring-redis://localhost:" + port + "?redisTemplate=#redisTemplate");
        }
    });

    camelctx.start();
    try {
        Object[] headers = new Object[] {
                RedisConstants.COMMAND, "SET",
                RedisConstants.KEY, "key1",
                RedisConstants.VALUE, "value"
                };

        ProducerTemplate producer = camelctx.createProducerTemplate();
        producer.send("direct:start", new Processor() {
            public void process(Exchange exchange) throws Exception {
                Message in = exchange.getIn();
                for (int i = 0; i < headers.length; i = i + 2) {
                    in.setHeader(headers[i].toString(), headers[i + 1]);
                }
            }
        });
        Assert.assertEquals("value", redisTemplate.opsForValue().get("key1"));
    } finally {
        camelctx.stop();
    }
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:50,代码来源:SpringRedisIntegrationTest.java

示例15: RedisKeyValueAdapter

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
public RedisKeyValueAdapter(IndexConfiguration indexConfiguration) {

		super(new RedisQueryEngine());

		converter = new MappingRedisConverter(indexConfiguration, new ReferenceResolverImpl(this));

		JedisConnectionFactory conFactory = new JedisConnectionFactory();
		conFactory.afterPropertiesSet();

		RedisTemplate<byte[], byte[]> template = new RedisTemplate<byte[], byte[]>();
		template.setConnectionFactory(conFactory);
		template.afterPropertiesSet();

		this.redisOps = template;
	}
 
开发者ID:christophstrobl,项目名称:spring-data-keyvalue-redis,代码行数:16,代码来源:RedisKeyValueAdapter.java


注:本文中的org.springframework.data.redis.connection.jedis.JedisConnectionFactory.afterPropertiesSet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。