|
|
|
@ -22,7 +22,6 @@ import java.util.Collections;
|
|
|
|
|
import java.util.LinkedHashSet;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
import java.util.function.Supplier;
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
|
|
|
|
|
@ -107,6 +106,10 @@ class ConfigDataEnvironment {
|
|
|
|
|
|
|
|
|
|
private static final Bindable<List<String>> STRING_LIST = Bindable.listOf(String.class);
|
|
|
|
|
|
|
|
|
|
private static final BinderOption[] ALLOW_INACTIVE_BINDING = {};
|
|
|
|
|
|
|
|
|
|
private static final BinderOption[] DENY_INACTIVE_BINDING = { BinderOption.FAIL_ON_BIND_TO_INACTIVE_SOURCE };
|
|
|
|
|
|
|
|
|
|
private final DeferredLogFactory logFactory;
|
|
|
|
|
|
|
|
|
|
private final Log logger;
|
|
|
|
@ -222,25 +225,22 @@ class ConfigDataEnvironment {
|
|
|
|
|
void processAndApply() {
|
|
|
|
|
ConfigDataImporter importer = new ConfigDataImporter(this.logFactory, this.notFoundAction, this.resolvers,
|
|
|
|
|
this.loaders);
|
|
|
|
|
registerBootstrapBinder(() -> this.contributors.getBinder(null, BinderOption.FAIL_ON_BIND_TO_INACTIVE_SOURCE));
|
|
|
|
|
registerBootstrapBinder(this.contributors, null, DENY_INACTIVE_BINDING);
|
|
|
|
|
ConfigDataEnvironmentContributors contributors = processInitial(this.contributors, importer);
|
|
|
|
|
Binder initialBinder = contributors.getBinder(null, BinderOption.FAIL_ON_BIND_TO_INACTIVE_SOURCE);
|
|
|
|
|
registerBootstrapBinder(() -> initialBinder);
|
|
|
|
|
ConfigDataActivationContext activationContext = createActivationContext(initialBinder);
|
|
|
|
|
ConfigDataActivationContext activationContext = createActivationContext(
|
|
|
|
|
contributors.getBinder(null, BinderOption.FAIL_ON_BIND_TO_INACTIVE_SOURCE));
|
|
|
|
|
contributors = processWithoutProfiles(contributors, importer, activationContext);
|
|
|
|
|
activationContext = withProfiles(contributors, activationContext);
|
|
|
|
|
contributors = processWithProfiles(contributors, importer, activationContext);
|
|
|
|
|
applyToEnvironment(contributors, activationContext);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void registerBootstrapBinder(Supplier<Binder> supplier) {
|
|
|
|
|
this.bootstrapContext.register(Binder.class, InstanceSupplier.from(supplier).withScope(Scope.PROTOTYPE));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ConfigDataEnvironmentContributors processInitial(ConfigDataEnvironmentContributors contributors,
|
|
|
|
|
ConfigDataImporter importer) {
|
|
|
|
|
this.logger.trace("Processing initial config data environment contributors without activation context");
|
|
|
|
|
return contributors.withProcessedImports(importer, null);
|
|
|
|
|
contributors = contributors.withProcessedImports(importer, null);
|
|
|
|
|
registerBootstrapBinder(contributors, null, DENY_INACTIVE_BINDING);
|
|
|
|
|
return contributors;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ConfigDataActivationContext createActivationContext(Binder initialBinder) {
|
|
|
|
@ -259,7 +259,9 @@ class ConfigDataEnvironment {
|
|
|
|
|
private ConfigDataEnvironmentContributors processWithoutProfiles(ConfigDataEnvironmentContributors contributors,
|
|
|
|
|
ConfigDataImporter importer, ConfigDataActivationContext activationContext) {
|
|
|
|
|
this.logger.trace("Processing config data environment contributors with initial activation context");
|
|
|
|
|
return contributors.withProcessedImports(importer, activationContext);
|
|
|
|
|
contributors = contributors.withProcessedImports(importer, activationContext);
|
|
|
|
|
registerBootstrapBinder(contributors, activationContext, DENY_INACTIVE_BINDING);
|
|
|
|
|
return contributors;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ConfigDataActivationContext withProfiles(ConfigDataEnvironmentContributors contributors,
|
|
|
|
@ -304,7 +306,15 @@ class ConfigDataEnvironment {
|
|
|
|
|
private ConfigDataEnvironmentContributors processWithProfiles(ConfigDataEnvironmentContributors contributors,
|
|
|
|
|
ConfigDataImporter importer, ConfigDataActivationContext activationContext) {
|
|
|
|
|
this.logger.trace("Processing config data environment contributors with profile activation context");
|
|
|
|
|
return contributors.withProcessedImports(importer, activationContext);
|
|
|
|
|
contributors = contributors.withProcessedImports(importer, activationContext);
|
|
|
|
|
registerBootstrapBinder(contributors, activationContext, ALLOW_INACTIVE_BINDING);
|
|
|
|
|
return contributors;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void registerBootstrapBinder(ConfigDataEnvironmentContributors contributors,
|
|
|
|
|
ConfigDataActivationContext activationContext, BinderOption... binderOptions) {
|
|
|
|
|
this.bootstrapContext.register(Binder.class, InstanceSupplier
|
|
|
|
|
.from(() -> contributors.getBinder(activationContext, binderOptions)).withScope(Scope.PROTOTYPE));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void applyToEnvironment(ConfigDataEnvironmentContributors contributors,
|
|
|
|
|