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
90545fb0
Commit
90545fb0
authored
Jan 27, 2018
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update LocalDevToolsAutoConfiguration to use constructor injection
Closes gh-11769
parent
c533cb28
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
20 deletions
+40
-20
LocalDevToolsAutoConfiguration.java
...evtools/autoconfigure/LocalDevToolsAutoConfiguration.java
+40
-20
No files found.
spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/LocalDevToolsAutoConfiguration.java
View file @
90545fb0
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -20,7 +20,6 @@ import java.io.File;
...
@@ -20,7 +20,6 @@ import java.io.File;
import
java.net.URL
;
import
java.net.URL
;
import
java.util.List
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
...
@@ -62,11 +61,11 @@ public class LocalDevToolsAutoConfiguration {
...
@@ -62,11 +61,11 @@ public class LocalDevToolsAutoConfiguration {
@ConditionalOnProperty
(
prefix
=
"spring.devtools.livereload"
,
name
=
"enabled"
,
matchIfMissing
=
true
)
@ConditionalOnProperty
(
prefix
=
"spring.devtools.livereload"
,
name
=
"enabled"
,
matchIfMissing
=
true
)
static
class
LiveReloadConfiguration
{
static
class
LiveReloadConfiguration
{
@Autowired
private
final
DevToolsProperties
properties
;
private
DevToolsProperties
properties
;
@Autowired
(
required
=
false
)
LiveReloadConfiguration
(
DevToolsProperties
properties
)
{
private
LiveReloadServer
liveReloadServer
;
this
.
properties
=
properties
;
}
@Bean
@Bean
@RestartScope
@RestartScope
...
@@ -76,21 +75,16 @@ public class LocalDevToolsAutoConfiguration {
...
@@ -76,21 +75,16 @@ public class LocalDevToolsAutoConfiguration {
Restarter
.
getInstance
().
getThreadFactory
());
Restarter
.
getInstance
().
getThreadFactory
());
}
}
@EventListener
@Bean
public
void
onContextRefreshed
(
ContextRefreshedEvent
event
)
{
public
OptionalLiveReloadServer
optionalLiveReloadServer
(
optionalLiveReloadServer
().
triggerReload
();
LiveReloadServer
liveReloadServer
)
{
}
return
new
OptionalLiveReloadServer
(
liveReloadServer
);
@EventListener
public
void
onClassPathChanged
(
ClassPathChangedEvent
event
)
{
if
(!
event
.
isRestartRequired
())
{
optionalLiveReloadServer
().
triggerReload
();
}
}
}
@Bean
@Bean
public
OptionalLiveReloadServer
optionalLiveReloadServer
()
{
public
LiveReloadServerEventListener
liveReloadServerEventListener
(
return
new
OptionalLiveReloadServer
(
this
.
liveReloadServer
);
OptionalLiveReloadServer
liveReloadServer
)
{
return
new
LiveReloadServerEventListener
(
liveReloadServer
);
}
}
}
}
...
@@ -102,8 +96,11 @@ public class LocalDevToolsAutoConfiguration {
...
@@ -102,8 +96,11 @@ public class LocalDevToolsAutoConfiguration {
@ConditionalOnProperty
(
prefix
=
"spring.devtools.restart"
,
name
=
"enabled"
,
matchIfMissing
=
true
)
@ConditionalOnProperty
(
prefix
=
"spring.devtools.restart"
,
name
=
"enabled"
,
matchIfMissing
=
true
)
static
class
RestartConfiguration
{
static
class
RestartConfiguration
{
@Autowired
private
final
DevToolsProperties
properties
;
private
DevToolsProperties
properties
;
RestartConfiguration
(
DevToolsProperties
properties
)
{
this
.
properties
=
properties
;
}
@EventListener
@EventListener
public
void
onClassPathChanged
(
ClassPathChangedEvent
event
)
{
public
void
onClassPathChanged
(
ClassPathChangedEvent
event
)
{
...
@@ -164,4 +161,27 @@ public class LocalDevToolsAutoConfiguration {
...
@@ -164,4 +161,27 @@ public class LocalDevToolsAutoConfiguration {
}
}
static
class
LiveReloadServerEventListener
{
private
final
OptionalLiveReloadServer
liveReloadServer
;
LiveReloadServerEventListener
(
OptionalLiveReloadServer
liveReloadServer
)
{
this
.
liveReloadServer
=
liveReloadServer
;
}
@EventListener
public
void
onContextRefreshed
(
ContextRefreshedEvent
event
)
{
this
.
liveReloadServer
.
triggerReload
();
}
@EventListener
public
void
onClassPathChanged
(
ClassPathChangedEvent
event
)
{
if
(!
event
.
isRestartRequired
())
{
this
.
liveReloadServer
.
triggerReload
();
}
}
}
}
}
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