diff --git a/README.md b/README.md
index 3785325..5c96cce 100644
--- a/README.md
+++ b/README.md
@@ -5,11 +5,18 @@
## Description
Spring Auto-configuration library for [Cloud Config Client](https://github.com/Piszmog/cloud-config-client).
+__Cloud Config Client AutoConfig 3.x__ is compatible with
+
+| Dependency | Version |
+| :---: | :---: |
+| Spring Boot | 2.2.x |
+| Spring Cloud Services | 3.x.x.RELEASE |
+
__Cloud Config Client AutoConfig 2.x__ is compatible with
| Dependency | Version |
| :---: | :---: |
-| Spring Boot | 2.x.x |
+| Spring Boot | 2.1.x |
| Spring Cloud Services | 2.x.x.RELEASE |
__Cloud Config Client AutoConfig 1.x__ is compatible with
diff --git a/pom.xml b/pom.xml
index 6c72567..b80aa06 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
io.github.piszmogcloud-config-client-autoconfig
- 2.5-SNAPSHOT
+ 3.0-SNAPSHOTjar
@@ -30,7 +30,7 @@
UTF-8UTF-8
- 1.7.1
+ 1.8.13.8.13.1.02.22.2
@@ -38,14 +38,14 @@
1.61.6.8
- 2.1.4.RELEASE
- 2.1.6.RELEASE
+ 3.1.0.RELEASE
+ 2.2.2.RELEASE
- 2.5
+ 3.0-SNAPSHOT
- 3.2.12
- 2.5.7
- 3.0.1
+ 3.3.0
+ 2.5.8
+ 3.11.3-groovy-2.5
@@ -77,6 +77,11 @@
spring-cloud-services-starter-config-clientprovided
+
+ io.pivotal.spring.cloud
+ spring-cloud-services-config-client-autoconfigure
+ provided
+ org.spockframework
@@ -172,6 +177,9 @@
org.apache.maven.pluginsmaven-javadoc-plugin${maven-plugin.version}
+
+
+ attach-javadocs
diff --git a/src/main/java/io/github/piszmog/cloudconfigclient/autoconfig/client/ConfigClientAutoConfiguration.java b/src/main/java/io/github/piszmog/cloudconfigclient/autoconfig/client/ConfigClientAutoConfiguration.java
index a08ef20..77e0fde 100644
--- a/src/main/java/io/github/piszmog/cloudconfigclient/autoconfig/client/ConfigClientAutoConfiguration.java
+++ b/src/main/java/io/github/piszmog/cloudconfigclient/autoconfig/client/ConfigClientAutoConfiguration.java
@@ -19,9 +19,8 @@
* Created by Piszmog on 5/5/2018
*/
@Configuration
-@ConditionalOnBean( ConfigTemplate.class )
-public class ConfigClientAutoConfiguration
-{
+@ConditionalOnBean(ConfigTemplate.class)
+public class ConfigClientAutoConfiguration {
// ============================================================
// Beans:
// ============================================================
@@ -33,10 +32,9 @@ public class ConfigClientAutoConfiguration
* @return The decryption client.
*/
@Bean
- @ConditionalOnProperty( prefix = "cloud.config.client", name = "decrypt.enabled", matchIfMissing = true )
- public DecryptConfigClient decryptConfigClient( final ConfigTemplate configTemplate )
- {
- return new DecryptConfigClient( configTemplate );
+ @ConditionalOnProperty(prefix = "cloud.config.client", name = "decrypt.enabled", matchIfMissing = true)
+ public DecryptConfigClient decryptConfigClient(final ConfigTemplate configTemplate) {
+ return new DecryptConfigClient(configTemplate);
}
/**
@@ -46,10 +44,9 @@ public DecryptConfigClient decryptConfigClient( final ConfigTemplate configTempl
* @return The encryption client.
*/
@Bean
- @ConditionalOnProperty( prefix = "cloud.config.client", name = "encrypt.enabled", matchIfMissing = true )
- public EncryptConfigClient encryptConfigClient( final ConfigTemplate configTemplate )
- {
- return new EncryptConfigClient( configTemplate );
+ @ConditionalOnProperty(prefix = "cloud.config.client", name = "encrypt.enabled", matchIfMissing = true)
+ public EncryptConfigClient encryptConfigClient(final ConfigTemplate configTemplate) {
+ return new EncryptConfigClient(configTemplate);
}
/**
@@ -59,9 +56,8 @@ public EncryptConfigClient encryptConfigClient( final ConfigTemplate configTempl
* @return The public key client.
*/
@Bean
- @ConditionalOnProperty( prefix = "cloud.config.client", name = "publickey.enabled", matchIfMissing = true )
- public PublicKeyClient publicKeyClient( final ConfigTemplate configTemplate )
- {
- return new PublicKeyClient( configTemplate );
+ @ConditionalOnProperty(prefix = "cloud.config.client", name = "publickey.enabled", matchIfMissing = true)
+ public PublicKeyClient publicKeyClient(final ConfigTemplate configTemplate) {
+ return new PublicKeyClient(configTemplate);
}
}
diff --git a/src/main/java/io/github/piszmog/cloudconfigclient/autoconfig/env/ConfigPropertySourceLocator.java b/src/main/java/io/github/piszmog/cloudconfigclient/autoconfig/env/ConfigPropertySourceLocator.java
index 82f0065..41f9d6f 100644
--- a/src/main/java/io/github/piszmog/cloudconfigclient/autoconfig/env/ConfigPropertySourceLocator.java
+++ b/src/main/java/io/github/piszmog/cloudconfigclient/autoconfig/env/ConfigPropertySourceLocator.java
@@ -31,9 +31,8 @@
*
* Created by Piszmog on 7/21/2018
*/
-public class ConfigPropertySourceLocator
-{
- private static final transient Log logger = LogFactory.getLog( ConfigPropertySourceLocator.class );
+public class ConfigPropertySourceLocator {
+ private static final transient Log logger = LogFactory.getLog(ConfigPropertySourceLocator.class);
// ============================================================
// Class Constants:
@@ -41,7 +40,7 @@ public class ConfigPropertySourceLocator
private static final String PROPERTY_SOURCE_NAME = "jsonResource";
private static final String THREAD_NAME = "ConfigLocator";
- private static final ObjectMapper YAML_MAPPER = new ObjectMapper( new YAMLFactory() );
+ private static final ObjectMapper YAML_MAPPER = new ObjectMapper(new YAMLFactory());
private static final JavaPropsMapper PROPERTIES_MAPPER = new JavaPropsMapper();
// ============================================================
@@ -49,11 +48,11 @@ public class ConfigPropertySourceLocator
// ============================================================
private final FileConfigClient fileConfigClient;
- private final ExecutorService executorService = Executors.newFixedThreadPool( 10,
- new BasicThreadFactory.Builder().namingPattern( THREAD_NAME + "-%d" )
- .daemon( true )
- .priority( Thread.MAX_PRIORITY )
- .build() );
+ private final ExecutorService executorService = Executors.newFixedThreadPool(10,
+ new BasicThreadFactory.Builder().namingPattern(THREAD_NAME + "-%d")
+ .daemon(true)
+ .priority(Thread.MAX_PRIORITY)
+ .build());
// ============================================================
// Constructors:
@@ -64,8 +63,7 @@ public class ConfigPropertySourceLocator
*
* @param fileConfigClient the file config client to load files from the config server.
*/
- public ConfigPropertySourceLocator( final FileConfigClient fileConfigClient )
- {
+ public ConfigPropertySourceLocator(final FileConfigClient fileConfigClient) {
this.fileConfigClient = fileConfigClient;
}
@@ -79,31 +77,25 @@ public ConfigPropertySourceLocator( final FileConfigClient fileConfigClient )
* @param resources the resources to load
* @return The property source with the JSON resources loaded.
*/
- public PropertySource> locateConfigResources( final List resources )
- {
- CompositePropertySource composite = new CompositePropertySource( PROPERTY_SOURCE_NAME );
+ public PropertySource> locateConfigResources(final List resources) {
+ CompositePropertySource composite = new CompositePropertySource(PROPERTY_SOURCE_NAME);
//
// Load files asynchronously
//
List> futures = new ArrayList<>();
- resources.stream().filter( Objects::nonNull ).map( resource ->
- getJsonConfiguration( composite, resource.getDirectory(), resource.getFiles() ) ).forEach( futures::addAll );
- final CompletableFuture> listCompletableFuture = CompletableFuture.allOf( futures.toArray( new CompletableFuture[ 0 ] ) )
- .thenApply( future -> futures.stream().map( CompletableFuture::join ).collect( Collectors.toList() ) );
- try
- {
+ resources.stream().filter(Objects::nonNull).map(resource ->
+ getJsonConfiguration(composite, resource.getDirectory(), resource.getFiles())).forEach(futures::addAll);
+ final CompletableFuture> listCompletableFuture = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]))
+ .thenApply(future -> futures.stream().map(CompletableFuture::join).collect(Collectors.toList()));
+ try {
//
// Wait for files to complete -- don't want Spring to start setting up Beans without all property sources
//
listCompletableFuture.get();
- logger.info( "Successfully loaded all external configuration files." );
- }
- catch ( InterruptedException | ExecutionException e )
- {
- throw new ConfigResourceException( "Failed to retrieve files.", e );
- }
- finally
- {
+ logger.info("Successfully loaded all external configuration files.");
+ } catch (InterruptedException | ExecutionException e) {
+ throw new ConfigResourceException("Failed to retrieve files.", e);
+ } finally {
executorService.shutdownNow();
}
return composite;
@@ -113,101 +105,76 @@ public PropertySource> locateConfigResources( final List resources )
// Private Methods:
// ============================================================
- private List> getJsonConfiguration( final CompositePropertySource composite,
- final String directoryPath,
- final List files )
- {
- return files.stream().filter( Objects::nonNull ).map( file -> CompletableFuture.supplyAsync( () ->
- loadConfigurationFile( directoryPath, file ), executorService ).thenAccept( mapPropertySource -> {
- if ( mapPropertySource != null )
- {
- composite.addPropertySource( mapPropertySource );
+ private List> getJsonConfiguration(final CompositePropertySource composite,
+ final String directoryPath,
+ final List files) {
+ return files.stream().filter(Objects::nonNull).map(file -> CompletableFuture.supplyAsync(() ->
+ loadConfigurationFile(directoryPath, file), executorService).thenAccept(mapPropertySource -> {
+ if (mapPropertySource != null) {
+ composite.addPropertySource(mapPropertySource);
}
- } ) ).collect( Collectors.toList() );
+ })).collect(Collectors.toList());
}
- @SuppressWarnings( "unchecked" )
- private MapPropertySource loadConfigurationFile( final String directoryPath, final String fileName )
- {
- final String filePath = getFilePath( directoryPath, fileName );
+ @SuppressWarnings("unchecked")
+ private MapPropertySource loadConfigurationFile(final String directoryPath, final String fileName) {
+ final String filePath = getFilePath(directoryPath, fileName);
Map file;
- try
- {
- logger.info( "Loading configuration " + filePath + "..." );
- if ( StringUtils.endsWithIgnoreCase( fileName, ".yml" ) || StringUtils.endsWithIgnoreCase( fileName, ".yaml" ) )
- {
- file = getYAMLFile( directoryPath, fileName );
- }
- else if ( StringUtils.endsWithIgnoreCase( fileName, ".properties" ) )
- {
- file = getPropertiesFile( directoryPath, fileName );
- }
- else
- {
- file = getJSONFile( directoryPath, fileName );
+ try {
+ logger.info("Loading configuration " + filePath + "...");
+ if (StringUtils.endsWithIgnoreCase(fileName, ".yml") || StringUtils.endsWithIgnoreCase(fileName, ".yaml")) {
+ file = getYAMLFile(directoryPath, fileName);
+ } else if (StringUtils.endsWithIgnoreCase(fileName, ".properties")) {
+ file = getPropertiesFile(directoryPath, fileName);
+ } else {
+ file = getJSONFile(directoryPath, fileName);
}
+ } catch (ConfigException e) {
+ throw new ConfigResourceException("Failed to load " + filePath, e);
}
- catch ( ConfigException e )
- {
- throw new ConfigResourceException( "Failed to load " + filePath, e );
- }
- if ( !file.isEmpty() )
- {
- final Map flattenMap = MapFlattener.flatten( file );
- return new MapPropertySource( filePath, flattenMap );
+ if (!file.isEmpty()) {
+ final Map flattenMap = MapFlattener.flatten(file);
+ return new MapPropertySource(filePath, flattenMap);
}
return null;
}
- private String getFilePath( final String directoryPath, final String fileName )
- {
+ private String getFilePath(final String directoryPath, final String fileName) {
return directoryPath + "/" + fileName;
}
- private Map getYAMLFile( final String directoryPath, final String fileName ) throws ConfigException
- {
+ private Map getYAMLFile(final String directoryPath, final String fileName) throws ConfigException {
final Map file;
- final byte[] yamlFile = fileConfigClient.getFileFromDefaultBranch( fileName, directoryPath, byte[].class );
- if ( yamlFile == null )
- {
- throw new ConfigResourceException( "Failed to find file " + fileName + " from the Config Server. Ensure the file exists." );
- }
- try
- {
- file = YAML_MAPPER.readValue( yamlFile, Map.class );
+ final byte[] yamlFile = fileConfigClient.getFileFromDefaultBranch(fileName, directoryPath, byte[].class);
+ if (yamlFile == null) {
+ throw new ConfigResourceException("Failed to find file " + fileName + " from the Config Server. Ensure the file exists.");
}
- catch ( IOException e )
- {
- throw new ConfigResourceException( "Failed to convert " + fileName + " from YAML format to be loaded in the property sources.", e );
+ try {
+ file = YAML_MAPPER.readValue(yamlFile, Map.class);
+ } catch (IOException e) {
+ throw new ConfigResourceException("Failed to convert " + fileName + " from YAML format to be loaded in the property sources.", e);
}
return file;
}
- private Map getPropertiesFile( final String directoryPath, final String fileName ) throws ConfigException
- {
+ private Map getPropertiesFile(final String directoryPath, final String fileName) throws ConfigException {
final Map file;
- final byte[] propertiesFile = fileConfigClient.getFileFromDefaultBranch( fileName, directoryPath, byte[].class );
- if ( propertiesFile == null )
- {
- throw new ConfigResourceException( "Failed to find file " + fileName + " from the Config Server. Ensure the file exists." );
- }
- try
- {
- file = PROPERTIES_MAPPER.readValue( propertiesFile, Map.class );
+ final byte[] propertiesFile = fileConfigClient.getFileFromDefaultBranch(fileName, directoryPath, byte[].class);
+ if (propertiesFile == null) {
+ throw new ConfigResourceException("Failed to find file " + fileName + " from the Config Server. Ensure the file exists.");
}
- catch ( IOException e )
- {
- throw new ConfigResourceException( "Failed to convert " + fileName + " from PROPERTIES format to be loaded in the property sources.", e );
+ try {
+ file = PROPERTIES_MAPPER.readValue(propertiesFile, Map.class);
+ } catch (IOException e) {
+ throw new ConfigResourceException("Failed to convert " + fileName + " from PROPERTIES format to be loaded in the property sources.", e);
}
return file;
}
- private Map getJSONFile( final String directoryPath, final String fileName ) throws ConfigException
- {
- final Map jsonFile = fileConfigClient.getFileFromDefaultBranch( fileName, directoryPath, Map.class );
- if ( jsonFile == null )
- {
- throw new ConfigResourceException( "Failed to find file " + fileName + " from the Config Server. Ensure the file exists." );
+ private Map getJSONFile(final String directoryPath, final String fileName) throws ConfigException {
+ final Map jsonFile = fileConfigClient.getFileFromDefaultBranch(fileName, directoryPath, Map.class);
+ if (jsonFile == null) {
+ throw new ConfigResourceException("Failed to find file " + fileName + " from the Config Server. Ensure the file exists.");
}
return jsonFile;
}
diff --git a/src/main/java/io/github/piszmog/cloudconfigclient/autoconfig/env/ConfigResourceBootstrapInitializer.java b/src/main/java/io/github/piszmog/cloudconfigclient/autoconfig/env/ConfigResourceBootstrapInitializer.java
index d63aa72..e2f1e93 100644
--- a/src/main/java/io/github/piszmog/cloudconfigclient/autoconfig/env/ConfigResourceBootstrapInitializer.java
+++ b/src/main/java/io/github/piszmog/cloudconfigclient/autoconfig/env/ConfigResourceBootstrapInitializer.java
@@ -32,8 +32,7 @@
* Created by Piszmog on 7/21/2018
*/
@Configuration
-public class ConfigResourceBootstrapInitializer implements ApplicationContextInitializer, Ordered
-{
+public class ConfigResourceBootstrapInitializer implements ApplicationContextInitializer, Ordered {
// ============================================================
// Class Constants:
// ============================================================
@@ -53,59 +52,49 @@ public class ConfigResourceBootstrapInitializer implements ApplicationContextIni
// ============================================================
@Override
- public void initialize( final ConfigurableApplicationContext applicationContext )
- {
+ public void initialize(final ConfigurableApplicationContext applicationContext) {
final ConfigurableEnvironment environment = applicationContext.getEnvironment();
- final String isEnabled = environment.getProperty( PROPERTY_ENABLED );
- if ( ( StringUtils.isBlank( isEnabled ) || BooleanUtils.toBoolean( isEnabled ) )
- && configPropertySourceLocator != null )
- {
+ final String isEnabled = environment.getProperty(PROPERTY_ENABLED);
+ if ((StringUtils.isBlank(isEnabled) || BooleanUtils.toBoolean(isEnabled))
+ && configPropertySourceLocator != null) {
final List resources = new ArrayList<>();
- for ( int i = 0; i < MAX_SIZE; i++ )
- {
+ for (int i = 0; i < MAX_SIZE; i++) {
final List files = new ArrayList<>();
- final String directory = environment.getProperty( PROPERTY_FILE + ".resources[" + i + "].directory" );
- for ( int j = 0; j < MAX_SIZE; j++ )
- {
- final String fileName = environment.getProperty( PROPERTY_FILE + ".resources[" + i + "].files[" + j + "]" );
- if ( StringUtils.isBlank( fileName ) )
- {
+ final String directory = environment.getProperty(PROPERTY_FILE + ".resources[" + i + "].directory");
+ for (int j = 0; j < MAX_SIZE; j++) {
+ final String fileName = environment.getProperty(PROPERTY_FILE + ".resources[" + i + "].files[" + j + "]");
+ if (StringUtils.isBlank(fileName)) {
break;
}
- if ( StringUtils.isBlank( directory ) && StringUtils.isNotBlank( fileName ) )
- {
- throw new ConfigResourceException( "Directory must not be null or blank when file is not blank or null." );
+ if (StringUtils.isBlank(directory) && StringUtils.isNotBlank(fileName)) {
+ throw new ConfigResourceException("Directory must not be null or blank when file is not blank or null.");
}
- if ( !StringUtils.endsWithIgnoreCase( fileName, ".json" )
- && !StringUtils.endsWithIgnoreCase( fileName, ".yml" )
- && !StringUtils.endsWithIgnoreCase( fileName, ".yaml" )
- && !StringUtils.endsWithIgnoreCase( fileName, ".properties" ) )
- {
- throw new ConfigResourceException( "File " + fileName + " is not a configuration file." +
- " Only .json, .yml, .yaml, and .properties are accepted." );
+ if (!StringUtils.endsWithIgnoreCase(fileName, ".json")
+ && !StringUtils.endsWithIgnoreCase(fileName, ".yml")
+ && !StringUtils.endsWithIgnoreCase(fileName, ".yaml")
+ && !StringUtils.endsWithIgnoreCase(fileName, ".properties")) {
+ throw new ConfigResourceException("File " + fileName + " is not a configuration file." +
+ " Only .json, .yml, .yaml, and .properties are accepted.");
}
- files.add( fileName );
+ files.add(fileName);
}
- if ( StringUtils.isBlank( directory ) && files.isEmpty() )
- {
+ if (StringUtils.isBlank(directory) && files.isEmpty()) {
break;
}
final Resource resource = new Resource();
- resource.setDirectory( directory );
- resource.setFiles( files );
- resources.add( resource );
+ resource.setDirectory(directory);
+ resource.setFiles(files);
+ resources.add(resource);
}
- if ( !resources.isEmpty() )
- {
- final PropertySource> propertySource = configPropertySourceLocator.locateConfigResources( resources );
- environment.getPropertySources().addFirst( propertySource );
+ if (!resources.isEmpty()) {
+ final PropertySource> propertySource = configPropertySourceLocator.locateConfigResources(resources);
+ environment.getPropertySources().addFirst(propertySource);
}
}
}
@Override
- public int getOrder()
- {
+ public int getOrder() {
//
// Want to let all other initializers go first. Potentially the config server needs to be loaded first
// before we can load the files.
@@ -117,9 +106,8 @@ public int getOrder()
// Public Methods:
// ============================================================
- @Autowired( required = false )
- public void setConfigPropertySourceLocator( final ConfigPropertySourceLocator configPropertySourceLocator )
- {
+ @Autowired(required = false)
+ public void setConfigPropertySourceLocator(final ConfigPropertySourceLocator configPropertySourceLocator) {
this.configPropertySourceLocator = configPropertySourceLocator;
}
}
diff --git a/src/main/java/io/github/piszmog/cloudconfigclient/autoconfig/env/ConfigResourceException.java b/src/main/java/io/github/piszmog/cloudconfigclient/autoconfig/env/ConfigResourceException.java
index bcf6fed..7839e63 100644
--- a/src/main/java/io/github/piszmog/cloudconfigclient/autoconfig/env/ConfigResourceException.java
+++ b/src/main/java/io/github/piszmog/cloudconfigclient/autoconfig/env/ConfigResourceException.java
@@ -5,13 +5,11 @@
*
* Created by Piszmog on 5/5/2018
*/
-public class ConfigResourceException extends RuntimeException
-{
+public class ConfigResourceException extends RuntimeException {
/**
* Creates a new configuration resource exception.
*/
- public ConfigResourceException()
- {
+ public ConfigResourceException() {
}
/**
@@ -19,9 +17,8 @@ public ConfigResourceException()
*
* @param message the message associated with the exception
*/
- public ConfigResourceException( final String message )
- {
- super( message );
+ public ConfigResourceException(final String message) {
+ super(message);
}
/**
@@ -30,9 +27,8 @@ public ConfigResourceException( final String message )
* @param message the message associated with the exception
* @param cause the cause of th exception
*/
- public ConfigResourceException( final String message, final Throwable cause )
- {
- super( message, cause );
+ public ConfigResourceException(final String message, final Throwable cause) {
+ super(message, cause);
}
/**
@@ -40,9 +36,8 @@ public ConfigResourceException( final String message, final Throwable cause )
*
* @param cause the cause of th exception
*/
- public ConfigResourceException( final Throwable cause )
- {
- super( cause );
+ public ConfigResourceException(final Throwable cause) {
+ super(cause);
}
/**
@@ -53,8 +48,7 @@ public ConfigResourceException( final Throwable cause )
* @param enableSuppression determines if suppression is enabled
* @param writableStackTrace determines if the stack is writeable
*/
- public ConfigResourceException( final String message, final Throwable cause, final boolean enableSuppression, final boolean writableStackTrace )
- {
- super( message, cause, enableSuppression, writableStackTrace );
+ public ConfigResourceException(final String message, final Throwable cause, final boolean enableSuppression, final boolean writableStackTrace) {
+ super(message, cause, enableSuppression, writableStackTrace);
}
}
diff --git a/src/main/java/io/github/piszmog/cloudconfigclient/autoconfig/env/ResourceBootstrapConfig.java b/src/main/java/io/github/piszmog/cloudconfigclient/autoconfig/env/ResourceBootstrapConfig.java
index 6a40ab1..c847f3b 100644
--- a/src/main/java/io/github/piszmog/cloudconfigclient/autoconfig/env/ResourceBootstrapConfig.java
+++ b/src/main/java/io/github/piszmog/cloudconfigclient/autoconfig/env/ResourceBootstrapConfig.java
@@ -20,10 +20,9 @@
*/
@Order
@Configuration
-@ConditionalOnProperty( prefix = "cloud.config.client", name = "file.enabled", matchIfMissing = true )
-@Import( { LocalConfigTemplateBootstrapConfiguration.class, OAuth2ConfigTemplateBootStrapConfiguration.class } )
-public class ResourceBootstrapConfig
-{
+@ConditionalOnProperty(prefix = "cloud.config.client", name = "file.enabled", matchIfMissing = true)
+@Import({LocalConfigTemplateBootstrapConfiguration.class, OAuth2ConfigTemplateBootStrapConfiguration.class})
+public class ResourceBootstrapConfig {
/**
* Create a file client. To disable, the property {@code cloud.config.client.file.enabled} must be set via bootstrap
* configuration.
@@ -33,9 +32,8 @@ public class ResourceBootstrapConfig
*/
@Order
@Bean
- public FileConfigClient fileConfigClient( final ConfigTemplate configTemplate )
- {
- return new FileConfigClient( configTemplate );
+ public FileConfigClient fileConfigClient(final ConfigTemplate configTemplate) {
+ return new FileConfigClient(configTemplate);
}
/**
@@ -46,8 +44,7 @@ public FileConfigClient fileConfigClient( final ConfigTemplate configTemplate )
*/
@Order
@Bean
- public ConfigPropertySourceLocator configPropertySourceLocator( final FileConfigClient fileConfigClient )
- {
- return new ConfigPropertySourceLocator( fileConfigClient );
+ public ConfigPropertySourceLocator configPropertySourceLocator(final FileConfigClient fileConfigClient) {
+ return new ConfigPropertySourceLocator(fileConfigClient);
}
}
diff --git a/src/main/java/io/github/piszmog/cloudconfigclient/autoconfig/env/model/Resource.java b/src/main/java/io/github/piszmog/cloudconfigclient/autoconfig/env/model/Resource.java
index 417ff58..79833a1 100644
--- a/src/main/java/io/github/piszmog/cloudconfigclient/autoconfig/env/model/Resource.java
+++ b/src/main/java/io/github/piszmog/cloudconfigclient/autoconfig/env/model/Resource.java
@@ -7,8 +7,7 @@
*
* Created by Piszmog on 7/21/2018
*/
-public class Resource
-{
+public class Resource {
// ============================================================
// Class Attributes:
// ============================================================
@@ -20,23 +19,19 @@ public class Resource
// Public Methods:
// ============================================================
- public String getDirectory()
- {
+ public String getDirectory() {
return directory;
}
- public void setDirectory( final String directory )
- {
+ public void setDirectory(final String directory) {
this.directory = directory;
}
- public List getFiles()
- {
+ public List getFiles() {
return files;
}
- public void setFiles( final List files )
- {
+ public void setFiles(final List files) {
this.files = files;
}
}
diff --git a/src/main/java/io/github/piszmog/cloudconfigclient/autoconfig/env/support/MapFlattener.java b/src/main/java/io/github/piszmog/cloudconfigclient/autoconfig/env/support/MapFlattener.java
index 791a622..53b02a8 100644
--- a/src/main/java/io/github/piszmog/cloudconfigclient/autoconfig/env/support/MapFlattener.java
+++ b/src/main/java/io/github/piszmog/cloudconfigclient/autoconfig/env/support/MapFlattener.java
@@ -14,8 +14,7 @@
*
* Created by Piszmog on 7/25/2018
*/
-public class MapFlattener
-{
+public class MapFlattener {
// ============================================================
// Static Methods:
// ============================================================
@@ -26,10 +25,9 @@ public class MapFlattener
* @param map the map to flatten
* @return The flatten map with the keys in the Spring properties format.
*/
- public static Map flatten( Map map )
- {
+ public static Map flatten(Map map) {
Map result = new LinkedHashMap<>();
- flatten( null, result, map );
+ flatten(null, result, map);
return result;
}
@@ -37,47 +35,38 @@ public static Map flatten( Map map )
// Private Methods:
// ============================================================
- private static void flatten( String prefix,
- Map result,
- Map map )
- {
- String namePrefix = ( prefix != null ? prefix + "." : "" );
- map.forEach( ( key, value ) -> {
+ private static void flatten(String prefix,
+ Map result,
+ Map map) {
+ String namePrefix = (prefix != null ? prefix + "." : "");
+ map.forEach((key, value) -> {
String finalKey = key;
//
// If key has certain characters in it, we want to wrap key in '[' and ']'.
//
- if ( StringUtils.contains( key, ":" )
- || StringUtils.contains( key, "." )
- || StringUtils.contains( key, "*" )
- || StringUtils.startsWith( key, "$" )
- || StringUtils.startsWith( key, "#" ) )
- {
+ if (StringUtils.contains(key, ":")
+ || StringUtils.contains(key, ".")
+ || StringUtils.contains(key, "*")
+ || StringUtils.startsWith(key, "$")
+ || StringUtils.startsWith(key, "#")) {
finalKey = "[" + key + "]";
}
- extract( namePrefix + finalKey, result, value );
- } );
+ extract(namePrefix + finalKey, result, value);
+ });
}
- @SuppressWarnings( "unchecked" )
- private static void extract( String name, Map result, Object value )
- {
- if ( value instanceof Map )
- {
- flatten( name, result, (Map) value );
- }
- else if ( value instanceof Collection )
- {
+ @SuppressWarnings("unchecked")
+ private static void extract(String name, Map result, Object value) {
+ if (value instanceof Map) {
+ flatten(name, result, (Map) value);
+ } else if (value instanceof Collection) {
int index = 0;
- for ( Object object : (Collection