merge method

  1. @override
void merge(
  1. ConfigurableEnvironment parent
)
override

Merges another ConfigurableEnvironment into this one.

Property sources, profiles, and system accessors may be merged based on implementation logic.

This is useful when bootstrapping from parent contexts or templates.

Implementation

@override
void merge(ConfigurableEnvironment parent) {
	for (PropertySource<dynamic> ps in parent.getPropertySources()) {
		if (!_propertySources.containsName(ps.getName())) {
			_propertySources.addLast(ps);
		}
	}

	List<String> parentActiveProfiles = parent.getActiveProfiles();
	if (parentActiveProfiles.isNotEmpty) {
		synchronized(_activeProfiles, () {
			_activeProfiles.addAll(parentActiveProfiles);
		});
	}

	List<String> parentDefaultProfiles = parent.getDefaultProfiles();
	if (parentDefaultProfiles.isNotEmpty) {
		synchronized(_defaultProfiles, () {
			_defaultProfiles.remove(RESERVED_DEFAULT_PROFILE_NAME);
			_defaultProfiles.addAll(parentDefaultProfiles);
		});
	}
}