Search in sources :

Example 1 with ConfigSupport

use of org.redisson.config.ConfigSupport in project redisson by redisson.

the class RedissonClientProducer method create.

@Produces
@Singleton
@DefaultBean
public RedissonClient create() throws IOException {
    InputStream configStream;
    Optional<String> configFile = ConfigProvider.getConfig().getOptionalValue("quarkus.redisson.file", String.class);
    if (configFile.isPresent()) {
        configStream = getClass().getResourceAsStream(configFile.get());
    } else {
        configStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("redisson.yaml");
    }
    String config;
    if (configStream != null) {
        byte[] array = new byte[configStream.available()];
        configStream.read(array);
        config = new String(array, StandardCharsets.UTF_8);
    } else {
        String yaml = PropertiesConvertor.toYaml("quarkus.redisson.", ConfigProvider.getConfig().getPropertyNames(), prop -> {
            return ConfigProvider.getConfig().getValue(prop, String.class);
        });
        config = yaml;
    }
    ConfigSupport support = new ConfigSupport() {

        {
            yamlMapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
        }
    };
    Config c = support.fromYAML(config, Config.class);
    redisson = Redisson.create(c);
    return redisson;
}
Also used : ConfigSupport(org.redisson.config.ConfigSupport) InputStream(java.io.InputStream) Config(org.redisson.config.Config) DefaultBean(io.quarkus.arc.DefaultBean) Produces(javax.enterprise.inject.Produces) Singleton(javax.inject.Singleton)

Aggregations

DefaultBean (io.quarkus.arc.DefaultBean)1 InputStream (java.io.InputStream)1 Produces (javax.enterprise.inject.Produces)1 Singleton (javax.inject.Singleton)1 Config (org.redisson.config.Config)1 ConfigSupport (org.redisson.config.ConfigSupport)1