@Override public synchronized Object clone() { return new RedisProperties(defaults, hashOps); }
@SuppressWarnings("unchecked") private RedisStore createStore(DataType dt) { switch (dt) { case LIST: return new DefaultRedisList(key, template); case SET: return new DefaultRedisSet(key, template); case ZSET: return new DefaultRedisZSet(key, template); case HASH: if (CollectionType.PROPERTIES.equals(type)) { return new RedisProperties(key, template); } return new DefaultRedisMap(key, template); } return null; }
/** * Initializes the {@link RedisProperties} by provided {@link RedisConnectionFactory} and key. * * @param operations The Redis operations object. * @param key The key. */ public RedisMetadataStore(RedisOperations<String, ?> operations, String key) { Assert.notNull(operations, "'operations' must not be null."); Assert.hasText(key, "'key' must not be empty."); BoundHashOperations<String, String, String> hashOperations = operations.boundHashOps(key); this.properties = new RedisProperties(hashOperations); }
/** * Initializes the {@link RedisProperties} by provided {@link RedisConnectionFactory} and key. * * @param connectionFactory The connection factory. * @param key The key. */ public RedisMetadataStore(RedisConnectionFactory connectionFactory, String key) { Assert.notNull(connectionFactory, "'connectionFactory' must not be null."); Assert.hasText(key, "'key' must not be empty."); RedisOperations<String, String> redisTemplate = new StringRedisTemplate(connectionFactory); BoundHashOperations<String, String, String> hashOperations = redisTemplate.boundHashOps(key); this.properties = new RedisProperties(hashOperations); }
@Override public synchronized Object clone() { return new RedisProperties(defaults, hashOps); }
@Override public synchronized Object clone() { return new RedisProperties(defaults, hashOps); }
@Test @RedisAvailable public void testProperties() { RedisProperties redisProperties = new RedisProperties("pepboys", this.redisTemplate); assertEquals(0, redisProperties.size()); Properties pepboys = new Properties(); pepboys.put("1", "Manny"); pepboys.put("2", "Moe"); pepboys.put("3", "Jack"); Message<Properties> message = MessageBuilder.withPayload(pepboys).build(); this.propertyChannel.send(message); assertEquals("Manny", redisProperties.get("1")); assertEquals("Moe", redisProperties.get("2")); assertEquals("Jack", redisProperties.get("3")); }
@Test @RedisAvailable public void testPropertiesSimple() { RedisProperties redisProperties = new RedisProperties("foo", this.redisTemplate); assertEquals(0, redisProperties.size()); Message<String> message = MessageBuilder.withPayload("bar") .setHeader(RedisHeaders.KEY, "foo") .setHeader("baz", "qux") .build(); this.simplePropertyChannel.send(message); assertEquals("bar", redisProperties.get("qux")); }
/** * Initializes the {@link RedisProperties} by provided {@link RedisConnectionFactory} and key. * * @param operations The Redis operations object. * @param key The key. */ public RedisMetadataStore(RedisOperations<String, ?> operations, String key) { Assert.notNull(operations, "'operations' must not be null."); Assert.hasText(key, "'key' must not be empty."); BoundHashOperations<String, String, String> hashOperations = operations.boundHashOps(key); this.properties = new RedisProperties(hashOperations); }
/** * Initializes the {@link RedisProperties} by provided {@link RedisConnectionFactory} and key. * * @param connectionFactory The connection factory. * @param key The key. */ public RedisMetadataStore(RedisConnectionFactory connectionFactory, String key) { Assert.notNull(connectionFactory, "'connectionFactory' must not be null."); Assert.hasText(key, "'key' must not be empty."); RedisOperations<String, String> redisTemplate = new StringRedisTemplate(connectionFactory); BoundHashOperations<String, String, String> hashOperations = redisTemplate.boundHashOps(key); this.properties = new RedisProperties(hashOperations); }
@SuppressWarnings("unchecked") private RedisStore createStore(DataType dt) { switch (dt) { case LIST: return new DefaultRedisList(key, template); case SET: return new DefaultRedisSet(key, template); case ZSET: return new DefaultRedisZSet(key, template); case HASH: if (CollectionType.PROPERTIES.equals(type)) { return new RedisProperties(key, template); } return new DefaultRedisMap(key, template); } return null; }
@SuppressWarnings("unchecked") private RedisStore createStore(DataType dt) { switch (dt) { case LIST: return new DefaultRedisList(key, template); case SET: return new DefaultRedisSet(key, template); case ZSET: return new DefaultRedisZSet(key, template); case HASH: if (CollectionType.PROPERTIES.equals(type)) { return new RedisProperties(key, template); } return new DefaultRedisMap(key, template); } return null; }