Search in sources :

Example 1 with EasyjsonCodec

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);
}
Also used : EasyjsonCodec(com.jn.agileway.codec.serialization.json.EasyjsonCodec) DelegatableRedisSerializer(com.jn.agileway.redis.core.serialization.DelegatableRedisSerializer)

Example 2 with EasyjsonCodec

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);
}
Also used : EasyjsonCodec(com.jn.agileway.codec.serialization.json.EasyjsonCodec) DelegatableRedisSerializer(com.jn.agileway.redis.core.serialization.DelegatableRedisSerializer)

Example 3 with EasyjsonCodec

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;
}
Also used : HessianCodec(com.jn.agileway.codec.serialization.hessian.HessianCodec) CborJacksonCodec(com.jn.agileway.codec.serialization.cbor.CborJacksonCodec) FseCodec(com.jn.agileway.codec.serialization.fse.FseCodec) JdkCodec(com.jn.agileway.codec.serialization.jdk.JdkCodec) XsonCodec(com.jn.agileway.codec.serialization.xson.XsonCodec) KryoCodec(com.jn.agileway.codec.serialization.kryo.KryoCodec) ProtostuffCodec(com.jn.agileway.codec.serialization.protostuff.ProtostuffCodec) EasyjsonCodec(com.jn.agileway.codec.serialization.json.EasyjsonCodec) JdkCodec(com.jn.agileway.codec.serialization.jdk.JdkCodec) MsgPackCodec(com.jn.agileway.codec.serialization.msgpack.MsgPackCodec) EasyjsonCodec(com.jn.agileway.codec.serialization.json.EasyjsonCodec) ProtostuffCodec(com.jn.agileway.codec.serialization.protostuff.ProtostuffCodec) Codec(com.jn.agileway.codec.Codec) CborJacksonCodec(com.jn.agileway.codec.serialization.cbor.CborJacksonCodec) HessianCodec(com.jn.agileway.codec.serialization.hessian.HessianCodec) FstCodec(com.jn.agileway.codec.serialization.fst.FstCodec) BsonCodec(com.jn.agileway.codec.serialization.bson.BsonCodec) JacksonCodec(com.jn.agileway.codec.serialization.json.JacksonCodec) KryoCodec(com.jn.agileway.codec.serialization.kryo.KryoCodec) XsonCodec(com.jn.agileway.codec.serialization.xson.XsonCodec) FseCodec(com.jn.agileway.codec.serialization.fse.FseCodec) MsgPackCodec(com.jn.agileway.codec.serialization.msgpack.MsgPackCodec) CborJacksonCodec(com.jn.agileway.codec.serialization.cbor.CborJacksonCodec) JacksonCodec(com.jn.agileway.codec.serialization.json.JacksonCodec) FstCodec(com.jn.agileway.codec.serialization.fst.FstCodec) BsonCodec(com.jn.agileway.codec.serialization.bson.BsonCodec)

Example 4 with EasyjsonCodec

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;
}
Also used : EasyjsonCodec(com.jn.agileway.codec.serialization.json.EasyjsonCodec) StringRedisSerializer(org.springframework.data.redis.serializer.StringRedisSerializer) GenericJackson2JsonRedisSerializer(org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer) DelegatableRedisSerializer(com.jn.agileway.redis.core.serialization.DelegatableRedisSerializer)

Aggregations

EasyjsonCodec (com.jn.agileway.codec.serialization.json.EasyjsonCodec)4 DelegatableRedisSerializer (com.jn.agileway.redis.core.serialization.DelegatableRedisSerializer)3 Codec (com.jn.agileway.codec.Codec)1 BsonCodec (com.jn.agileway.codec.serialization.bson.BsonCodec)1 CborJacksonCodec (com.jn.agileway.codec.serialization.cbor.CborJacksonCodec)1 FseCodec (com.jn.agileway.codec.serialization.fse.FseCodec)1 FstCodec (com.jn.agileway.codec.serialization.fst.FstCodec)1 HessianCodec (com.jn.agileway.codec.serialization.hessian.HessianCodec)1 JdkCodec (com.jn.agileway.codec.serialization.jdk.JdkCodec)1 JacksonCodec (com.jn.agileway.codec.serialization.json.JacksonCodec)1 KryoCodec (com.jn.agileway.codec.serialization.kryo.KryoCodec)1 MsgPackCodec (com.jn.agileway.codec.serialization.msgpack.MsgPackCodec)1 ProtostuffCodec (com.jn.agileway.codec.serialization.protostuff.ProtostuffCodec)1 XsonCodec (com.jn.agileway.codec.serialization.xson.XsonCodec)1 GenericJackson2JsonRedisSerializer (org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer)1 StringRedisSerializer (org.springframework.data.redis.serializer.StringRedisSerializer)1