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
Hide 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;
...
@@ -26,9 +26,10 @@ import java.util.Collections;
import
java.util.Map
;
import
java.util.Map
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.util.MimeTypeUtils
;
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.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ResponseBody
;
...
@@ -41,7 +42,6 @@ import static org.springframework.util.StringUtils.hasText;
...
@@ -41,7 +42,6 @@ import static org.springframework.util.StringUtils.hasText;
*/
*/
@AdminController
@AdminController
@ResponseBody
@ResponseBody
@RequestMapping
(
"/notifications/filters"
)
public
class
NotificationFilterController
{
public
class
NotificationFilterController
{
private
FilteringNotifier
filteringNotifier
;
private
FilteringNotifier
filteringNotifier
;
...
@@ -49,12 +49,12 @@ public class NotificationFilterController {
...
@@ -49,12 +49,12 @@ public class NotificationFilterController {
this
.
filteringNotifier
=
filteringNotifier
;
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
()
{
public
Map
<
String
,
NotificationFilter
>
getFilters
()
{
return
filteringNotifier
.
getNotificationFilters
();
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
,
public
ResponseEntity
<?>
addFilter
(
@RequestParam
(
name
=
"id"
,
required
=
false
)
String
id
,
@RequestParam
(
name
=
"name"
,
required
=
false
)
String
name
,
@RequestParam
(
name
=
"name"
,
required
=
false
)
String
name
,
@RequestParam
(
name
=
"ttl"
,
required
=
false
,
defaultValue
=
"-1"
)
long
ttl
)
{
@RequestParam
(
name
=
"ttl"
,
required
=
false
,
defaultValue
=
"-1"
)
long
ttl
)
{
...
@@ -67,7 +67,7 @@ public class NotificationFilterController {
...
@@ -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
)
{
public
ResponseEntity
<?>
deleteFilter
(
@PathVariable
(
"id"
)
String
id
)
{
NotificationFilter
deleted
=
filteringNotifier
.
removeFilter
(
id
);
NotificationFilter
deleted
=
filteringNotifier
.
removeFilter
(
id
);
if
(
deleted
!=
null
)
{
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;
...
@@ -37,7 +37,6 @@ import org.springframework.util.StringUtils;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
static
java
.
util
.
Comparator
.
comparing
;
import
static
java
.
util
.
Comparator
.
comparing
;
...
@@ -50,22 +49,21 @@ import static java.util.stream.Collectors.toMap;
...
@@ -50,22 +49,21 @@ import static java.util.stream.Collectors.toMap;
*/
*/
@AdminController
@AdminController
@ResponseBody
@ResponseBody
@RequestMapping
(
"/applications"
)
public
class
ApplicationsController
{
public
class
ApplicationsController
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
ApplicationsController
.
class
);
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
ApplicationsController
.
class
);
private
final
InstanceRegistry
registry
;
private
final
InstanceRegistry
registry
;
private
final
InstanceEventPublisher
eventPublisher
;
private
final
InstanceEventPublisher
eventPublisher
;
private
static
final
ServerSentEvent
<
Application
>
PING
=
ServerSentEvent
.<
Application
>
builder
().
comment
(
"ping"
)
private
static
final
ServerSentEvent
<
Application
>
PING
=
ServerSentEvent
.<
Application
>
builder
().
comment
(
"ping"
)
.
build
();
.
build
();
private
static
final
Flux
<
ServerSentEvent
<
Application
>>
PING_FLUX
=
Flux
.
interval
(
Duration
.
ofSeconds
(
10L
))
private
static
final
Flux
<
ServerSentEvent
<
Application
>>
PING_FLUX
=
Flux
.
interval
(
Duration
.
ZERO
,
.
map
(
tick
->
PING
);
Duration
.
ofSeconds
(
10L
))
.
map
(
tick
->
PING
);
public
ApplicationsController
(
InstanceRegistry
registry
,
InstanceEventPublisher
eventPublisher
)
{
public
ApplicationsController
(
InstanceRegistry
registry
,
InstanceEventPublisher
eventPublisher
)
{
this
.
registry
=
registry
;
this
.
registry
=
registry
;
this
.
eventPublisher
=
eventPublisher
;
this
.
eventPublisher
=
eventPublisher
;
}
}
@GetMapping
(
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@GetMapping
(
p
ath
=
"/applications"
,
p
roduces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
Flux
<
Application
>
applications
()
{
public
Flux
<
Application
>
applications
()
{
return
registry
.
getInstances
()
return
registry
.
getInstances
()
.
filter
(
Instance:
:
isRegistered
)
.
filter
(
Instance:
:
isRegistered
)
...
@@ -73,7 +71,7 @@ public class ApplicationsController {
...
@@ -73,7 +71,7 @@ public class ApplicationsController {
.
flatMap
(
grouped
->
toApplication
(
grouped
.
key
(),
grouped
));
.
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
()
{
public
Flux
<
ServerSentEvent
<
Application
>>
applicationsStream
()
{
return
Flux
.
from
(
eventPublisher
)
return
Flux
.
from
(
eventPublisher
)
.
flatMap
(
event
->
registry
.
getInstance
(
event
.
getInstance
()))
.
flatMap
(
event
->
registry
.
getInstance
(
event
.
getInstance
()))
...
@@ -83,7 +81,7 @@ public class ApplicationsController {
...
@@ -83,7 +81,7 @@ public class ApplicationsController {
.
mergeWith
(
PING_FLUX
);
.
mergeWith
(
PING_FLUX
);
}
}
@DeleteMapping
(
path
=
"/{name}"
)
@DeleteMapping
(
path
=
"/
applications/
{name}"
)
public
Mono
<
ResponseEntity
<
Void
>>
unregister
(
@PathVariable
(
"name"
)
String
name
)
{
public
Mono
<
ResponseEntity
<
Void
>>
unregister
(
@PathVariable
(
"name"
)
String
name
)
{
log
.
debug
(
"Unregister application with name '{}'"
,
name
);
log
.
debug
(
"Unregister application with name '{}'"
,
name
);
return
registry
.
getInstancesByApplication
(
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;
...
@@ -25,18 +25,19 @@ import reactor.core.publisher.Flux;
import
reactor.core.publisher.Mono
;
import
reactor.core.publisher.Mono
;
import
java.net.URI
;
import
java.net.URI
;
import
java.time.Duration
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.Map
;
import
java.util.Map
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.codec.ServerSentEvent
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
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.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.util.UriComponentsBuilder
;
import
org.springframework.web.util.UriComponentsBuilder
;
...
@@ -46,11 +47,14 @@ import org.springframework.web.util.UriComponentsBuilder;
...
@@ -46,11 +47,14 @@ import org.springframework.web.util.UriComponentsBuilder;
*/
*/
@AdminController
@AdminController
@ResponseBody
@ResponseBody
@RequestMapping
(
"/instances"
)
public
class
InstancesController
{
public
class
InstancesController
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
InstancesController
.
class
);
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
InstancesController
.
class
);
private
final
InstanceRegistry
registry
;
private
final
InstanceRegistry
registry
;
private
final
InstanceEventStore
eventStore
;
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
)
{
public
InstancesController
(
InstanceRegistry
registry
,
InstanceEventStore
eventStore
)
{
this
.
registry
=
registry
;
this
.
registry
=
registry
;
...
@@ -63,7 +67,7 @@ public class InstancesController {
...
@@ -63,7 +67,7 @@ public class InstancesController {
* @param registration registration info
* @param registration registration info
* @return The registered instance id;
* @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
,
public
Mono
<
ResponseEntity
<
Map
<
String
,
InstanceId
>>>
register
(
@RequestBody
Registration
registration
,
UriComponentsBuilder
builder
)
{
UriComponentsBuilder
builder
)
{
Registration
withSource
=
Registration
.
copyOf
(
registration
).
source
(
"http-api"
).
build
();
Registration
withSource
=
Registration
.
copyOf
(
registration
).
source
(
"http-api"
).
build
();
...
@@ -80,7 +84,7 @@ public class InstancesController {
...
@@ -80,7 +84,7 @@ public class InstancesController {
* @param name the name to search for
* @param name the name to search for
* @return application list
* @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
)
{
public
Flux
<
Instance
>
instances
(
@RequestParam
(
value
=
"name"
,
required
=
false
)
String
name
)
{
LOGGER
.
debug
(
"Deliver registered instances with name={}"
,
name
);
LOGGER
.
debug
(
"Deliver registered instances with name={}"
,
name
);
if
(
name
==
null
||
name
.
isEmpty
())
{
if
(
name
==
null
||
name
.
isEmpty
())
{
...
@@ -96,7 +100,7 @@ public class InstancesController {
...
@@ -96,7 +100,7 @@ public class InstancesController {
* @param id The application identifier.
* @param id The application identifier.
* @return The registered application.
* @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
)
{
public
Mono
<
ResponseEntity
<
Instance
>>
instance
(
@PathVariable
String
id
)
{
LOGGER
.
debug
(
"Deliver registered instance with ID '{}'"
,
id
);
LOGGER
.
debug
(
"Deliver registered instance with ID '{}'"
,
id
);
return
registry
.
getInstance
(
InstanceId
.
of
(
id
))
return
registry
.
getInstance
(
InstanceId
.
of
(
id
))
...
@@ -110,7 +114,7 @@ public class InstancesController {
...
@@ -110,7 +114,7 @@ public class InstancesController {
*
*
* @param id The instance id.
* @param id The instance id.
*/
*/
@DeleteMapping
(
path
=
"/{id}"
)
@DeleteMapping
(
path
=
"/
instances/
{id}"
)
public
Mono
<
ResponseEntity
<
Void
>>
unregister
(
@PathVariable
String
id
)
{
public
Mono
<
ResponseEntity
<
Void
>>
unregister
(
@PathVariable
String
id
)
{
LOGGER
.
debug
(
"Unregister instance with ID '{}'"
,
id
);
LOGGER
.
debug
(
"Unregister instance with ID '{}'"
,
id
);
return
registry
.
deregister
(
InstanceId
.
of
(
id
))
return
registry
.
deregister
(
InstanceId
.
of
(
id
))
...
@@ -118,14 +122,14 @@ public class InstancesController {
...
@@ -118,14 +122,14 @@ public class InstancesController {
.
defaultIfEmpty
(
ResponseEntity
.
notFound
().
build
());
.
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
()
{
public
Flux
<
InstanceEvent
>
events
()
{
return
eventStore
.
findAll
();
return
eventStore
.
findAll
();
}
}
@GetMapping
(
path
=
"/
events"
,
produces
=
MediaType
.
APPLICATION_STREAM_JSON
_VALUE
)
@GetMapping
(
path
=
"/
instances/events"
,
produces
=
MediaType
.
TEXT_EVENT_STREAM
_VALUE
)
public
Flux
<
?
extends
InstanceEvent
>
eventStream
()
{
public
Flux
<
ServerSentEvent
<
InstanceEvent
>
>
eventStream
()
{
return
Flux
.
from
(
eventStore
);
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