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
20bede21
Commit
20bede21
authored
Nov 28, 2013
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for parent hierarchy in AUtoConfigurationReport
parent
47d079d9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
4 deletions
+47
-4
AutoConfigurationReportEndpoint.java
...oot/actuate/endpoint/AutoConfigurationReportEndpoint.java
+10
-1
AutoConfigurationReport.java
...framework/boot/autoconfigure/AutoConfigurationReport.java
+25
-3
AutoConfigurationReportTests.java
...work/boot/autoconfigure/AutoConfigurationReportTests.java
+12
-0
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/AutoConfigurationReportEndpoint.java
View file @
20bede21
...
@@ -39,6 +39,7 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder;
...
@@ -39,6 +39,7 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder;
*
*
* @author Greg Turnquist
* @author Greg Turnquist
* @author Phillip Webb
* @author Phillip Webb
* @author Dave Syer
*/
*/
@ConfigurationProperties
(
name
=
"endpoints.autoconfig"
,
ignoreUnknownFields
=
false
)
@ConfigurationProperties
(
name
=
"endpoints.autoconfig"
,
ignoreUnknownFields
=
false
)
public
class
AutoConfigurationReportEndpoint
extends
AbstractEndpoint
<
Report
>
{
public
class
AutoConfigurationReportEndpoint
extends
AbstractEndpoint
<
Report
>
{
...
@@ -65,6 +66,8 @@ public class AutoConfigurationReportEndpoint extends AbstractEndpoint<Report> {
...
@@ -65,6 +66,8 @@ public class AutoConfigurationReportEndpoint extends AbstractEndpoint<Report> {
private
MultiValueMap
<
String
,
MessageAndCondition
>
negativeMatches
;
private
MultiValueMap
<
String
,
MessageAndCondition
>
negativeMatches
;
private
Report
parent
;
public
Report
(
AutoConfigurationReport
report
)
{
public
Report
(
AutoConfigurationReport
report
)
{
this
.
positiveMatches
=
new
LinkedMultiValueMap
<
String
,
MessageAndCondition
>();
this
.
positiveMatches
=
new
LinkedMultiValueMap
<
String
,
MessageAndCondition
>();
this
.
negativeMatches
=
new
LinkedMultiValueMap
<
String
,
MessageAndCondition
>();
this
.
negativeMatches
=
new
LinkedMultiValueMap
<
String
,
MessageAndCondition
>();
...
@@ -74,7 +77,9 @@ public class AutoConfigurationReportEndpoint extends AbstractEndpoint<Report> {
...
@@ -74,7 +77,9 @@ public class AutoConfigurationReportEndpoint extends AbstractEndpoint<Report> {
:
this
.
negativeMatches
,
entry
.
getKey
(),
entry
.
getValue
());
:
this
.
negativeMatches
,
entry
.
getKey
(),
entry
.
getValue
());
}
}
if
(
report
.
getParent
()
!=
null
)
{
this
.
parent
=
new
Report
(
report
.
getParent
());
}
}
}
private
void
dunno
(
MultiValueMap
<
String
,
MessageAndCondition
>
map
,
String
source
,
private
void
dunno
(
MultiValueMap
<
String
,
MessageAndCondition
>
map
,
String
source
,
...
@@ -93,6 +98,10 @@ public class AutoConfigurationReportEndpoint extends AbstractEndpoint<Report> {
...
@@ -93,6 +98,10 @@ public class AutoConfigurationReportEndpoint extends AbstractEndpoint<Report> {
return
this
.
negativeMatches
;
return
this
.
negativeMatches
;
}
}
public
Report
getParent
()
{
return
this
.
parent
;
}
}
}
/**
/**
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationReport.java
View file @
20bede21
...
@@ -24,6 +24,7 @@ import java.util.Map;
...
@@ -24,6 +24,7 @@ import java.util.Map;
import
java.util.SortedMap
;
import
java.util.SortedMap
;
import
java.util.TreeMap
;
import
java.util.TreeMap
;
import
org.springframework.beans.factory.BeanFactory
;
import
org.springframework.beans.factory.NoSuchBeanDefinitionException
;
import
org.springframework.beans.factory.NoSuchBeanDefinitionException
;
import
org.springframework.beans.factory.config.ConfigurableListableBeanFactory
;
import
org.springframework.beans.factory.config.ConfigurableListableBeanFactory
;
import
org.springframework.boot.autoconfigure.condition.ConditionOutcome
;
import
org.springframework.boot.autoconfigure.condition.ConditionOutcome
;
...
@@ -42,6 +43,8 @@ public class AutoConfigurationReport {
...
@@ -42,6 +43,8 @@ public class AutoConfigurationReport {
private
final
SortedMap
<
String
,
ConditionAndOutcomes
>
outcomes
=
new
TreeMap
<
String
,
ConditionAndOutcomes
>();
private
final
SortedMap
<
String
,
ConditionAndOutcomes
>
outcomes
=
new
TreeMap
<
String
,
ConditionAndOutcomes
>();
private
AutoConfigurationReport
parent
;
/**
/**
* Private constructor.
* Private constructor.
* @see #get(ConfigurableListableBeanFactory)
* @see #get(ConfigurableListableBeanFactory)
...
@@ -70,6 +73,15 @@ public class AutoConfigurationReport {
...
@@ -70,6 +73,15 @@ public class AutoConfigurationReport {
return
Collections
.
unmodifiableMap
(
this
.
outcomes
);
return
Collections
.
unmodifiableMap
(
this
.
outcomes
);
}
}
/**
* The parent report (from a parent BeanFactory if there is one).
*
* @return the parent report (or null if there isn't one)
*/
public
AutoConfigurationReport
getParent
()
{
return
this
.
parent
;
}
/**
/**
* Obtain a {@link AutoConfigurationReport} for the specified bean factory.
* Obtain a {@link AutoConfigurationReport} for the specified bean factory.
* @param beanFactory the bean factory
* @param beanFactory the bean factory
...
@@ -77,14 +89,24 @@ public class AutoConfigurationReport {
...
@@ -77,14 +89,24 @@ public class AutoConfigurationReport {
*/
*/
public
static
AutoConfigurationReport
get
(
ConfigurableListableBeanFactory
beanFactory
)
{
public
static
AutoConfigurationReport
get
(
ConfigurableListableBeanFactory
beanFactory
)
{
synchronized
(
beanFactory
)
{
synchronized
(
beanFactory
)
{
AutoConfigurationReport
report
;
try
{
try
{
re
turn
beanFactory
.
getBean
(
BEAN_NAME
,
AutoConfigurationReport
.
class
);
re
port
=
beanFactory
.
getBean
(
BEAN_NAME
,
AutoConfigurationReport
.
class
);
}
}
catch
(
NoSuchBeanDefinitionException
ex
)
{
catch
(
NoSuchBeanDefinitionException
ex
)
{
AutoConfigurationReport
report
=
new
AutoConfigurationReport
();
report
=
new
AutoConfigurationReport
();
beanFactory
.
registerSingleton
(
BEAN_NAME
,
report
);
beanFactory
.
registerSingleton
(
BEAN_NAME
,
report
);
return
report
;
}
}
locateParent
(
beanFactory
.
getParentBeanFactory
(),
report
);
return
report
;
}
}
private
static
void
locateParent
(
BeanFactory
beanFactory
,
AutoConfigurationReport
report
)
{
if
(
beanFactory
!=
null
&&
report
.
parent
==
null
&&
beanFactory
.
containsBean
(
BEAN_NAME
))
{
report
.
parent
=
beanFactory
.
getBean
(
BEAN_NAME
,
AutoConfigurationReport
.
class
);
}
}
}
}
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/AutoConfigurationReportTests.java
View file @
20bede21
...
@@ -24,6 +24,7 @@ import org.junit.Test;
...
@@ -24,6 +24,7 @@ import org.junit.Test;
import
org.mockito.Mock
;
import
org.mockito.Mock
;
import
org.mockito.MockitoAnnotations
;
import
org.mockito.MockitoAnnotations
;
import
org.springframework.beans.factory.annotation.Configurable
;
import
org.springframework.beans.factory.annotation.Configurable
;
import
org.springframework.beans.factory.config.ConfigurableListableBeanFactory
;
import
org.springframework.beans.factory.support.DefaultListableBeanFactory
;
import
org.springframework.beans.factory.support.DefaultListableBeanFactory
;
import
org.springframework.boot.autoconfigure.AutoConfigurationReport.ConditionAndOutcome
;
import
org.springframework.boot.autoconfigure.AutoConfigurationReport.ConditionAndOutcome
;
import
org.springframework.boot.autoconfigure.AutoConfigurationReport.ConditionAndOutcomes
;
import
org.springframework.boot.autoconfigure.AutoConfigurationReport.ConditionAndOutcomes
;
...
@@ -84,6 +85,17 @@ public class AutoConfigurationReportTests {
...
@@ -84,6 +85,17 @@ public class AutoConfigurationReportTests {
sameInstance
(
AutoConfigurationReport
.
get
(
this
.
beanFactory
)));
sameInstance
(
AutoConfigurationReport
.
get
(
this
.
beanFactory
)));
}
}
@Test
public
void
parent
()
throws
Exception
{
this
.
beanFactory
.
setParentBeanFactory
(
new
DefaultListableBeanFactory
());
AutoConfigurationReport
.
get
((
ConfigurableListableBeanFactory
)
this
.
beanFactory
.
getParentBeanFactory
());
assertThat
(
this
.
report
,
sameInstance
(
AutoConfigurationReport
.
get
(
this
.
beanFactory
)));
assertThat
(
this
.
report
,
not
(
nullValue
()));
assertThat
(
this
.
report
.
getParent
(),
not
(
nullValue
()));
}
@Test
@Test
public
void
recordConditionEvaluations
()
throws
Exception
{
public
void
recordConditionEvaluations
()
throws
Exception
{
this
.
report
.
recordConditionEvaluation
(
"a"
,
this
.
condition1
,
this
.
outcome1
);
this
.
report
.
recordConditionEvaluation
(
"a"
,
this
.
condition1
,
this
.
outcome1
);
...
...
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