本文整理汇总了Java中org.springframework.data.redis.serializer.SerializationException类的典型用法代码示例。如果您正苦于以下问题:Java SerializationException类的具体用法?Java SerializationException怎么用?Java SerializationException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SerializationException类属于org.springframework.data.redis.serializer包,在下文中一共展示了SerializationException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: redisTemplate
import org.springframework.data.redis.serializer.SerializationException; //导入依赖的package包/类
@Bean
@Primary
RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory rcf) {
AitLogger.debug(logger, "Serializer overriding ");
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(rcf);
GenericJackson2JsonRedisSerializer valSerializer = new GenericJackson2JsonRedisSerializer();
template.setValueSerializer(valSerializer);
template.setKeySerializer(new RedisSerializer<Object>() {
@Override
public byte[] serialize(Object t) throws SerializationException {
return (t == null ? null : (":" + t.toString()).getBytes());
}
@Override
public Object deserialize(byte[] bytes) throws SerializationException {
return (bytes == null ? null : new String(bytes));
}
});
template.setHashValueSerializer(valSerializer);
return template;
}
开发者ID:allianzit,项目名称:ait-platform,代码行数:27,代码来源:AitCacheConfigBase.java
示例2: deserialize
import org.springframework.data.redis.serializer.SerializationException; //导入依赖的package包/类
@Override
public Execution deserialize(byte[] bytes) throws SerializationException {
try {
return super.deserialize(bytes);
} catch (SerializationException e) {
if (ignoreDeserializationFailures) {
if (deserializationFailuresCache.add(e.getMessage())) {
log.warn("Ignoring invalid JSON: {}.", e.getMessage());
}
if (deserializationFailuresCache.size() > 1000) {
deserializationFailuresCache.clear();
}
return null;
}
throw e;
}
}
开发者ID:shopping24,项目名称:redjob,代码行数:19,代码来源:ExecutionRedisSerializer.java
示例3: serialize
import org.springframework.data.redis.serializer.SerializationException; //导入依赖的package包/类
@Override
public byte[] serialize(Object obj) throws SerializationException {
final Kryo kryo = KryoHolder.borrow();
Output output = null;
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
output = new Output(baos);
kryo.writeClassAndObject(output, obj);
return output.toBytes();
} finally {
if (output != null) {
output.close();
}
KryoHolder.release(kryo);
}
}
开发者ID:walle-liao,项目名称:jaf-examples,代码行数:17,代码来源:KryoSerializer.java
示例4: deserialize
import org.springframework.data.redis.serializer.SerializationException; //导入依赖的package包/类
@Override
public Object deserialize(byte[] bytes) throws SerializationException {
if (bytes == null || bytes.length == 0)
return null;
final Kryo kryo = KryoHolder.borrow();
Input input = null;
try {
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
input = new Input(bais);
return kryo.readClassAndObject(input);
} finally {
if (input != null) {
input.close();
}
KryoHolder.release(kryo);
}
}
开发者ID:walle-liao,项目名称:jaf-examples,代码行数:19,代码来源:KryoSerializer.java
示例5: serialize
import org.springframework.data.redis.serializer.SerializationException; //导入依赖的package包/类
public String serialize(Object payload) {
Class<?> payloadType = payload.getClass();
try {
JAXBContext context = JAXBContext.newInstance(payloadType);
Marshaller marshaller = context.createMarshaller();
ByteArrayOutputStream payloadAsXml = new ByteArrayOutputStream(INITIAL_BUFFER_SIZE);
marshaller.marshal(payload, payloadAsXml);
return new String(payloadAsXml.toByteArray());
} catch (JAXBException e) {
throw new SerializationException("JAXB error while serializing object.", e);
}
}
开发者ID:davidmarquis,项目名称:redisq,代码行数:17,代码来源:JaxbPayloadSerializer.java
示例6: deserialize
import org.springframework.data.redis.serializer.SerializationException; //导入依赖的package包/类
public <T> T deserialize(String payload, Class<T> payloadType) {
try {
JAXBContext context = JAXBContext.newInstance(payloadType);
Unmarshaller unmarshaller = context.createUnmarshaller();
if (log.isDebugEnabled()) {
// input stream can only be read once.
log.debug("Message payload content as JAXB XML:");
log.debug("++++++++++++++++++++++++++++++++++");
log.debug(payload);
log.debug("----------------------------------");
}
ByteArrayInputStream payloadStream = new ByteArrayInputStream(payload.getBytes());
JAXBElement<T> element = unmarshaller.unmarshal(new StreamSource(payloadStream), payloadType);
return (element == null) ? null : element.getValue();
} catch (JAXBException e) {
throw new SerializationException("Could not deserialize payload.", e);
}
}
开发者ID:davidmarquis,项目名称:redisq,代码行数:23,代码来源:JaxbPayloadSerializer.java
示例7: serialize
import org.springframework.data.redis.serializer.SerializationException; //导入依赖的package包/类
@Override
public byte[] serialize(T graph) throws SerializationException {
if (GzipRedisSerializer.log.isTraceEnabled())
GzipRedisSerializer.log.trace("객체를 직렬화 후에 압축을 수행합니다...");
if (graph == null)
return new byte[0];
try {
byte[] bytes = innerSerializer.serialize(graph);
@Cleanup ByteArrayOutputStream bos = new ByteArrayOutputStream();
@Cleanup GZIPOutputStream gzip = new GZIPOutputStream(bos);
gzip.write(bytes);
gzip.close();
byte[] result = bos.toByteArray();
if (GzipRedisSerializer.log.isTraceEnabled())
GzipRedisSerializer.log.trace("객체를 직렬화 후에 압축했습니다. 기존=[{}], 압축후=[{}]", bytes.length, result.length);
return result;
} catch (Exception e) {
throw new SerializationException("Gzip 압축 실패", e);
}
}
开发者ID:debop,项目名称:debop4j,代码行数:27,代码来源:GzipRedisSerializer.java
示例8: serialize
import org.springframework.data.redis.serializer.SerializationException; //导入依赖的package包/类
@Override
public byte[] serialize(T t) throws SerializationException {
if (t == null) {
return new byte[0];
}
try {
return JSON.toJSONBytes(t, fastJsonConfig.getSerializeConfig(), fastJsonConfig.getSerializerFeatures());
} catch (Exception ex) {
throw new SerializationException("Could not serialize: " + ex.getMessage(), ex);
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:FastJsonRedisSerializer.java
示例9: deserialize
import org.springframework.data.redis.serializer.SerializationException; //导入依赖的package包/类
@Override
public T deserialize(byte[] bytes) throws SerializationException {
if (bytes == null || bytes.length == 0) {
return null;
}
try {
return (T) JSON.parseObject(bytes, type, fastJsonConfig.getFeatures());
} catch (Exception ex) {
throw new SerializationException("Could not deserialize: " + ex.getMessage(), ex);
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:FastJsonRedisSerializer.java
示例10: serialize
import org.springframework.data.redis.serializer.SerializationException; //导入依赖的package包/类
@Override
public byte[] serialize(Object object) throws SerializationException {
if (object == null) {
return new byte[0];
}
try {
return JSON.toJSONBytes(object, SerializerFeature.WriteClassName);
} catch (Exception ex) {
throw new SerializationException("Could not serialize: " + ex.getMessage(), ex);
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:GenericFastJsonRedisSerializer.java
示例11: deserialize
import org.springframework.data.redis.serializer.SerializationException; //导入依赖的package包/类
@Override
public Object deserialize(byte[] bytes) throws SerializationException {
if (bytes == null || bytes.length == 0) {
return null;
}
try {
return JSON.parseObject(new String(bytes, IOUtils.UTF8), Object.class, defaultRedisConfig);
} catch (Exception ex) {
throw new SerializationException("Could not deserialize: " + ex.getMessage(), ex);
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:GenericFastJsonRedisSerializer.java
示例12: test_5
import org.springframework.data.redis.serializer.SerializationException; //导入依赖的package包/类
@Test(expected = SerializationException.class)
public void test_5() {
User user = new User(1, "土豆", 25);
byte[] serializedValue = serializer.serialize(user);
Arrays.sort(serializedValue); // corrupt serialization result
serializer.deserialize(serializedValue);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:GenericFastJsonRedisSerializerTest.java
示例13: deserialize
import org.springframework.data.redis.serializer.SerializationException; //导入依赖的package包/类
/**
* 反序列化
*
* @param bytes
* @return
* @throws SerializationException
*/
public T deserialize(byte[] bytes) throws SerializationException {
if (bytes == null || bytes.length <= 0) {
return null;
}
String str = new String(bytes, charset);
if (clazz == null) {
return (T) JSON.parse(str);
}
return (T) JSON.parseObject(str, clazz);
}
开发者ID:Lengchuan,项目名称:SpringBoot-Study,代码行数:18,代码来源:FastJsonRedisSerializer.java
示例14: deserialize
import org.springframework.data.redis.serializer.SerializationException; //导入依赖的package包/类
/**
* 反序列化
*/
@Override
public Object deserialize(byte[] bytes) {
if (isEmpty(bytes)) {
return null;
}
try {
return deserializer.convert(bytes);
} catch (Exception ex) {
throw new SerializationException("Cannot deserialize", ex);
}
}
开发者ID:timebusker,项目名称:spring-boot-redis,代码行数:15,代码来源:ObjectRedisSerializer.java
示例15: deserialize
import org.springframework.data.redis.serializer.SerializationException; //导入依赖的package包/类
public Object deserialize(byte[] bytes) {
if (isEmpty(bytes)) {
return null;
}
try {
return deserializer.convert(bytes);
} catch (Exception ex) {
throw new SerializationException("Cannot deserialize", ex);
}
}
开发者ID:nellochen,项目名称:springboot-start,代码行数:11,代码来源:RedisObjectSerializer.java
示例16: deserialize
import org.springframework.data.redis.serializer.SerializationException; //导入依赖的package包/类
public Object deserialize(byte[] bytes) {
if (isEmpty(bytes)) {
return null;
}
try {
return deserializer.convert(bytes);
} catch (Exception ex) {
throw new SerializationException("Cannot deserialize", ex);
}
}
开发者ID:guolf,项目名称:pds,代码行数:12,代码来源:RedisObjectSerializer.java
示例17: getSession
import org.springframework.data.redis.serializer.SerializationException; //导入依赖的package包/类
public S getSession(String id) {
try {
return repository.getSession(id);
} catch (SerializationException e) {
LOG.info("deleting non-deserializable session with key {}", id);
// NOTE: deleting directly via redis instead of template since the repository.delete method would
// run into the same serializationissue again
sessionRedisTemplate.delete(BOUNDED_HASH_KEY_PREFIX + id);
counterService.increment("meter.cat.boot.session.deleteAfterDeserializationError");
return null;
}
}
开发者ID:Catalysts,项目名称:cat-boot,代码行数:13,代码来源:InvalidClassExceptionSafeRepository.java
示例18: serialize
import org.springframework.data.redis.serializer.SerializationException; //导入依赖的package包/类
@Override
public byte[] serialize(Object t) throws SerializationException {
log.debug("Kyro serialize:"+t.getClass().getName()+", value:"+t);
byte[] buffer = new byte[2048];
Output output = new Output(buffer);
kryo.writeClassAndObject(output, t);
return output.toBytes();
}
开发者ID:simbest,项目名称:simbest-cores,代码行数:9,代码来源:KyroRedisSerializer.java
示例19: deserialize
import org.springframework.data.redis.serializer.SerializationException; //导入依赖的package包/类
@Override
public T deserialize(byte[] bytes) throws SerializationException {
log.debug("Kyro deserialize:"+bytes);
Input input = new Input(bytes);
@SuppressWarnings("unchecked")
T t = (T) kryo.readClassAndObject(input);
return t;
}
开发者ID:simbest,项目名称:simbest-cores,代码行数:9,代码来源:KyroRedisSerializer.java
示例20: serialize
import org.springframework.data.redis.serializer.SerializationException; //导入依赖的package包/类
@Override
public byte[] serialize(Object t) throws SerializationException {
try {
return om.writeValueAsBytes(t);
} catch (JsonProcessingException e) {
throw new SerializationException(e.getMessage(), e);
}
}
开发者ID:Turbots,项目名称:SpringOne2016,代码行数:9,代码来源:JsonRedisSerializer.java
注:本文中的org.springframework.data.redis.serializer.SerializationException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论