All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.zodiac.autoconfigure.redis.RedisProtoStuffAutoConfiguration Maven / Gradle / Ivy

There is a newer version: 1.6.8
Show newest version
package org.zodiac.autoconfigure.redis;

import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.zodiac.autoconfigure.redis.condition.ConditionalOnRedisEnabled;

/**
 * ProtoStuff 序列化配置。
 *
 */
@SpringBootConfiguration
@ConditionalOnRedisEnabled
@ConditionalOnClass(name = {"io.protostuff.Schema"})
@AutoConfigureBefore(value = {RedisTemplateAutoConfiguration.class})
public class RedisProtoStuffAutoConfiguration implements RedisSerializerConfigable {

    @Bean
    @ConditionalOnMissingBean
    @Override
    public RedisSerializer redisSerializer(RedisCacheCloudProperties configProperties) {
        if (org.zodiac.redis.RedisSerializerType.ProtoStuff == configProperties.getSerializerType()) {
            return new org.zodiac.redis.serializer.RedisProtoStuffSerializer();
        }
        return defaultRedisSerializer(configProperties);
    }

}