use of io.quarkus.arc.DefaultBean 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;
}
Aggregations