use of com.jn.agileway.codec.serialization.json.EasyjsonCodec in project agileway by fangjinuo.
the class RedisTemplates method createEasyjsonCommonJsonRedisTemplate.
public static RedisTemplate<String, ?> createEasyjsonCommonJsonRedisTemplate(@NonNull RedisConnectionFactory connectionFactory, @Nullable String keyPrefix, @NonNull JSONFactory jsonFactory, @Nullable ClassLoader beanClassLoader, @Nullable RedisSerializer<?> hashKeySerializer, @Nullable RedisSerializer<?> hashValueSerializer, @Nullable RedisLuaScriptRepository redisLuaScriptRepository, boolean enableTx, boolean initIt) {
EasyjsonCodec easyjsonRedisSerializer = new EasyjsonCodec();
easyjsonRedisSerializer.setJsonFactory(jsonFactory);
return createRedisTemplate(connectionFactory, keyPrefix, new DelegatableRedisSerializer(easyjsonRedisSerializer), beanClassLoader, null, hashKeySerializer, hashValueSerializer, redisLuaScriptRepository, enableTx, initIt);
}
use of com.jn.agileway.codec.serialization.json.EasyjsonCodec in project agileway by fangjinuo.
the class RedisTemplates method createBeanJsonRedisTemplate.
public static RedisTemplate<String, ?> createBeanJsonRedisTemplate(@NonNull RedisConnectionFactory connectionFactory, @Nullable String keyPrefix, @NonNull Class beanClass, @Nullable RedisSerializer hashKeySerializer, @Nullable RedisSerializer hashValueSerializer, @Nullable RedisLuaScriptRepository redisLuaScriptRepository, boolean enableTx, boolean initIt) {
Preconditions.checkNotNull(beanClass, "the target class is null");
EasyjsonCodec easyjsonRedisSerializer = new EasyjsonCodec();
easyjsonRedisSerializer.setJsonFactory(JsonFactorys.getJSONFactory(JsonScope.SINGLETON));
easyjsonRedisSerializer.setTargetType(beanClass);
return createRedisTemplate(connectionFactory, keyPrefix, new DelegatableRedisSerializer(easyjsonRedisSerializer), beanClass.getClassLoader(), null, hashKeySerializer, hashValueSerializer, redisLuaScriptRepository, enableTx, initIt);
}
use of com.jn.agileway.codec.serialization.json.EasyjsonCodec in project agileway by fangjinuo.
the class RedisTemplates method newCodec.
public static Codec newCodec(BuiltinCodecType codecType) {
codecType = codecType == null ? BuiltinCodecType.EASYJSON : codecType;
Codec codec = null;
switch(codecType) {
case JSCKSON:
codec = new JacksonCodec();
break;
case JDK:
codec = new JdkCodec();
break;
case KRYO:
codec = new KryoCodec();
break;
case HESSIAN:
codec = new HessianCodec();
break;
case PROTOSTUFF:
codec = new ProtostuffCodec();
break;
case FSE:
codec = new FseCodec();
break;
case FST:
codec = new FstCodec();
break;
case CBOR:
codec = new CborJacksonCodec();
break;
case MSGPACK:
codec = new MsgPackCodec();
break;
case XSON:
codec = new XsonCodec();
break;
case BSON:
codec = new BsonCodec();
break;
case EASYJSON:
default:
codec = new EasyjsonCodec();
break;
}
return codec;
}
use of com.jn.agileway.codec.serialization.json.EasyjsonCodec in project agileway by fangjinuo.
the class StringValueController method createRedisTemplate.
private RedisTemplate createRedisTemplate(TestScope scope) {
RedisTemplate<String, ?> RedisTemplate = null;
switch(scope) {
case JACKSON_COMMON:
RedisTemplate = RedisTemplates.createRedisTemplate(connectionFactory, keyPrefix, new GenericJackson2JsonRedisSerializer(), StringValueController.class.getClassLoader(), RedisTemplates.stringRedisSerializer, null, null, repository, false, true);
break;
case EASYJSON_COMMON:
EasyjsonCodec jsonSerializer = new EasyjsonCodec();
DelegatableRedisSerializer valueSerializer = new DelegatableRedisSerializer(jsonSerializer);
RedisTemplate = RedisTemplates.createRedisTemplate(connectionFactory, keyPrefix, valueSerializer, StringValueController.class.getClassLoader(), RedisTemplates.stringRedisSerializer, null, valueSerializer, repository, false, true);
break;
default:
RedisTemplate = RedisTemplates.createRedisTemplate(connectionFactory, keyPrefix, new StringRedisSerializer(), StringValueController.class.getClassLoader(), RedisTemplates.stringRedisSerializer, null, null, repository, false, true);
break;
}
return RedisTemplate;
}
Aggregations