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
1528b6c2
Commit
1528b6c2
authored
Sep 28, 2019
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
9568777d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
20 deletions
+28
-20
DevToolsHomePropertiesPostProcessor.java
...oot/devtools/env/DevToolsHomePropertiesPostProcessor.java
+28
-20
No files found.
spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsHomePropertiesPostProcessor.java
View file @
1528b6c2
...
@@ -55,37 +55,45 @@ public class DevToolsHomePropertiesPostProcessor implements EnvironmentPostProce
...
@@ -55,37 +55,45 @@ public class DevToolsHomePropertiesPostProcessor implements EnvironmentPostProce
@Override
@Override
public
void
postProcessEnvironment
(
ConfigurableEnvironment
environment
,
SpringApplication
application
)
{
public
void
postProcessEnvironment
(
ConfigurableEnvironment
environment
,
SpringApplication
application
)
{
if
(
DevToolsEnablementDeducer
.
shouldEnable
(
Thread
.
currentThread
()))
{
if
(
DevToolsEnablementDeducer
.
shouldEnable
(
Thread
.
currentThread
()))
{
List
<
PropertySource
>
propertySources
=
getPropertySources
();
List
<
PropertySource
<?>
>
propertySources
=
getPropertySources
();
if
(
propertySources
.
isEmpty
())
{
if
(
propertySources
.
isEmpty
())
{
addPropertySource
(
LEGACY_FILE_NAME
,
(
file
)
->
"devtools-local"
,
propertySources
);
addPropertySource
(
propertySources
,
LEGACY_FILE_NAME
,
(
file
)
->
"devtools-local"
);
}
}
propertySources
.
forEach
(
(
source
)
->
environment
.
getPropertySources
().
addFirst
(
source
)
);
propertySources
.
forEach
(
environment
.
getPropertySources
()::
addFirst
);
}
}
}
}
private
List
<
PropertySource
>
getPropertySources
()
{
private
List
<
PropertySource
<?>
>
getPropertySources
()
{
List
<
PropertySource
>
propertySources
=
new
ArrayList
<>();
List
<
PropertySource
<?>
>
propertySources
=
new
ArrayList
<>();
for
(
String
fileName
:
FILE_NAMES
)
{
for
(
String
fileName
:
FILE_NAMES
)
{
addPropertySource
(
CONFIG_PATH
+
fileName
,
(
file
)
->
"devtools-local: ["
+
file
.
toURI
()
+
"]"
,
addPropertySource
(
propertySources
,
CONFIG_PATH
+
fileName
,
this
::
getPropertySourceName
);
propertySources
);
}
}
return
propertySources
;
return
propertySources
;
}
}
private
void
addPropertySource
(
String
fileName
,
Function
<
File
,
String
>
propertySourceName
,
private
String
getPropertySourceName
(
File
file
)
{
List
<
PropertySource
>
propertySources
)
{
return
"devtools-local: ["
+
file
.
toURI
()
+
"]"
;
Properties
properties
;
}
private
void
addPropertySource
(
List
<
PropertySource
<?>>
propertySources
,
String
fileName
,
Function
<
File
,
String
>
propertySourceNamer
)
{
File
home
=
getHomeFolder
();
File
home
=
getHomeFolder
();
File
propertyFile
=
(
home
!=
null
)
?
new
File
(
home
,
fileName
)
:
null
;
File
file
=
(
home
!=
null
)
?
new
File
(
home
,
fileName
)
:
null
;
if
(
propertyFile
!=
null
&&
propertyFile
.
exists
()
&&
propertyFile
.
isFile
())
{
FileSystemResource
resource
=
(
file
!=
null
)
?
new
FileSystemResource
(
file
)
:
null
;
FileSystemResource
resource
=
new
FileSystemResource
(
propertyFile
);
if
(
resource
!=
null
&&
resource
.
exists
()
&&
resource
.
isFile
())
{
try
{
addPropertySource
(
propertySources
,
resource
,
propertySourceNamer
);
properties
=
PropertiesLoaderUtils
.
loadProperties
(
resource
);
}
propertySources
.
add
(
new
PropertiesPropertySource
(
propertySourceName
.
apply
(
propertyFile
),
properties
));
}
}
catch
(
IOException
ex
)
{
private
void
addPropertySource
(
List
<
PropertySource
<?>>
propertySources
,
FileSystemResource
resource
,
throw
new
IllegalStateException
(
"Unable to load "
+
fileName
,
ex
);
Function
<
File
,
String
>
propertySourceNamer
)
{
}
try
{
Properties
properties
=
PropertiesLoaderUtils
.
loadProperties
(
resource
);
String
name
=
propertySourceNamer
.
apply
(
resource
.
getFile
());
propertySources
.
add
(
new
PropertiesPropertySource
(
name
,
properties
));
}
catch
(
IOException
ex
)
{
throw
new
IllegalStateException
(
"Unable to load "
+
resource
.
getFilename
(),
ex
);
}
}
}
}
...
...
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