Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
e53bef73
Commit
e53bef73
authored
Jan 24, 2018
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename property migrator classes
Rename packages and classes to match the new module name. See gh-11301
parent
1a1a62b7
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
58 additions
and
58 deletions
+58
-58
PropertiesMigrationListener.java
...text/properties/migrator/PropertiesMigrationListener.java
+7
-7
PropertiesMigrationReport.java
...ontext/properties/migrator/PropertiesMigrationReport.java
+21
-21
PropertiesMigrationReporter.java
...text/properties/migrator/PropertiesMigrationReporter.java
+16
-16
PropertyMigration.java
...k/boot/context/properties/migrator/PropertyMigration.java
+4
-4
package-info.java
...mework/boot/context/properties/migrator/package-info.java
+1
-1
spring.factories
...ies-migrator/src/main/resources/META-INF/spring.factories
+1
-1
PropertiesMigrationListenerTests.java
...properties/migrator/PropertiesMigrationListenerTests.java
+3
-3
PropertiesMigrationReporterTests.java
...properties/migrator/PropertiesMigrationReporterTests.java
+5
-5
No files found.
spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/
legacyproperties/LegacyProperties
Listener.java
→
spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/
context/properties/migrator/PropertiesMigration
Listener.java
View file @
e53bef73
...
...
@@ -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
LegacyProperties
Listener
public
class
PropertiesMigration
Listener
implements
ApplicationListener
<
SpringApplicationEvent
>
{
private
static
final
Log
logger
=
LogFactory
.
getLog
(
LegacyProperties
Listener
.
class
);
.
getLog
(
PropertiesMigration
Listener
.
class
);
private
LegacyProperties
Report
report
;
private
PropertiesMigration
Report
report
;
private
boolean
reported
;
...
...
@@ -64,7 +64,7 @@ public class LegacyPropertiesListener
private
void
onApplicationPreparedEvent
(
ApplicationPreparedEvent
event
)
{
ConfigurationMetadataRepository
repository
=
loadRepository
();
LegacyPropertiesReporter
reporter
=
new
LegacyProperties
Reporter
(
repository
,
PropertiesMigrationReporter
reporter
=
new
PropertiesMigration
Reporter
(
repository
,
event
.
getApplicationContext
().
getEnvironment
());
this
.
report
=
reporter
.
getReport
();
}
...
...
spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/
legacyproperties/LegacyProperties
Report.java
→
spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/
context/properties/migrator/PropertiesMigration
Report.java
View file @
e53bef73
...
...
@@ -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
LegacyProperties
Report
{
class
PropertiesMigration
Report
{
private
final
Map
<
String
,
LegacyProperties
>
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
<
String
,
List
<
LegacyProperty
>>
content
=
getContent
(
Map
<
String
,
List
<
PropertyMigration
>>
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
<
String
,
List
<
LegacyProperty
>>
content
=
getContent
(
Map
<
String
,
List
<
PropertyMigration
>>
content
=
getContent
(
LegacyProperties:
:
getUnsupported
);
if
(
content
.
isEmpty
())
{
return
null
;
...
...
@@ -85,8 +85,8 @@ class LegacyPropertiesReport {
return
report
.
toString
();
}
private
Map
<
String
,
List
<
LegacyProperty
>>
getContent
(
Function
<
LegacyProperties
,
List
<
LegacyProperty
>>
extractor
)
{
private
Map
<
String
,
List
<
PropertyMigration
>>
getContent
(
Function
<
LegacyProperties
,
List
<
PropertyMigration
>>
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
<
String
,
List
<
LegacyProperty
>>
content
,
Map
<
String
,
List
<
PropertyMigration
>>
content
,
Function
<
ConfigurationMetadataProperty
,
String
>
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
<
LegacyProperty
>
renamed
,
List
<
LegacyProperty
>
unsupported
)
{
void
add
(
String
name
,
List
<
PropertyMigration
>
renamed
,
List
<
PropertyMigration
>
unsupported
)
{
this
.
content
.
put
(
name
,
new
LegacyProperties
(
renamed
,
unsupported
));
}
private
static
class
LegacyProperties
{
private
final
List
<
LegacyProperty
>
renamed
;
private
final
List
<
PropertyMigration
>
renamed
;
private
final
List
<
LegacyProperty
>
unsupported
;
private
final
List
<
PropertyMigration
>
unsupported
;
LegacyProperties
(
List
<
LegacyProperty
>
renamed
,
List
<
LegacyProperty
>
unsupported
)
{
LegacyProperties
(
List
<
PropertyMigration
>
renamed
,
List
<
PropertyMigration
>
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
<
LegacyProperty
>
getRenamed
()
{
public
List
<
PropertyMigration
>
getRenamed
()
{
return
this
.
renamed
;
}
public
List
<
LegacyProperty
>
getUnsupported
()
{
public
List
<
PropertyMigration
>
getUnsupported
()
{
return
this
.
unsupported
;
}
...
...
spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/
legacyproperties/LegacyProperties
Reporter.java
→
spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/
context/properties/migrator/PropertiesMigration
Reporter.java
View file @
e53bef73
...
...
@@ -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
LegacyProperties
Reporter
{
class
PropertiesMigration
Reporter
{
private
final
Map
<
String
,
ConfigurationMetadataProperty
>
allProperties
;
private
final
ConfigurableEnvironment
environment
;
LegacyProperties
Reporter
(
ConfigurationMetadataRepository
metadataRepository
,
PropertiesMigration
Reporter
(
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
LegacyProperties
Report
getReport
()
{
LegacyPropertiesReport
report
=
new
LegacyProperties
Report
();
Map
<
String
,
List
<
LegacyProperty
>>
properties
=
getMatchingProperties
(
public
PropertiesMigration
Report
getReport
()
{
PropertiesMigrationReport
report
=
new
PropertiesMigration
Report
();
Map
<
String
,
List
<
PropertyMigration
>>
properties
=
getMatchingProperties
(
deprecatedFilter
());
if
(
properties
.
isEmpty
())
{
return
report
;
...
...
@@ -80,10 +80,10 @@ class LegacyPropertiesReporter {
}
private
PropertySource
<?>
mapPropertiesWithReplacement
(
LegacyProperties
Report
report
,
String
name
,
List
<
LegacyProperty
>
properties
)
{
List
<
LegacyProperty
>
renamed
=
new
ArrayList
<>();
List
<
LegacyProperty
>
unsupported
=
new
ArrayList
<>();
PropertiesMigration
Report
report
,
String
name
,
List
<
PropertyMigration
>
properties
)
{
List
<
PropertyMigration
>
renamed
=
new
ArrayList
<>();
List
<
PropertyMigration
>
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
<
String
,
OriginTrackedValue
>
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
<
String
,
List
<
LegacyProperty
>>
getMatchingProperties
(
private
Map
<
String
,
List
<
PropertyMigration
>>
getMatchingProperties
(
Predicate
<
ConfigurationMetadataProperty
>
filter
)
{
MultiValueMap
<
String
,
LegacyProperty
>
result
=
new
LinkedMultiValueMap
<>();
MultiValueMap
<
String
,
PropertyMigration
>
result
=
new
LinkedMultiValueMap
<>();
List
<
ConfigurationMetadataProperty
>
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
));
}
});
});
...
...
spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/
legacyproperties/LegacyProperty
.java
→
spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/
context/properties/migrator/PropertyMigration
.java
View file @
e53bef73
...
...
@@ -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
<
LegacyProperty
>
COMPARATOR
=
Comparator
public
static
final
Comparator
<
PropertyMigration
>
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
;
...
...
spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/
legacyproperties
/package-info.java
→
spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/
context/properties/migrator
/package-info.java
View file @
e53bef73
...
...
@@ -17,4 +17,4 @@
/**
* Support for migrating legacy Spring Boot properties.
*/
package
org
.
springframework
.
boot
.
legacyproperties
;
package
org
.
springframework
.
boot
.
context
.
properties
.
migrator
;
spring-boot-project/spring-boot-properties-migrator/src/main/resources/META-INF/spring.factories
View file @
e53bef73
org.springframework.context.ApplicationListener=\
org.springframework.boot.
legacyproperties.LegacyProperties
Listener
org.springframework.boot.
context.properties.migrator.PropertiesMigration
Listener
spring-boot-project/spring-boot-properties-migrator/src/test/java/org/springframework/boot/
legacyproperties/LegacyProperties
ListenerTests.java
→
spring-boot-project/spring-boot-properties-migrator/src/test/java/org/springframework/boot/
context/properties/migrator/PropertiesMigration
ListenerTests.java
View file @
e53bef73
...
...
@@ -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
LegacyProperties
Listener}.
* Tests for {@link
PropertiesMigration
Listener}.
*
* @author Stephane Nicoll
*/
public
class
LegacyProperties
ListenerTests
{
public
class
PropertiesMigration
ListenerTests
{
@Rule
public
final
OutputCapture
output
=
new
OutputCapture
();
...
...
spring-boot-project/spring-boot-properties-migrator/src/test/java/org/springframework/boot/
legacyproperties/LegacyProperties
ReporterTests.java
→
spring-boot-project/spring-boot-properties-migrator/src/test/java/org/springframework/boot/
context/properties/migrator/PropertiesMigration
ReporterTests.java
View file @
e53bef73
...
...
@@ -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
LegacyProperties
Reporter}.
* Tests for {@link
PropertiesMigration
Reporter}.
*
* @author Stephane Nicoll
*/
public
class
LegacyProperties
ReporterTests
{
public
class
PropertiesMigration
ReporterTests
{
private
ConfigurableEnvironment
environment
=
new
MockEnvironment
();
...
...
@@ -172,9 +172,9 @@ public class LegacyPropertiesReporterTests {
return
createAnalyzer
(
repository
).
getReport
().
getErrorReport
();
}
private
LegacyProperties
Reporter
createAnalyzer
(
private
PropertiesMigration
Reporter
createAnalyzer
(
ConfigurationMetadataRepository
repository
)
{
return
new
LegacyProperties
Reporter
(
repository
,
this
.
environment
);
return
new
PropertiesMigration
Reporter
(
repository
,
this
.
environment
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment