diff --git a/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/legacyproperties/LegacyPropertiesListener.java b/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationListener.java similarity index 88% rename from spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/legacyproperties/LegacyPropertiesListener.java rename to spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationListener.java index c93ff6dd90..25d8df3986 100644 --- a/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/legacyproperties/LegacyPropertiesListener.java +++ b/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationListener.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.legacyproperties; +package org.springframework.boot.context.properties.migrator; import java.io.IOException; import java.io.InputStream; @@ -35,19 +35,19 @@ import org.springframework.core.io.support.PathMatchingResourcePatternResolver; /** * An {@link ApplicationListener} that inspects the {@link ConfigurableEnvironment - * environment} for legacy configuration keys. Automatically renames the keys that - * have a matching replacement and log a report of what was discovered. + * environment} for configuration keys that need to be migrated. Automatically renames the + * keys that have a matching replacement and log a report of what was discovered. * * @author Stephane Nicoll * @since 2.0.0 */ -public class LegacyPropertiesListener +public class PropertiesMigrationListener implements ApplicationListener { private static final Log logger = LogFactory - .getLog(LegacyPropertiesListener.class); + .getLog(PropertiesMigrationListener.class); - private LegacyPropertiesReport report; + private PropertiesMigrationReport report; private boolean reported; @@ -64,7 +64,7 @@ public class LegacyPropertiesListener private void onApplicationPreparedEvent(ApplicationPreparedEvent event) { ConfigurationMetadataRepository repository = loadRepository(); - LegacyPropertiesReporter reporter = new LegacyPropertiesReporter(repository, + PropertiesMigrationReporter reporter = new PropertiesMigrationReporter(repository, event.getApplicationContext().getEnvironment()); this.report = reporter.getReport(); } diff --git a/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/legacyproperties/LegacyPropertiesReport.java b/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReport.java similarity index 78% rename from spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/legacyproperties/LegacyPropertiesReport.java rename to spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReport.java index c16d1ff799..160694124e 100644 --- a/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/legacyproperties/LegacyPropertiesReport.java +++ b/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReport.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.legacyproperties; +package org.springframework.boot.context.properties.migrator; import java.util.ArrayList; import java.util.Collections; @@ -28,21 +28,21 @@ import org.springframework.boot.configurationmetadata.ConfigurationMetadataPrope import org.springframework.util.StringUtils; /** - * Provides a legacy properties report. + * Provides a properties migration report. * * @author Stephane Nicoll */ -class LegacyPropertiesReport { +class PropertiesMigrationReport { private final Map content = new LinkedHashMap<>(); /** - * Return a report for all the legacy properties that were automatically renamed. If - * no such legacy properties were found, return {@code null}. + * Return a report for all the properties that were automatically renamed. If no such + * properties were found, return {@code null}. * @return a report with the configurations keys that should be renamed */ public String getWarningReport() { - Map> content = getContent( + Map> content = getContent( LegacyProperties::getRenamed); if (content.isEmpty()) { return null; @@ -61,12 +61,12 @@ class LegacyPropertiesReport { } /** - * Return a report for all the legacy properties that are no longer supported. If no - * such legacy properties were found, return {@code null}. + * Return a report for all the properties that are no longer supported. If no such + * properties were found, return {@code null}. * @return a report with the configurations keys that are no longer supported */ public String getErrorReport() { - Map> content = getContent( + Map> content = getContent( LegacyProperties::getUnsupported); if (content.isEmpty()) { return null; @@ -85,8 +85,8 @@ class LegacyPropertiesReport { return report.toString(); } - private Map> getContent( - Function> extractor) { + private Map> getContent( + Function> extractor) { return this.content.entrySet().stream() .filter((entry) -> !extractor.apply(entry.getValue()).isEmpty()) .collect(Collectors.toMap(Map.Entry::getKey, @@ -94,11 +94,11 @@ class LegacyPropertiesReport { } private void append(StringBuilder report, - Map> content, + Map> content, Function deprecationMessage) { content.forEach((name, properties) -> { report.append(String.format("Property source '%s':%n", name)); - properties.sort(LegacyProperty.COMPARATOR); + properties.sort(PropertyMigration.COMPARATOR); properties.forEach((property) -> { ConfigurationMetadataProperty metadata = property.getMetadata(); report.append(String.format("\tKey: %s%n", metadata.getId())); @@ -119,19 +119,19 @@ class LegacyPropertiesReport { * @param renamed the properties that were renamed * @param unsupported the properties that are no longer supported */ - void add(String name, List renamed, - List unsupported) { + void add(String name, List renamed, + List unsupported) { this.content.put(name, new LegacyProperties(renamed, unsupported)); } private static class LegacyProperties { - private final List renamed; + private final List renamed; - private final List unsupported; + private final List unsupported; - LegacyProperties(List renamed, - List unsupported) { + LegacyProperties(List renamed, + List unsupported) { this.renamed = asNewList(renamed); this.unsupported = asNewList(unsupported); } @@ -140,11 +140,11 @@ class LegacyPropertiesReport { return (source == null ? Collections.emptyList() : new ArrayList<>(source)); } - public List getRenamed() { + public List getRenamed() { return this.renamed; } - public List getUnsupported() { + public List getUnsupported() { return this.unsupported; } diff --git a/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/legacyproperties/LegacyPropertiesReporter.java b/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReporter.java similarity index 85% rename from spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/legacyproperties/LegacyPropertiesReporter.java rename to spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReporter.java index b51ef148bc..dc365a4521 100644 --- a/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/legacyproperties/LegacyPropertiesReporter.java +++ b/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReporter.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.legacyproperties; +package org.springframework.boot.context.properties.migrator; import java.util.ArrayList; import java.util.Collections; @@ -40,17 +40,17 @@ import org.springframework.util.MultiValueMap; import org.springframework.util.StringUtils; /** - * Report on {@link LegacyProperty legacy properties}. + * Report on {@link PropertyMigration legacy properties}. * * @author Stephane Nicoll */ -class LegacyPropertiesReporter { +class PropertiesMigrationReporter { private final Map allProperties; private final ConfigurableEnvironment environment; - LegacyPropertiesReporter(ConfigurationMetadataRepository metadataRepository, + PropertiesMigrationReporter(ConfigurationMetadataRepository metadataRepository, ConfigurableEnvironment environment) { this.allProperties = Collections .unmodifiableMap(metadataRepository.getAllProperties()); @@ -62,9 +62,9 @@ class LegacyPropertiesReporter { * legacy properties if a replacement exists. * @return the analysis */ - public LegacyPropertiesReport getReport() { - LegacyPropertiesReport report = new LegacyPropertiesReport(); - Map> properties = getMatchingProperties( + public PropertiesMigrationReport getReport() { + PropertiesMigrationReport report = new PropertiesMigrationReport(); + Map> properties = getMatchingProperties( deprecatedFilter()); if (properties.isEmpty()) { return report; @@ -80,10 +80,10 @@ class LegacyPropertiesReporter { } private PropertySource mapPropertiesWithReplacement( - LegacyPropertiesReport report, String name, - List properties) { - List renamed = new ArrayList<>(); - List unsupported = new ArrayList<>(); + PropertiesMigrationReport report, String name, + List properties) { + List renamed = new ArrayList<>(); + List unsupported = new ArrayList<>(); properties.forEach((property) -> (isRenamed(property) ? renamed : unsupported).add(property)); report.add(name, renamed, unsupported); @@ -92,7 +92,7 @@ class LegacyPropertiesReporter { } String target = "migrate-" + name; Map content = new LinkedHashMap<>(); - for (LegacyProperty candidate : renamed) { + for (PropertyMigration candidate : renamed) { OriginTrackedValue value = OriginTrackedValue.of( candidate.getProperty().getValue(), candidate.getProperty().getOrigin()); @@ -101,7 +101,7 @@ class LegacyPropertiesReporter { return new OriginTrackedMapPropertySource(target, content); } - private boolean isRenamed(LegacyProperty property) { + private boolean isRenamed(PropertyMigration property) { ConfigurationMetadataProperty metadata = property.getMetadata(); String replacementId = metadata.getDeprecation().getReplacement(); if (StringUtils.hasText(replacementId)) { @@ -127,9 +127,9 @@ class LegacyPropertiesReporter { return null; } - private Map> getMatchingProperties( + private Map> getMatchingProperties( Predicate filter) { - MultiValueMap result = new LinkedMultiValueMap<>(); + MultiValueMap result = new LinkedMultiValueMap<>(); List candidates = this.allProperties.values() .stream().filter(filter).collect(Collectors.toList()); getPropertySourcesAsMap().forEach((name, source) -> { @@ -139,7 +139,7 @@ class LegacyPropertiesReporter { ConfigurationPropertyName.of(metadata.getId())); if (configurationProperty != null) { result.add(name, - new LegacyProperty(metadata, configurationProperty)); + new PropertyMigration(metadata, configurationProperty)); } }); }); diff --git a/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/legacyproperties/LegacyProperty.java b/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertyMigration.java similarity index 89% rename from spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/legacyproperties/LegacyProperty.java rename to spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertyMigration.java index 6a806be413..9a2ca673d6 100644 --- a/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/legacyproperties/LegacyProperty.java +++ b/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertyMigration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.legacyproperties; +package org.springframework.boot.context.properties.migrator; import java.util.Comparator; @@ -28,9 +28,9 @@ import org.springframework.boot.origin.TextResourceOrigin; * * @author Stephane Nicoll */ -class LegacyProperty { +class PropertyMigration { - public static final Comparator COMPARATOR = Comparator + public static final Comparator COMPARATOR = Comparator .comparing((property) -> property.getMetadata().getId()); private final ConfigurationMetadataProperty metadata; @@ -39,7 +39,7 @@ class LegacyProperty { private final Integer lineNumber; - LegacyProperty(ConfigurationMetadataProperty metadata, + PropertyMigration(ConfigurationMetadataProperty metadata, ConfigurationProperty property) { this.metadata = metadata; this.property = property; diff --git a/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/legacyproperties/package-info.java b/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/package-info.java similarity index 91% rename from spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/legacyproperties/package-info.java rename to spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/package-info.java index 96e7a6bc22..a17ded0c95 100644 --- a/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/legacyproperties/package-info.java +++ b/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/package-info.java @@ -17,4 +17,4 @@ /** * Support for migrating legacy Spring Boot properties. */ -package org.springframework.boot.legacyproperties; +package org.springframework.boot.context.properties.migrator; diff --git a/spring-boot-project/spring-boot-properties-migrator/src/main/resources/META-INF/spring.factories b/spring-boot-project/spring-boot-properties-migrator/src/main/resources/META-INF/spring.factories index 3023d42112..34a7377988 100644 --- a/spring-boot-project/spring-boot-properties-migrator/src/main/resources/META-INF/spring.factories +++ b/spring-boot-project/spring-boot-properties-migrator/src/main/resources/META-INF/spring.factories @@ -1,2 +1,2 @@ org.springframework.context.ApplicationListener=\ -org.springframework.boot.legacyproperties.LegacyPropertiesListener +org.springframework.boot.context.properties.migrator.PropertiesMigrationListener diff --git a/spring-boot-project/spring-boot-properties-migrator/src/test/java/org/springframework/boot/legacyproperties/LegacyPropertiesListenerTests.java b/spring-boot-project/spring-boot-properties-migrator/src/test/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationListenerTests.java similarity index 91% rename from spring-boot-project/spring-boot-properties-migrator/src/test/java/org/springframework/boot/legacyproperties/LegacyPropertiesListenerTests.java rename to spring-boot-project/spring-boot-properties-migrator/src/test/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationListenerTests.java index 76e6692be5..39d125d3bf 100644 --- a/spring-boot-project/spring-boot-properties-migrator/src/test/java/org/springframework/boot/legacyproperties/LegacyPropertiesListenerTests.java +++ b/spring-boot-project/spring-boot-properties-migrator/src/test/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationListenerTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.legacyproperties; +package org.springframework.boot.context.properties.migrator; import org.junit.After; import org.junit.Rule; @@ -28,11 +28,11 @@ import org.springframework.context.annotation.Configuration; import static org.assertj.core.api.Assertions.assertThat; /** - * Tests for {@link LegacyPropertiesListener}. + * Tests for {@link PropertiesMigrationListener}. * * @author Stephane Nicoll */ -public class LegacyPropertiesListenerTests { +public class PropertiesMigrationListenerTests { @Rule public final OutputCapture output = new OutputCapture(); diff --git a/spring-boot-project/spring-boot-properties-migrator/src/test/java/org/springframework/boot/legacyproperties/LegacyPropertiesReporterTests.java b/spring-boot-project/spring-boot-properties-migrator/src/test/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReporterTests.java similarity index 95% rename from spring-boot-project/spring-boot-properties-migrator/src/test/java/org/springframework/boot/legacyproperties/LegacyPropertiesReporterTests.java rename to spring-boot-project/spring-boot-properties-migrator/src/test/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReporterTests.java index f576975991..0367de21b3 100644 --- a/spring-boot-project/spring-boot-properties-migrator/src/test/java/org/springframework/boot/legacyproperties/LegacyPropertiesReporterTests.java +++ b/spring-boot-project/spring-boot-properties-migrator/src/test/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReporterTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.legacyproperties; +package org.springframework.boot.context.properties.migrator; import java.io.IOException; import java.util.ArrayList; @@ -39,11 +39,11 @@ import org.springframework.mock.env.MockEnvironment; import static org.assertj.core.api.Assertions.assertThat; /** - * Tests for {@link LegacyPropertiesReporter}. + * Tests for {@link PropertiesMigrationReporter}. * * @author Stephane Nicoll */ -public class LegacyPropertiesReporterTests { +public class PropertiesMigrationReporterTests { private ConfigurableEnvironment environment = new MockEnvironment(); @@ -172,9 +172,9 @@ public class LegacyPropertiesReporterTests { return createAnalyzer(repository).getReport().getErrorReport(); } - private LegacyPropertiesReporter createAnalyzer( + private PropertiesMigrationReporter createAnalyzer( ConfigurationMetadataRepository repository) { - return new LegacyPropertiesReporter(repository, this.environment); + return new PropertiesMigrationReporter(repository, this.environment); } }