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
39861bf8
Commit
39861bf8
authored
May 29, 2018
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.0.x'
parents
52b80c77
42598175
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
17 deletions
+54
-17
EndpointDiscoverer.java
.../boot/actuate/endpoint/annotation/EndpointDiscoverer.java
+17
-13
EndpointDiscovererTests.java
.../actuate/endpoint/annotation/EndpointDiscovererTests.java
+34
-0
JmxEndpointDiscovererTests.java
...e/endpoint/jmx/annotation/JmxEndpointDiscovererTests.java
+1
-2
WebEndpointDiscovererTests.java
...e/endpoint/web/annotation/WebEndpointDiscovererTests.java
+2
-2
No files found.
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java
View file @
39861bf8
...
...
@@ -145,17 +145,17 @@ public abstract class EndpointDiscoverer<E extends ExposableEndpoint<O>, O exten
}
private
void
addExtensionBeans
(
Collection
<
EndpointBean
>
endpointBeans
)
{
Map
<
?,
EndpointBean
>
byType
=
endpointBeans
.
stream
()
.
collect
(
Collectors
.
toMap
(
(
bean
)
->
bean
.
getType
()
,
(
bean
)
->
bean
));
Map
<
String
,
EndpointBean
>
byId
=
endpointBeans
.
stream
()
.
collect
(
Collectors
.
toMap
(
EndpointBean:
:
getId
,
(
bean
)
->
bean
));
String
[]
beanNames
=
BeanFactoryUtils
.
beanNamesForAnnotationIncludingAncestors
(
this
.
applicationContext
,
EndpointExtension
.
class
);
for
(
String
beanName
:
beanNames
)
{
ExtensionBean
extensionBean
=
createExtensionBean
(
beanName
);
EndpointBean
endpointBean
=
by
Type
.
get
(
extensionBean
.
getEndpointType
());
EndpointBean
endpointBean
=
by
Id
.
get
(
extensionBean
.
getEndpointId
());
Assert
.
state
(
endpointBean
!=
null
,
()
->
(
"Invalid extension '"
+
extensionBean
.
getBeanName
()
+
"': no endpoint found with
type
'"
+
extensionBean
.
getEndpoint
Type
().
getName
()
+
"'"
));
+
"': no endpoint found with
id
'"
+
extensionBean
.
getEndpoint
Id
()
+
"'"
));
addExtensionBean
(
endpointBean
,
extensionBean
);
}
}
...
...
@@ -488,20 +488,24 @@ public abstract class EndpointDiscoverer<E extends ExposableEndpoint<O>, O exten
private
final
Object
bean
;
private
final
Class
<?>
endpointType
;
private
final
String
endpointId
;
private
final
Class
<?>
filter
;
ExtensionBean
(
String
beanName
,
Object
bean
)
{
this
.
bean
=
bean
;
this
.
beanName
=
beanName
;
AnnotationAttributes
attributes
=
AnnotatedElementUtils
.
getMergedAnnotationAttributes
(
bean
.
getClass
(),
EndpointExtension
.
class
);
this
.
beanName
=
beanName
;
this
.
bean
=
bean
;
this
.
endpointType
=
attributes
.
getClass
(
"endpoint"
);
Class
<?>
endpointType
=
attributes
.
getClass
(
"endpoint"
);
AnnotationAttributes
endpointAttributes
=
AnnotatedElementUtils
.
findMergedAnnotationAttributes
(
endpointType
,
Endpoint
.
class
,
true
,
true
);
Assert
.
state
(
endpointAttributes
!=
null
,
()
->
"Extension "
+
endpointType
.
getName
()
+
" does not specify an endpoint"
);
this
.
endpointId
=
endpointAttributes
.
getString
(
"id"
);
this
.
filter
=
attributes
.
getClass
(
"filter"
);
Assert
.
state
(!
this
.
endpointType
.
equals
(
Void
.
class
),
()
->
"Extension "
+
this
.
endpointType
.
getName
()
+
" does not specify an endpoint"
);
}
public
String
getBeanName
()
{
...
...
@@ -512,8 +516,8 @@ public abstract class EndpointDiscoverer<E extends ExposableEndpoint<O>, O exten
return
this
.
bean
;
}
public
Class
<?>
getEndpointType
()
{
return
this
.
endpoint
Type
;
public
String
getEndpointId
()
{
return
this
.
endpoint
Id
;
}
public
Class
<?>
getFilter
()
{
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscovererTests.java
View file @
39861bf8
...
...
@@ -233,6 +233,25 @@ public class EndpointDiscovererTests {
});
}
@Test
public
void
getEndpointShouldFindParentExtension
()
{
load
(
SubSpecializedEndpointsConfiguration
.
class
,
(
context
)
->
{
SpecializedEndpointDiscoverer
discoverer
=
new
SpecializedEndpointDiscoverer
(
context
);
Map
<
String
,
SpecializedExposableEndpoint
>
endpoints
=
mapEndpoints
(
discoverer
.
getEndpoints
());
Map
<
Method
,
SpecializedOperation
>
operations
=
mapOperations
(
endpoints
.
get
(
"specialized"
));
assertThat
(
operations
).
containsKeys
(
ReflectionUtils
.
findMethod
(
SpecializedTestEndpoint
.
class
,
"getAll"
));
assertThat
(
operations
).
containsKeys
(
ReflectionUtils
.
findMethod
(
SubSpecializedTestEndpoint
.
class
,
"getSpecialOne"
,
String
.
class
));
assertThat
(
operations
).
containsKeys
(
ReflectionUtils
.
findMethod
(
SpecializedExtension
.
class
,
"getSpecial"
));
assertThat
(
operations
).
hasSize
(
3
);
});
}
@Test
public
void
getEndpointsShouldApplyFilters
()
{
load
(
SpecializedEndpointsConfiguration
.
class
,
(
context
)
->
{
...
...
@@ -371,6 +390,12 @@ public class EndpointDiscovererTests {
}
@Import
({
TestEndpoint
.
class
,
SubSpecializedTestEndpoint
.
class
,
SpecializedExtension
.
class
})
static
class
SubSpecializedEndpointsConfiguration
{
}
@Endpoint
(
id
=
"test"
)
static
class
TestEndpoint
{
...
...
@@ -449,6 +474,15 @@ public class EndpointDiscovererTests {
}
static
class
SubSpecializedTestEndpoint
extends
SpecializedTestEndpoint
{
@ReadOperation
public
Object
getSpecialOne
(
@Selector
String
id
)
{
return
null
;
}
}
static
class
TestEndpointDiscoverer
extends
EndpointDiscoverer
<
TestExposableEndpoint
,
TestOperation
>
{
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/annotation/JmxEndpointDiscovererTests.java
View file @
39861bf8
...
...
@@ -117,8 +117,7 @@ public class JmxEndpointDiscovererTests {
this
.
thrown
.
expect
(
IllegalStateException
.
class
);
this
.
thrown
.
expectMessage
(
"Invalid extension 'jmxEndpointDiscovererTests.TestJmxEndpointExtension': "
+
"no endpoint found with type '"
+
TestEndpoint
.
class
.
getName
()
+
"'"
);
+
"no endpoint found with id 'test'"
);
discoverer
.
getEndpoints
();
});
}
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/WebEndpointDiscovererTests.java
View file @
39861bf8
...
...
@@ -82,8 +82,8 @@ public class WebEndpointDiscovererTests {
load
(
TestWebEndpointExtensionConfiguration
.
class
,
(
discoverer
)
->
{
this
.
thrown
.
expect
(
IllegalStateException
.
class
);
this
.
thrown
.
expectMessage
(
"Invalid extension 'endpointExtension': no endpoint found with
type
'"
+
TestEndpoint
.
class
.
getName
()
+
"
'"
);
"Invalid extension 'endpointExtension': no endpoint found with
id
'"
+
"test
'"
);
discoverer
.
getEndpoints
();
});
}
...
...
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