Java Code Examples for org.springframework.data.redis.core.RedisTemplate#setBeanClassLoader()
The following examples show how to use
org.springframework.data.redis.core.RedisTemplate#setBeanClassLoader() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CacheManagerBuilder.java From jsets-shiro-spring-boot-starter with Apache License 2.0 | 6 votes |
private CacheManager decision(org.springframework.cache.CacheManager springCacheManager) { if (springCacheManager instanceof EhCacheCacheManager) { EhCacheManager ehCacheManager = new EhCacheManager(); ehCacheManager.setCacheManager(((EhCacheCacheManager) springCacheManager).getCacheManager()); return ehCacheManager; } if (springCacheManager instanceof org.springframework.data.redis.cache.RedisCacheManager) { GenericJackson2JsonRedisSerializer jsonSerializer = new GenericJackson2JsonRedisSerializer(); RedisTemplate rt = new RedisTemplate<Object, Object>(); rt.setConnectionFactory(SpringContextUtils.getBean(RedisConnectionFactory.class)); rt.setKeySerializer(jsonSerializer); rt.setHashKeySerializer(jsonSerializer); rt.setBeanClassLoader(this.getClass().getClassLoader()); rt.afterPropertiesSet(); RedisCacheManager redisCacheManager = new RedisCacheManager(); redisCacheManager.setRedisTemplate(rt); return redisCacheManager; } return new SpringCacheManager(springCacheManager); }
Example 2
Source File: RedisUtils.java From jsets-shiro-spring-boot-starter with Apache License 2.0 | 5 votes |
public static RedisTemplate<Object,Object> imitateRedisTemplate(){ RedisConnectionFactory connFactory = SpringContextUtils.getBean(RedisConnectionFactory.class); if(Objects.nonNull(connFactory)) { RedisTemplate<Object, Object> nRedisTemplate = new RedisTemplate<Object, Object>(); nRedisTemplate.setConnectionFactory(connFactory); nRedisTemplate.setKeySerializer(jsonSerializer); nRedisTemplate.setHashKeySerializer(jsonSerializer); nRedisTemplate.setBeanClassLoader(RedisUtils.class.getClassLoader()); nRedisTemplate.afterPropertiesSet(); return nRedisTemplate; } return null; }
Example 3
Source File: RedisHttpSessionConfiguration.java From spring-session with Apache License 2.0 | 5 votes |
private RedisTemplate<Object, Object> createRedisTemplate() { RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>(); redisTemplate.setKeySerializer(new StringRedisSerializer()); redisTemplate.setHashKeySerializer(new StringRedisSerializer()); if (this.defaultRedisSerializer != null) { redisTemplate.setDefaultSerializer(this.defaultRedisSerializer); } redisTemplate.setConnectionFactory(this.redisConnectionFactory); redisTemplate.setBeanClassLoader(this.classLoader); redisTemplate.afterPropertiesSet(); return redisTemplate; }