Why a “RedisTemplate” can convert to a “ListOperations”

后端 未结 2 1500
耶瑟儿~
耶瑟儿~ 2021-01-29 02:53

I\'m reading the spring-data-redis reference guide. In the 5.5 capther,we create the redisTemplate bean in spring config xml File.



        
2条回答
  •  情深已故
    2021-01-29 03:16

    Spring IOC container do the magic for you:

    class ListOperationsEditor extends PropertyEditorSupport {
        ListOperationsEditor() {
        }
    
        public void setValue(Object value) {
            if(value instanceof RedisOperations) {
                super.setValue(((RedisOperations)value).opsForList());
            } else {
                throw new IllegalArgumentException("Editor supports only conversion of type " + RedisOperations.class);
            }
        }
    }
    

提交回复
热议问题