Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-boot-admin
Project
Overview
Details
Activity
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
openSource
spring-boot-admin
Commits
378348b9
Commit
378348b9
authored
Sep 22, 2017
by
Johannes Edmeier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove class level @RequestMapping
... to prevent registration of the controller from standard spring mechanisms
parent
8a497e65
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
23 deletions
+25
-23
NotificationFilterController.java
...erver/notify/filter/web/NotificationFilterController.java
+6
-6
ApplicationsController.java
...centric/boot/admin/server/web/ApplicationsController.java
+5
-7
InstancesController.java
...odecentric/boot/admin/server/web/InstancesController.java
+14
-10
No files found.
spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/notify/filter/web/NotificationFilterController.java
View file @
378348b9
...
...
@@ -26,9 +26,10 @@ import java.util.Collections;
import
java.util.Map
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.util.MimeTypeUtils
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
...
...
@@ -41,7 +42,6 @@ import static org.springframework.util.StringUtils.hasText;
*/
@AdminController
@ResponseBody
@RequestMapping
(
"/notifications/filters"
)
public
class
NotificationFilterController
{
private
FilteringNotifier
filteringNotifier
;
...
...
@@ -49,12 +49,12 @@ public class NotificationFilterController {
this
.
filteringNotifier
=
filteringNotifier
;
}
@
RequestMapping
(
method
=
{
RequestMethod
.
GET
}
,
produces
=
MimeTypeUtils
.
APPLICATION_JSON_VALUE
)
@
GetMapping
(
path
=
"/notifications/filters"
,
produces
=
MimeTypeUtils
.
APPLICATION_JSON_VALUE
)
public
Map
<
String
,
NotificationFilter
>
getFilters
()
{
return
filteringNotifier
.
getNotificationFilters
();
}
@
RequestMapping
(
method
=
{
RequestMethod
.
POST
}
,
produces
=
MimeTypeUtils
.
APPLICATION_JSON_VALUE
)
@
PostMapping
(
path
=
"/notifications/filters"
,
produces
=
MimeTypeUtils
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
addFilter
(
@RequestParam
(
name
=
"id"
,
required
=
false
)
String
id
,
@RequestParam
(
name
=
"name"
,
required
=
false
)
String
name
,
@RequestParam
(
name
=
"ttl"
,
required
=
false
,
defaultValue
=
"-1"
)
long
ttl
)
{
...
...
@@ -67,7 +67,7 @@ public class NotificationFilterController {
}
}
@
RequestMapping
(
path
=
"/{id}"
,
method
=
{
RequestMethod
.
DELETE
}
)
@
DeleteMapping
(
path
=
"/notifications/filters/{id}"
)
public
ResponseEntity
<?>
deleteFilter
(
@PathVariable
(
"id"
)
String
id
)
{
NotificationFilter
deleted
=
filteringNotifier
.
removeFilter
(
id
);
if
(
deleted
!=
null
)
{
...
...
spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/web/ApplicationsController.java
View file @
378348b9
...
...
@@ -37,7 +37,6 @@ import org.springframework.util.StringUtils;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
static
java
.
util
.
Comparator
.
comparing
;
...
...
@@ -50,22 +49,21 @@ import static java.util.stream.Collectors.toMap;
*/
@AdminController
@ResponseBody
@RequestMapping
(
"/applications"
)
public
class
ApplicationsController
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
ApplicationsController
.
class
);
private
final
InstanceRegistry
registry
;
private
final
InstanceEventPublisher
eventPublisher
;
private
static
final
ServerSentEvent
<
Application
>
PING
=
ServerSentEvent
.<
Application
>
builder
().
comment
(
"ping"
)
.
build
();
private
static
final
Flux
<
ServerSentEvent
<
Application
>>
PING_FLUX
=
Flux
.
interval
(
Duration
.
ofSeconds
(
10L
))
.
map
(
tick
->
PING
);
private
static
final
Flux
<
ServerSentEvent
<
Application
>>
PING_FLUX
=
Flux
.
interval
(
Duration
.
ZERO
,
Duration
.
ofSeconds
(
10L
))
.
map
(
tick
->
PING
);
public
ApplicationsController
(
InstanceRegistry
registry
,
InstanceEventPublisher
eventPublisher
)
{
this
.
registry
=
registry
;
this
.
eventPublisher
=
eventPublisher
;
}
@GetMapping
(
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@GetMapping
(
p
ath
=
"/applications"
,
p
roduces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
Flux
<
Application
>
applications
()
{
return
registry
.
getInstances
()
.
filter
(
Instance:
:
isRegistered
)
...
...
@@ -73,7 +71,7 @@ public class ApplicationsController {
.
flatMap
(
grouped
->
toApplication
(
grouped
.
key
(),
grouped
));
}
@GetMapping
(
produces
=
MediaType
.
TEXT_EVENT_STREAM_VALUE
)
@GetMapping
(
p
ath
=
"/applications"
,
p
roduces
=
MediaType
.
TEXT_EVENT_STREAM_VALUE
)
public
Flux
<
ServerSentEvent
<
Application
>>
applicationsStream
()
{
return
Flux
.
from
(
eventPublisher
)
.
flatMap
(
event
->
registry
.
getInstance
(
event
.
getInstance
()))
...
...
@@ -83,7 +81,7 @@ public class ApplicationsController {
.
mergeWith
(
PING_FLUX
);
}
@DeleteMapping
(
path
=
"/{name}"
)
@DeleteMapping
(
path
=
"/
applications/
{name}"
)
public
Mono
<
ResponseEntity
<
Void
>>
unregister
(
@PathVariable
(
"name"
)
String
name
)
{
log
.
debug
(
"Unregister application with name '{}'"
,
name
);
return
registry
.
getInstancesByApplication
(
name
)
...
...
spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/web/InstancesController.java
View file @
378348b9
...
...
@@ -25,18 +25,19 @@ import reactor.core.publisher.Flux;
import
reactor.core.publisher.Mono
;
import
java.net.URI
;
import
java.time.Duration
;
import
java.util.Collections
;
import
java.util.Map
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.codec.ServerSentEvent
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.util.UriComponentsBuilder
;
...
...
@@ -46,11 +47,14 @@ import org.springframework.web.util.UriComponentsBuilder;
*/
@AdminController
@ResponseBody
@RequestMapping
(
"/instances"
)
public
class
InstancesController
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
InstancesController
.
class
);
private
final
InstanceRegistry
registry
;
private
final
InstanceEventStore
eventStore
;
private
static
final
ServerSentEvent
<
InstanceEvent
>
PING
=
ServerSentEvent
.<
InstanceEvent
>
builder
().
comment
(
"ping"
)
.
build
();
private
static
final
Flux
<
ServerSentEvent
<
InstanceEvent
>>
PING_FLUX
=
Flux
.
interval
(
Duration
.
ZERO
,
Duration
.
ofSeconds
(
10L
)).
map
(
tick
->
PING
);
public
InstancesController
(
InstanceRegistry
registry
,
InstanceEventStore
eventStore
)
{
this
.
registry
=
registry
;
...
...
@@ -63,7 +67,7 @@ public class InstancesController {
* @param registration registration info
* @return The registered instance id;
*/
@PostMapping
(
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
@PostMapping
(
path
=
"/instances"
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
Mono
<
ResponseEntity
<
Map
<
String
,
InstanceId
>>>
register
(
@RequestBody
Registration
registration
,
UriComponentsBuilder
builder
)
{
Registration
withSource
=
Registration
.
copyOf
(
registration
).
source
(
"http-api"
).
build
();
...
...
@@ -80,7 +84,7 @@ public class InstancesController {
* @param name the name to search for
* @return application list
*/
@GetMapping
(
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@GetMapping
(
p
ath
=
"/instances"
,
p
roduces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
Flux
<
Instance
>
instances
(
@RequestParam
(
value
=
"name"
,
required
=
false
)
String
name
)
{
LOGGER
.
debug
(
"Deliver registered instances with name={}"
,
name
);
if
(
name
==
null
||
name
.
isEmpty
())
{
...
...
@@ -96,7 +100,7 @@ public class InstancesController {
* @param id The application identifier.
* @return The registered application.
*/
@GetMapping
(
path
=
"/{id}"
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@GetMapping
(
path
=
"/
instances/
{id}"
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
Mono
<
ResponseEntity
<
Instance
>>
instance
(
@PathVariable
String
id
)
{
LOGGER
.
debug
(
"Deliver registered instance with ID '{}'"
,
id
);
return
registry
.
getInstance
(
InstanceId
.
of
(
id
))
...
...
@@ -110,7 +114,7 @@ public class InstancesController {
*
* @param id The instance id.
*/
@DeleteMapping
(
path
=
"/{id}"
)
@DeleteMapping
(
path
=
"/
instances/
{id}"
)
public
Mono
<
ResponseEntity
<
Void
>>
unregister
(
@PathVariable
String
id
)
{
LOGGER
.
debug
(
"Unregister instance with ID '{}'"
,
id
);
return
registry
.
deregister
(
InstanceId
.
of
(
id
))
...
...
@@ -118,14 +122,14 @@ public class InstancesController {
.
defaultIfEmpty
(
ResponseEntity
.
notFound
().
build
());
}
@GetMapping
(
path
=
"/events"
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@GetMapping
(
path
=
"/
instances/
events"
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
Flux
<
InstanceEvent
>
events
()
{
return
eventStore
.
findAll
();
}
@GetMapping
(
path
=
"/
events"
,
produces
=
MediaType
.
APPLICATION_STREAM_JSON
_VALUE
)
public
Flux
<
?
extends
InstanceEvent
>
eventStream
()
{
return
Flux
.
from
(
eventStore
);
@GetMapping
(
path
=
"/
instances/events"
,
produces
=
MediaType
.
TEXT_EVENT_STREAM
_VALUE
)
public
Flux
<
ServerSentEvent
<
InstanceEvent
>
>
eventStream
()
{
return
Flux
.
from
(
eventStore
)
.
map
(
event
->
ServerSentEvent
.
builder
(
event
).
build
()).
mergeWith
(
PING_FLUX
)
;
}
}
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