An open API service indexing awesome lists of open source software.

https://github.com/entando/config-connector

Entando Config Service connector
https://github.com/entando/config-connector

Last synced: 9 months ago
JSON representation

Entando Config Service connector

Awesome Lists containing this project

README

          

# Entando Config Service Connector

[![Build Status](https://jenkins.entandocloud.com/buildStatus/icon?job=de-config-connector-master)](https://jenkins.entandocloud.com/job/de-config-connector-master/)
[![Coverage Status](https://coveralls.io/repos/github/entando/config-connector/badge.svg?branch=master)](https://coveralls.io/github/entando/config-connector?branch=master)

This library is used to integrate with Entando ConfigService without the need to implement the communication to the service.

## Install

Add the dependency to your project

```xml

org.entando
config-connector
1.0.0-SNAPSHOT

```

Then create a Configuration class to create the bean

```java
@Configuration
public class ConfigServiceConfiguration {

@Bean
public ConfigService configService(
@Value("${client-id}") final String clientId,
@Value("${client-secret}") final String clientSecret,
@Value("${access-token-uri}") final String accessTokenUri,
@Value("${config-service-uri}") final String configServiceUri) {
return new ConfigService<>(clientId, clientSecret, accessTokenUri, configServiceUri, YourCustomConfig.class);
}

}
```

Now you can use the service, for example a wrapper:

```java
@Service
public class YourCustomConfigService {

private final ConfigService configService;

@Autowired
public YourCustomConfigService(final ConfigService configService) {
this.configService = configService;
}

public YourCustomConfig getConfig() {
return Optional.ofNullable(configService.getConfig())
.orElseGet(YourCustomConfig::getDefault);
}

public void updateAvatarConfig(final YourCustomConfig config) {
configService.updateConfig(config);
}

}
```

The configuration is builtin with a memory cache (Guava).
At the moment it is not configurable and has 10 minutes TTL.