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
33b93210
Commit
33b93210
authored
Feb 14, 2019
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Track condition evaluation per-context when determining delta
Closes gh-15766
parent
1be794fe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
10 deletions
+29
-10
ConditionEvaluationDeltaLoggingListener.java
...utoconfigure/ConditionEvaluationDeltaLoggingListener.java
+29
-10
No files found.
spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/ConditionEvaluationDeltaLoggingListener.java
View file @
33b93210
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
9
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.
...
...
@@ -16,12 +16,16 @@
package
org
.
springframework
.
boot
.
devtools
.
autoconfigure
;
import
java.util.concurrent.ConcurrentHashMap
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport
;
import
org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportMessage
;
import
org.springframework.boot.context.event.ApplicationReadyEvent
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContextAware
;
import
org.springframework.context.ApplicationListener
;
/**
...
...
@@ -31,32 +35,47 @@ import org.springframework.context.ApplicationListener;
* @author Andy Wilkinson
*/
class
ConditionEvaluationDeltaLoggingListener
implements
ApplicationListener
<
ApplicationReadyEvent
>
{
implements
ApplicationListener
<
ApplicationReadyEvent
>,
ApplicationContextAware
{
private
static
final
ConcurrentHashMap
<
String
,
ConditionEvaluationReport
>
previousReports
=
new
ConcurrentHashMap
<>();
private
final
Log
logger
=
LogFactory
.
getLog
(
getClass
());
private
static
final
Log
logger
=
LogFactory
.
getLog
(
ConditionEvaluationDeltaLoggingListener
.
class
);
private
static
ConditionEvaluationReport
previousRepor
t
;
private
volatile
ApplicationContext
contex
t
;
@Override
public
void
onApplicationEvent
(
ApplicationReadyEvent
event
)
{
if
(!
event
.
getApplicationContext
().
equals
(
this
.
context
))
{
return
;
}
ConditionEvaluationReport
report
=
event
.
getApplicationContext
()
.
getBean
(
ConditionEvaluationReport
.
class
);
ConditionEvaluationReport
previousReport
=
previousReports
.
get
(
event
.
getApplicationContext
().
getId
());
if
(
previousReport
!=
null
)
{
ConditionEvaluationReport
delta
=
report
.
getDelta
(
previousReport
);
if
(!
delta
.
getConditionAndOutcomesBySource
().
isEmpty
()
||
!
delta
.
getExclusions
().
isEmpty
()
||
!
delta
.
getUnconditionalClasses
().
isEmpty
())
{
if
(
this
.
logger
.
isInfoEnabled
())
{
this
.
logger
.
info
(
"Condition evaluation delta:"
+
new
ConditionEvaluationReportMessage
(
delta
,
"CONDITION EVALUATION DELTA"
));
if
(
ConditionEvaluationDeltaLoggingListener
.
logger
.
isInfoEnabled
())
{
ConditionEvaluationDeltaLoggingListener
.
logger
.
info
(
"Condition evaluation delta:"
+
new
ConditionEvaluationReportMessage
(
delta
,
"CONDITION EVALUATION DELTA"
));
}
}
else
{
this
.
logger
.
info
(
"Condition evaluation unchanged"
);
ConditionEvaluationDeltaLoggingListener
.
logger
.
info
(
"Condition evaluation unchanged"
);
}
}
previousReport
=
report
;
previousReports
.
put
(
event
.
getApplicationContext
().
getId
(),
report
);
}
@Override
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
{
this
.
context
=
applicationContext
;
}
}
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