List of usage examples for org.springframework.data.redis.serializer SerializationException SerializationException
public SerializationException(String msg, Throwable cause)
From source file:grails.plugin.cache.web.filter.redis.GrailsRedisSerializer.java
public Object deserialize(byte[] bytes) { if (bytes == null || bytes.length == 0) { return null; }/*from www .j a v a 2 s. co m*/ try { return deserializer.convert(bytes); } catch (Exception e) { throw new SerializationException("Cannot deserialize", e); } }
From source file:grails.plugin.cache.web.filter.redis.GrailsRedisSerializer.java
public byte[] serialize(Object object) { if (object == null) { return EMPTY_ARRAY; }/*from w ww . j a v a2s. c o m*/ try { return serializer.convert(object); } catch (Exception e) { throw new SerializationException("Cannot serialize", e); } }
From source file:org.solq.dht.db.redis.service.ser.Jackson3JsonRedisSerializer.java
public static String object2Json(Object o) { if (o == null) { return null; }/*from w w w. j av a2 s . com*/ try { return objectMapper.writeValueAsString(o); } catch (Exception ex) { throw new SerializationException("Could not write JSON: " + ex.getMessage(), ex); } }
From source file:org.trustedanalytics.user.secure.serializer.SecureJacksonJsonRedisSerializer.java
@Override public T deserialize(byte[] bytes) throws SerializationException { if (bytes == null || bytes.length == 0) { return null; }//from w w w . j a v a 2 s .c o m try { SecureJson sj = this.objectMapper.readValue(bytes, 0, bytes.length, SecureJson.class); byte[] plainJson = encryptionService.decrypt(sj); return super.deserialize(plainJson); } catch (IOException e) { throw new SerializationException("Could not read Secure-JSON", e); } catch (EncryptionException e) { throw new SerializationException("Could not decrypt Secure-JSON", e); } }
From source file:am.ik.categolj3.api.entry.redis.EntryRedisTemplateFactory.java
public RedisTemplate<Object, Object> create() { RedisTemplate<Object, Object> template = new RedisTemplate<>(); template.setConnectionFactory(redisConnectionFactory); template.setKeySerializer(new JdkSerializationRedisSerializer()); template.setValueSerializer(new RedisSerializer<Entry>() { @Override/* w w w .jav a 2 s.co m*/ public byte[] serialize(Entry entry) throws SerializationException { if (entry == null) { return new byte[0]; } try { return objectMapper.writeValueAsBytes(entry); } catch (JsonProcessingException e) { throw new SerializationException("Cannot serialize " + entry, e); } } @Override public Entry deserialize(byte[] bytes) throws SerializationException { if (bytes == null || bytes.length == 0) { return null; } try { return objectMapper.readValue(bytes, Entry.class); } catch (IOException e) { throw new SerializationException("Cannot deserialize " + Arrays.toString(bytes), e); } } }); return template; }
From source file:org.solq.dht.db.redis.service.ser.Jackson3JsonRedisSerializer.java
@SuppressWarnings("unchecked") public T deserialize(byte[] bytes) throws SerializationException { if (isEmpty(bytes)) { return null; }//from w w w. j ava2 s.c o m try { return (T) objectMapper.readValue(bytes, 0, bytes.length, javaType); } catch (Exception ex) { throw new SerializationException("Could not read JSON: " + ex.getMessage(), ex); } }
From source file:org.solq.dht.db.redis.service.ser.Jackson3JsonRedisSerializer.java
public static <T> T json2Object(String json, Class<T> type) { if (json == null) { return null; }/*from w w w.j av a 2 s .c om*/ try { return (T) objectMapper.readValue(json, type); } catch (Exception ex) { throw new SerializationException("Could not read JSON: " + ex.getMessage(), ex); } }
From source file:org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer.java
@SuppressWarnings("unchecked") public T deserialize(byte[] bytes) throws SerializationException { if (SerializationUtils.isEmpty(bytes)) { return null; }//from w w w.ja v a 2 s. c o m try { return (T) this.objectMapper.readValue(bytes, 0, bytes.length, javaType); } catch (Exception ex) { throw new SerializationException("Could not read JSON: " + ex.getMessage(), ex); } }
From source file:org.trustedanalytics.user.secure.serializer.SecureJacksonJsonRedisSerializer.java
@Override public byte[] serialize(Object t) throws SerializationException { if (t == null) { return new byte[0]; }//from ww w .ja v a2s. c om try { byte[] plainJson = super.serialize(t); SecureJson sj = encryptionService.encrypt(plainJson); return this.objectMapper.writeValueAsBytes(sj); } catch (IOException e) { throw new SerializationException("Could not write Secure-JSON", e); } catch (EncryptionException e) { throw new SerializationException("Could not encrypt Secure-JSON", e); } }
From source file:org.solq.dht.db.redis.service.ser.Jackson3JsonRedisSerializer.java
public byte[] serialize(Object t) throws SerializationException { if (t == null) { return EMPTY_ARRAY; }// w w w. ja va 2 s . c om try { return objectMapper.writeValueAsBytes(t); } catch (Exception ex) { throw new SerializationException("Could not write JSON: " + ex.getMessage(), ex); } }