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
fbf34e26
Commit
fbf34e26
authored
Mar 30, 2015
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
d07e1814
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
63 additions
and
38 deletions
+63
-38
DataEndpointMBean.java
...ramework/boot/actuate/endpoint/jmx/DataEndpointMBean.java
+13
-0
EndpointMBean.java
...ingframework/boot/actuate/endpoint/jmx/EndpointMBean.java
+13
-3
EndpointMBeanExporter.java
...work/boot/actuate/endpoint/jmx/EndpointMBeanExporter.java
+8
-1
ShutdownEndpointMBean.java
...work/boot/actuate/endpoint/jmx/ShutdownEndpointMBean.java
+15
-2
EndpointMBeanExporterTests.java
...boot/actuate/endpoint/jmx/EndpointMBeanExporterTests.java
+3
-21
EnableAutoConfigurationImportSelector.java
.../autoconfigure/EnableAutoConfigurationImportSelector.java
+1
-2
ConditionEvaluationReport.java
...ot/autoconfigure/condition/ConditionEvaluationReport.java
+10
-9
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/DataEndpointMBean.java
View file @
fbf34e26
...
...
@@ -32,11 +32,24 @@ import com.fasterxml.jackson.databind.ObjectMapper;
@ManagedResource
public
class
DataEndpointMBean
extends
EndpointMBean
{
/**
* Create a new {@link DataEndpointMBean} instance.
* @param beanName the bean name
* @param endpoint the endpoint to wrap
* @deprecated since 1.3 in favor of
* {@link #DataEndpointMBean(String, Endpoint, ObjectMapper)}
*/
@Deprecated
public
DataEndpointMBean
(
String
beanName
,
Endpoint
<?>
endpoint
)
{
super
(
beanName
,
endpoint
);
}
/**
* Create a new {@link DataEndpointMBean} instance.
* @param beanName the bean name
* @param endpoint the endpoint to wrap
* @param objectMapper the {@link ObjectMapper} used to convert the payload
*/
public
DataEndpointMBean
(
String
beanName
,
Endpoint
<?>
endpoint
,
ObjectMapper
objectMapper
)
{
super
(
beanName
,
endpoint
,
objectMapper
);
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/EndpointMBean.java
View file @
fbf34e26
...
...
@@ -40,11 +40,24 @@ public class EndpointMBean {
private
final
ObjectMapper
mapper
;
/**
* Create a new {@link EndpointMBean} instance.
* @param beanName the bean name
* @param endpoint the endpoint to wrap
* @deprecated since 1.3 in favor of
* {@link #EndpointMBean(String, Endpoint, ObjectMapper)}
*/
@Deprecated
public
EndpointMBean
(
String
beanName
,
Endpoint
<?>
endpoint
)
{
this
(
beanName
,
endpoint
,
new
ObjectMapper
());
}
/**
* Create a new {@link EndpointMBean} instance.
* @param beanName the bean name
* @param endpoint the endpoint to wrap
* @param objectMapper the {@link ObjectMapper} used to convert the payload
*/
public
EndpointMBean
(
String
beanName
,
Endpoint
<?>
endpoint
,
ObjectMapper
objectMapper
)
{
Assert
.
notNull
(
beanName
,
"BeanName must not be null"
);
Assert
.
notNull
(
endpoint
,
"Endpoint must not be null"
);
...
...
@@ -71,15 +84,12 @@ public class EndpointMBean {
if
(
result
==
null
)
{
return
null
;
}
if
(
result
instanceof
String
)
{
return
result
;
}
if
(
result
.
getClass
().
isArray
()
||
result
instanceof
List
)
{
return
this
.
mapper
.
convertValue
(
result
,
List
.
class
);
}
return
this
.
mapper
.
convertValue
(
result
,
Map
.
class
);
}
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/EndpointMBeanExporter.java
View file @
fbf34e26
...
...
@@ -96,12 +96,19 @@ public class EndpointMBeanExporter extends MBeanExporter implements SmartLifecyc
private
final
ObjectMapper
objectMapper
;
/**
* Create a new {@link EndpointMBeanExporter} instance.
*/
public
EndpointMBeanExporter
()
{
this
(
null
);
}
/**
* Create a new {@link EndpointMBeanExporter} instance.
* @param objectMapper the object mapper
*/
public
EndpointMBeanExporter
(
ObjectMapper
objectMapper
)
{
this
.
objectMapper
=
objectMapper
==
null
?
new
ObjectMapper
()
:
objectMapper
;
this
.
objectMapper
=
(
objectMapper
==
null
?
new
ObjectMapper
()
:
objectMapper
)
;
setAutodetect
(
false
);
setNamingStrategy
(
this
.
defaultNamingStrategy
);
setAssembler
(
this
.
assembler
);
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/ShutdownEndpointMBean.java
View file @
fbf34e26
...
...
@@ -32,14 +32,27 @@ import com.fasterxml.jackson.databind.ObjectMapper;
@ManagedResource
public
class
ShutdownEndpointMBean
extends
EndpointMBean
{
/**
* Create a new {@link ShutdownEndpointMBean} instance.
* @param beanName the bean name
* @param endpoint the endpoint to wrap
* @deprecated since 1.3 in favor of
* {@link #ShutdownEndpointMBean(String, Endpoint, ObjectMapper)}
*/
@Deprecated
public
ShutdownEndpointMBean
(
String
beanName
,
Endpoint
<?>
endpoint
)
{
super
(
beanName
,
endpoint
);
}
/**
* Create a new {@link ShutdownEndpointMBean} instance.
* @param beanName the bean name
* @param endpoint the endpoint to wrap
* @param objectMapper the {@link ObjectMapper} used to convert the payload
*/
public
ShutdownEndpointMBean
(
String
beanName
,
Endpoint
<?>
endpoint
,
ObjectMapper
m
apper
)
{
super
(
beanName
,
endpoint
,
m
apper
);
ObjectMapper
objectM
apper
)
{
super
(
beanName
,
endpoint
,
objectM
apper
);
}
@ManagedOperation
(
description
=
"Shutdown the ApplicationContext"
)
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/EndpointMBeanExporterTests.java
View file @
fbf34e26
...
...
@@ -73,9 +73,7 @@ public class EndpointMBeanExporterTests {
this
.
context
.
registerBeanDefinition
(
"endpoint1"
,
new
RootBeanDefinition
(
TestEndpoint
.
class
));
this
.
context
.
refresh
();
MBeanExporter
mbeanExporter
=
this
.
context
.
getBean
(
EndpointMBeanExporter
.
class
);
MBeanInfo
mbeanInfo
=
mbeanExporter
.
getServer
().
getMBeanInfo
(
getObjectName
(
"endpoint1"
,
this
.
context
));
assertNotNull
(
mbeanInfo
);
...
...
@@ -93,9 +91,7 @@ public class EndpointMBeanExporterTests {
this
.
context
.
registerBeanDefinition
(
"endpoint2"
,
new
RootBeanDefinition
(
TestEndpoint
.
class
));
this
.
context
.
refresh
();
MBeanExporter
mbeanExporter
=
this
.
context
.
getBean
(
EndpointMBeanExporter
.
class
);
assertNotNull
(
mbeanExporter
.
getServer
().
getMBeanInfo
(
getObjectName
(
"endpoint1"
,
this
.
context
)));
assertNotNull
(
mbeanExporter
.
getServer
().
getMBeanInfo
(
...
...
@@ -113,9 +109,7 @@ public class EndpointMBeanExporterTests {
this
.
context
.
registerBeanDefinition
(
"endpoint1"
,
new
RootBeanDefinition
(
TestEndpoint
.
class
));
this
.
context
.
refresh
();
MBeanExporter
mbeanExporter
=
this
.
context
.
getBean
(
EndpointMBeanExporter
.
class
);
assertNotNull
(
mbeanExporter
.
getServer
().
getMBeanInfo
(
getObjectName
(
"test-domain"
,
"endpoint1"
,
false
,
this
.
context
)));
}
...
...
@@ -132,9 +126,7 @@ public class EndpointMBeanExporterTests {
this
.
context
.
registerBeanDefinition
(
"endpoint1"
,
new
RootBeanDefinition
(
TestEndpoint
.
class
));
this
.
context
.
refresh
();
MBeanExporter
mbeanExporter
=
this
.
context
.
getBean
(
EndpointMBeanExporter
.
class
);
assertNotNull
(
mbeanExporter
.
getServer
().
getMBeanInfo
(
getObjectName
(
"test-domain"
,
"endpoint1"
,
true
,
this
.
context
)));
}
...
...
@@ -156,9 +148,7 @@ public class EndpointMBeanExporterTests {
this
.
context
.
registerBeanDefinition
(
"endpoint1"
,
new
RootBeanDefinition
(
TestEndpoint
.
class
));
this
.
context
.
refresh
();
MBeanExporter
mbeanExporter
=
this
.
context
.
getBean
(
EndpointMBeanExporter
.
class
);
assertNotNull
(
mbeanExporter
.
getServer
().
getMBeanInfo
(
ObjectNameManager
.
getInstance
(
getObjectName
(
"test-domain"
,
"endpoint1"
,
true
,
this
.
context
).
toString
()
...
...
@@ -173,13 +163,10 @@ public class EndpointMBeanExporterTests {
this
.
context
.
registerBeanDefinition
(
"endpoint1"
,
new
RootBeanDefinition
(
TestEndpoint
.
class
));
GenericApplicationContext
parent
=
new
GenericApplicationContext
();
this
.
context
.
setParent
(
parent
);
parent
.
refresh
();
this
.
context
.
refresh
();
MBeanExporter
mbeanExporter
=
this
.
context
.
getBean
(
EndpointMBeanExporter
.
class
);
assertNotNull
(
mbeanExporter
.
getServer
().
getMBeanInfo
(
getObjectName
(
"endpoint1"
,
this
.
context
)));
...
...
@@ -194,12 +181,10 @@ public class EndpointMBeanExporterTests {
this
.
context
.
registerBeanDefinition
(
"endpoint1"
,
new
RootBeanDefinition
(
JsonConversionEndpoint
.
class
));
this
.
context
.
refresh
();
MBeanExporter
mbeanExporter
=
this
.
context
.
getBean
(
EndpointMBeanExporter
.
class
);
Object
response
=
mbeanExporter
.
getServer
().
invoke
(
getObjectName
(
"endpoint1"
,
this
.
context
),
"getData"
,
new
Object
[
0
],
new
String
[
0
]);
assertThat
(
response
,
is
(
instanceOf
(
Map
.
class
)));
assertThat
(((
Map
<?,
?>)
response
).
get
(
"date"
),
is
(
instanceOf
(
Long
.
class
)));
}
...
...
@@ -217,12 +202,10 @@ public class EndpointMBeanExporterTests {
this
.
context
.
registerBeanDefinition
(
"endpoint1"
,
new
RootBeanDefinition
(
JsonConversionEndpoint
.
class
));
this
.
context
.
refresh
();
MBeanExporter
mbeanExporter
=
this
.
context
.
getBean
(
EndpointMBeanExporter
.
class
);
Object
response
=
mbeanExporter
.
getServer
().
invoke
(
getObjectName
(
"endpoint1"
,
this
.
context
),
"getData"
,
new
Object
[
0
],
new
String
[
0
]);
assertThat
(
response
,
is
(
instanceOf
(
Map
.
class
)));
assertThat
(((
Map
<?,
?>)
response
).
get
(
"date"
),
is
(
instanceOf
(
String
.
class
)));
}
...
...
@@ -242,10 +225,8 @@ public class EndpointMBeanExporterTests {
.
getIdentityHexString
(
applicationContext
.
getBean
(
beanKey
))));
}
else
{
return
ObjectNameManager
.
getInstance
(
String
.
format
(
"%s:type=Endpoint,name=%s"
,
domain
,
beanKey
));
}
return
ObjectNameManager
.
getInstance
(
String
.
format
(
"%s:type=Endpoint,name=%s"
,
domain
,
beanKey
));
}
public
static
class
TestEndpoint
extends
AbstractEndpoint
<
String
>
{
...
...
@@ -258,6 +239,7 @@ public class EndpointMBeanExporterTests {
public
String
invoke
()
{
return
"hello world"
;
}
}
public
static
class
JsonConversionEndpoint
extends
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/EnableAutoConfigurationImportSelector.java
View file @
fbf34e26
...
...
@@ -73,8 +73,7 @@ class EnableAutoConfigurationImportSelector implements DeferredImportSelector,
this
.
beanClassLoader
)));
// Remove those specifically disabled
List
<
String
>
excluded
=
new
ArrayList
<
String
>(
Arrays
.
asList
(
attributes
.
getStringArray
(
"exclude"
)));
List
<
String
>
excluded
=
Arrays
.
asList
(
attributes
.
getStringArray
(
"exclude"
));
factories
.
removeAll
(
excluded
);
ConditionEvaluationReport
.
get
(
this
.
beanFactory
).
recordExclusions
(
excluded
);
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionEvaluationReport.java
View file @
fbf34e26
...
...
@@ -16,6 +16,7 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
condition
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Iterator
;
import
java.util.LinkedHashSet
;
...
...
@@ -87,7 +88,7 @@ public class ConditionEvaluationReport {
*/
public
void
recordExclusions
(
List
<
String
>
exclusions
)
{
Assert
.
notNull
(
exclusions
,
"exclusions must not be null"
);
this
.
exclusions
=
exclusions
;
this
.
exclusions
=
new
ArrayList
<
String
>(
exclusions
)
;
}
/**
...
...
@@ -106,14 +107,6 @@ public class ConditionEvaluationReport {
return
Collections
.
unmodifiableMap
(
this
.
outcomes
);
}
/**
* Returns the name of the classes that have been excluded from condition evaluation.
* @return the names of the excluded classes
*/
public
List
<
String
>
getExclusions
()
{
return
Collections
.
unmodifiableList
(
this
.
exclusions
);
}
private
void
addNoMatchOutcomeToAncestors
(
String
source
)
{
String
prefix
=
source
+
"$"
;
for
(
Entry
<
String
,
ConditionAndOutcomes
>
entry
:
this
.
outcomes
.
entrySet
())
{
...
...
@@ -125,6 +118,14 @@ public class ConditionEvaluationReport {
}
}
/**
* Returns the name of the classes that have been excluded from condition evaluation.
* @return the names of the excluded classes
*/
public
List
<
String
>
getExclusions
()
{
return
Collections
.
unmodifiableList
(
this
.
exclusions
);
}
/**
* The parent report (from a parent BeanFactory if there is one).
* @return the parent report (or null if there isn't one)
...
...
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