|
|
@ -1,5 +1,5 @@
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Copyright 2012-2020 the original author or authors.
|
|
|
|
* Copyright 2012-2021 the original author or authors.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
@ -55,6 +55,8 @@ class ConfigDataEnvironmentContributor implements Iterable<ConfigDataEnvironment
|
|
|
|
|
|
|
|
|
|
|
|
private final ConfigDataResource resource;
|
|
|
|
private final ConfigDataResource resource;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final boolean profileSpecific;
|
|
|
|
|
|
|
|
|
|
|
|
private final PropertySource<?> propertySource;
|
|
|
|
private final PropertySource<?> propertySource;
|
|
|
|
|
|
|
|
|
|
|
|
private final ConfigurationPropertySource configurationPropertySource;
|
|
|
|
private final ConfigurationPropertySource configurationPropertySource;
|
|
|
@ -72,6 +74,7 @@ class ConfigDataEnvironmentContributor implements Iterable<ConfigDataEnvironment
|
|
|
|
* @param kind the contributor kind
|
|
|
|
* @param kind the contributor kind
|
|
|
|
* @param location the location of this contributor
|
|
|
|
* @param location the location of this contributor
|
|
|
|
* @param resource the resource that contributed the data or {@code null}
|
|
|
|
* @param resource the resource that contributed the data or {@code null}
|
|
|
|
|
|
|
|
* @param profileSpecific if the contributor is from a profile specific import
|
|
|
|
* @param propertySource the property source for the data or {@code null}
|
|
|
|
* @param propertySource the property source for the data or {@code null}
|
|
|
|
* @param configurationPropertySource the configuration property source for the data
|
|
|
|
* @param configurationPropertySource the configuration property source for the data
|
|
|
|
* or {@code null}
|
|
|
|
* or {@code null}
|
|
|
@ -80,12 +83,13 @@ class ConfigDataEnvironmentContributor implements Iterable<ConfigDataEnvironment
|
|
|
|
* @param children the children of this contributor at each {@link ImportPhase}
|
|
|
|
* @param children the children of this contributor at each {@link ImportPhase}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
ConfigDataEnvironmentContributor(Kind kind, ConfigDataLocation location, ConfigDataResource resource,
|
|
|
|
ConfigDataEnvironmentContributor(Kind kind, ConfigDataLocation location, ConfigDataResource resource,
|
|
|
|
PropertySource<?> propertySource, ConfigurationPropertySource configurationPropertySource,
|
|
|
|
boolean profileSpecific, PropertySource<?> propertySource,
|
|
|
|
ConfigDataProperties properties, boolean ignoreImports,
|
|
|
|
ConfigurationPropertySource configurationPropertySource, ConfigDataProperties properties,
|
|
|
|
Map<ImportPhase, List<ConfigDataEnvironmentContributor>> children) {
|
|
|
|
boolean ignoreImports, Map<ImportPhase, List<ConfigDataEnvironmentContributor>> children) {
|
|
|
|
this.kind = kind;
|
|
|
|
this.kind = kind;
|
|
|
|
this.location = location;
|
|
|
|
this.location = location;
|
|
|
|
this.resource = resource;
|
|
|
|
this.resource = resource;
|
|
|
|
|
|
|
|
this.profileSpecific = profileSpecific;
|
|
|
|
this.properties = properties;
|
|
|
|
this.properties = properties;
|
|
|
|
this.propertySource = propertySource;
|
|
|
|
this.propertySource = propertySource;
|
|
|
|
this.configurationPropertySource = configurationPropertySource;
|
|
|
|
this.configurationPropertySource = configurationPropertySource;
|
|
|
@ -122,6 +126,14 @@ class ConfigDataEnvironmentContributor implements Iterable<ConfigDataEnvironment
|
|
|
|
return this.resource;
|
|
|
|
return this.resource;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Return if the contributor is from a profile specific import.
|
|
|
|
|
|
|
|
* @return if the contributor is profile specific
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
boolean isProfileSpecific() {
|
|
|
|
|
|
|
|
return this.profileSpecific;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Return the property source for this contributor.
|
|
|
|
* Return the property source for this contributor.
|
|
|
|
* @return the property source or {@code null}
|
|
|
|
* @return the property source or {@code null}
|
|
|
@ -201,7 +213,8 @@ class ConfigDataEnvironmentContributor implements Iterable<ConfigDataEnvironment
|
|
|
|
properties = properties.withoutImports();
|
|
|
|
properties = properties.withoutImports();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return new ConfigDataEnvironmentContributor(Kind.BOUND_IMPORT, this.location, this.resource,
|
|
|
|
return new ConfigDataEnvironmentContributor(Kind.BOUND_IMPORT, this.location, this.resource,
|
|
|
|
this.propertySource, this.configurationPropertySource, properties, this.ignoreImports, null);
|
|
|
|
this.profileSpecific, this.propertySource, this.configurationPropertySource, properties,
|
|
|
|
|
|
|
|
this.ignoreImports, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -215,8 +228,9 @@ class ConfigDataEnvironmentContributor implements Iterable<ConfigDataEnvironment
|
|
|
|
List<ConfigDataEnvironmentContributor> children) {
|
|
|
|
List<ConfigDataEnvironmentContributor> children) {
|
|
|
|
Map<ImportPhase, List<ConfigDataEnvironmentContributor>> updatedChildren = new LinkedHashMap<>(this.children);
|
|
|
|
Map<ImportPhase, List<ConfigDataEnvironmentContributor>> updatedChildren = new LinkedHashMap<>(this.children);
|
|
|
|
updatedChildren.put(importPhase, children);
|
|
|
|
updatedChildren.put(importPhase, children);
|
|
|
|
return new ConfigDataEnvironmentContributor(this.kind, this.location, this.resource, this.propertySource,
|
|
|
|
return new ConfigDataEnvironmentContributor(this.kind, this.location, this.resource, this.profileSpecific,
|
|
|
|
this.configurationPropertySource, this.properties, this.ignoreImports, updatedChildren);
|
|
|
|
this.propertySource, this.configurationPropertySource, this.properties, this.ignoreImports,
|
|
|
|
|
|
|
|
updatedChildren);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -240,8 +254,9 @@ class ConfigDataEnvironmentContributor implements Iterable<ConfigDataEnvironment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
updatedChildren.put(importPhase, Collections.unmodifiableList(updatedContributors));
|
|
|
|
updatedChildren.put(importPhase, Collections.unmodifiableList(updatedContributors));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return new ConfigDataEnvironmentContributor(this.kind, this.location, this.resource, this.propertySource,
|
|
|
|
return new ConfigDataEnvironmentContributor(this.kind, this.location, this.resource, this.profileSpecific,
|
|
|
|
this.configurationPropertySource, this.properties, this.ignoreImports, updatedChildren);
|
|
|
|
this.propertySource, this.configurationPropertySource, this.properties, this.ignoreImports,
|
|
|
|
|
|
|
|
updatedChildren);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -252,7 +267,7 @@ class ConfigDataEnvironmentContributor implements Iterable<ConfigDataEnvironment
|
|
|
|
static ConfigDataEnvironmentContributor of(List<ConfigDataEnvironmentContributor> contributors) {
|
|
|
|
static ConfigDataEnvironmentContributor of(List<ConfigDataEnvironmentContributor> contributors) {
|
|
|
|
Map<ImportPhase, List<ConfigDataEnvironmentContributor>> children = new LinkedHashMap<>();
|
|
|
|
Map<ImportPhase, List<ConfigDataEnvironmentContributor>> children = new LinkedHashMap<>();
|
|
|
|
children.put(ImportPhase.BEFORE_PROFILE_ACTIVATION, Collections.unmodifiableList(contributors));
|
|
|
|
children.put(ImportPhase.BEFORE_PROFILE_ACTIVATION, Collections.unmodifiableList(contributors));
|
|
|
|
return new ConfigDataEnvironmentContributor(Kind.ROOT, null, null, null, null, null, false, children);
|
|
|
|
return new ConfigDataEnvironmentContributor(Kind.ROOT, null, null, false, null, null, null, false, children);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -265,8 +280,8 @@ class ConfigDataEnvironmentContributor implements Iterable<ConfigDataEnvironment
|
|
|
|
static ConfigDataEnvironmentContributor ofInitialImport(ConfigDataLocation initialImport) {
|
|
|
|
static ConfigDataEnvironmentContributor ofInitialImport(ConfigDataLocation initialImport) {
|
|
|
|
List<ConfigDataLocation> imports = Collections.singletonList(initialImport);
|
|
|
|
List<ConfigDataLocation> imports = Collections.singletonList(initialImport);
|
|
|
|
ConfigDataProperties properties = new ConfigDataProperties(imports, null);
|
|
|
|
ConfigDataProperties properties = new ConfigDataProperties(imports, null);
|
|
|
|
return new ConfigDataEnvironmentContributor(Kind.INITIAL_IMPORT, null, null, null, null, properties, false,
|
|
|
|
return new ConfigDataEnvironmentContributor(Kind.INITIAL_IMPORT, null, null, false, null, null, properties,
|
|
|
|
null);
|
|
|
|
false, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -277,7 +292,7 @@ class ConfigDataEnvironmentContributor implements Iterable<ConfigDataEnvironment
|
|
|
|
* @return a new {@link ConfigDataEnvironmentContributor} instance
|
|
|
|
* @return a new {@link ConfigDataEnvironmentContributor} instance
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
static ConfigDataEnvironmentContributor ofExisting(PropertySource<?> propertySource) {
|
|
|
|
static ConfigDataEnvironmentContributor ofExisting(PropertySource<?> propertySource) {
|
|
|
|
return new ConfigDataEnvironmentContributor(Kind.EXISTING, null, null, propertySource,
|
|
|
|
return new ConfigDataEnvironmentContributor(Kind.EXISTING, null, null, false, propertySource,
|
|
|
|
ConfigurationPropertySource.from(propertySource), null, false, null);
|
|
|
|
ConfigurationPropertySource.from(propertySource), null, false, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -287,26 +302,29 @@ class ConfigDataEnvironmentContributor implements Iterable<ConfigDataEnvironment
|
|
|
|
* import further contributors later.
|
|
|
|
* import further contributors later.
|
|
|
|
* @param location the location of this contributor
|
|
|
|
* @param location the location of this contributor
|
|
|
|
* @param resource the config data resource
|
|
|
|
* @param resource the config data resource
|
|
|
|
|
|
|
|
* @param profileSpecific if the contributor is from a profile specific import
|
|
|
|
* @param configData the config data
|
|
|
|
* @param configData the config data
|
|
|
|
* @param propertySourceIndex the index of the property source that should be used
|
|
|
|
* @param propertySourceIndex the index of the property source that should be used
|
|
|
|
* @return a new {@link ConfigDataEnvironmentContributor} instance
|
|
|
|
* @return a new {@link ConfigDataEnvironmentContributor} instance
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
static ConfigDataEnvironmentContributor ofUnboundImport(ConfigDataLocation location, ConfigDataResource resource,
|
|
|
|
static ConfigDataEnvironmentContributor ofUnboundImport(ConfigDataLocation location, ConfigDataResource resource,
|
|
|
|
ConfigData configData, int propertySourceIndex) {
|
|
|
|
boolean profileSpecific, ConfigData configData, int propertySourceIndex) {
|
|
|
|
PropertySource<?> propertySource = configData.getPropertySources().get(propertySourceIndex);
|
|
|
|
PropertySource<?> propertySource = configData.getPropertySources().get(propertySourceIndex);
|
|
|
|
ConfigurationPropertySource configurationPropertySource = ConfigurationPropertySource.from(propertySource);
|
|
|
|
ConfigurationPropertySource configurationPropertySource = ConfigurationPropertySource.from(propertySource);
|
|
|
|
boolean ignoreImports = configData.getOptions().contains(ConfigData.Option.IGNORE_IMPORTS);
|
|
|
|
boolean ignoreImports = configData.getOptions().contains(ConfigData.Option.IGNORE_IMPORTS);
|
|
|
|
return new ConfigDataEnvironmentContributor(Kind.UNBOUND_IMPORT, location, resource, propertySource,
|
|
|
|
return new ConfigDataEnvironmentContributor(Kind.UNBOUND_IMPORT, location, resource, profileSpecific,
|
|
|
|
configurationPropertySource, null, ignoreImports, null);
|
|
|
|
propertySource, configurationPropertySource, null, ignoreImports, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Factory method to create an {@link Kind#EMPTY_LOCATION empty location} contributor.
|
|
|
|
* Factory method to create an {@link Kind#EMPTY_LOCATION empty location} contributor.
|
|
|
|
* @param location the location of this contributor
|
|
|
|
* @param location the location of this contributor
|
|
|
|
|
|
|
|
* @param profileSpecific if the contributor is from a profile specific import
|
|
|
|
* @return a new {@link ConfigDataEnvironmentContributor} instance
|
|
|
|
* @return a new {@link ConfigDataEnvironmentContributor} instance
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
static ConfigDataEnvironmentContributor ofEmptyLocation(ConfigDataLocation location) {
|
|
|
|
static ConfigDataEnvironmentContributor ofEmptyLocation(ConfigDataLocation location, boolean profileSpecific) {
|
|
|
|
return new ConfigDataEnvironmentContributor(Kind.EMPTY_LOCATION, location, null, null, null, null, true, null);
|
|
|
|
return new ConfigDataEnvironmentContributor(Kind.EMPTY_LOCATION, location, null, profileSpecific, null, null,
|
|
|
|
|
|
|
|
null, true, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|