|
|
|
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
|
|
|
|
/* |
|
|
|
|
* Copyright 2002-2019 the original author or authors. |
|
|
|
|
* Copyright 2002-2021 the original author or authors. |
|
|
|
|
* |
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -227,15 +227,15 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
@@ -227,15 +227,15 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
|
|
|
|
|
/** |
|
|
|
|
* Return the set of active profiles as explicitly set through |
|
|
|
|
* {@link #setActiveProfiles} or if the current set of active profiles |
|
|
|
|
* is empty, check for the presence of the {@value #ACTIVE_PROFILES_PROPERTY_NAME} |
|
|
|
|
* property and assign its value to the set of active profiles. |
|
|
|
|
* is empty, check for the presence of {@link #doGetActiveProfilesProperty()} |
|
|
|
|
* and assign its value to the set of active profiles. |
|
|
|
|
* @see #getActiveProfiles() |
|
|
|
|
* @see #ACTIVE_PROFILES_PROPERTY_NAME |
|
|
|
|
* @see #doGetActiveProfilesProperty() |
|
|
|
|
*/ |
|
|
|
|
protected Set<String> doGetActiveProfiles() { |
|
|
|
|
synchronized (this.activeProfiles) { |
|
|
|
|
if (this.activeProfiles.isEmpty()) { |
|
|
|
|
String profiles = getProperty(ACTIVE_PROFILES_PROPERTY_NAME); |
|
|
|
|
String profiles = doGetActiveProfilesProperty(); |
|
|
|
|
if (StringUtils.hasText(profiles)) { |
|
|
|
|
setActiveProfiles(StringUtils.commaDelimitedListToStringArray( |
|
|
|
|
StringUtils.trimAllWhitespace(profiles))); |
|
|
|
@ -245,6 +245,15 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
@@ -245,6 +245,15 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Return the property value for the active profiles. |
|
|
|
|
* @since 5.3.4 |
|
|
|
|
* @see #ACTIVE_PROFILES_PROPERTY_NAME |
|
|
|
|
*/ |
|
|
|
|
protected String doGetActiveProfilesProperty() { |
|
|
|
|
return getProperty(ACTIVE_PROFILES_PROPERTY_NAME); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void setActiveProfiles(String... profiles) { |
|
|
|
|
Assert.notNull(profiles, "Profile array must not be null"); |
|
|
|
@ -282,18 +291,17 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
@@ -282,18 +291,17 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
|
|
|
|
|
* Return the set of default profiles explicitly set via |
|
|
|
|
* {@link #setDefaultProfiles(String...)} or if the current set of default profiles |
|
|
|
|
* consists only of {@linkplain #getReservedDefaultProfiles() reserved default |
|
|
|
|
* profiles}, then check for the presence of the |
|
|
|
|
* {@value #DEFAULT_PROFILES_PROPERTY_NAME} property and assign its value (if any) |
|
|
|
|
* to the set of default profiles. |
|
|
|
|
* profiles}, then check for the presence of {@link #doGetActiveProfilesProperty()} |
|
|
|
|
* and assign its value (if any) to the set of default profiles. |
|
|
|
|
* @see #AbstractEnvironment() |
|
|
|
|
* @see #getDefaultProfiles() |
|
|
|
|
* @see #DEFAULT_PROFILES_PROPERTY_NAME |
|
|
|
|
* @see #getReservedDefaultProfiles() |
|
|
|
|
* @see #doGetDefaultProfilesProperty() |
|
|
|
|
*/ |
|
|
|
|
protected Set<String> doGetDefaultProfiles() { |
|
|
|
|
synchronized (this.defaultProfiles) { |
|
|
|
|
if (this.defaultProfiles.equals(getReservedDefaultProfiles())) { |
|
|
|
|
String profiles = getProperty(DEFAULT_PROFILES_PROPERTY_NAME); |
|
|
|
|
String profiles = doGetDefaultProfilesProperty(); |
|
|
|
|
if (StringUtils.hasText(profiles)) { |
|
|
|
|
setDefaultProfiles(StringUtils.commaDelimitedListToStringArray( |
|
|
|
|
StringUtils.trimAllWhitespace(profiles))); |
|
|
|
@ -303,6 +311,15 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
@@ -303,6 +311,15 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Return the property value for the default profiles. |
|
|
|
|
* @since 5.3.4 |
|
|
|
|
* @see #DEFAULT_PROFILES_PROPERTY_NAME |
|
|
|
|
*/ |
|
|
|
|
protected String doGetDefaultProfilesProperty() { |
|
|
|
|
return getProperty(DEFAULT_PROFILES_PROPERTY_NAME); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Specify the set of profiles to be made active by default if no other profiles |
|
|
|
|
* are explicitly made active through {@link #setActiveProfiles}. |
|
|
|
|