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
4a011458
Commit
4a011458
authored
Nov 02, 2016
by
Johannes Edmeier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add @AdminController for sba mvc controllers
To easily add new mvc controllers (e.g. from extensions) a new annotation `@AdminController` is added.
parent
ae042803
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
12 deletions
+58
-12
AdminServerWebConfiguration.java
...entric/boot/admin/config/AdminServerWebConfiguration.java
+6
-2
JournalController.java
...codecentric/boot/admin/journal/web/JournalController.java
+5
-2
NotificationFilterController.java
...admin/notify/filter/web/NotificationFilterController.java
+6
-4
RegistryController.java
...decentric/boot/admin/registry/web/RegistryController.java
+7
-4
AdminController.java
...n/java/de/codecentric/boot/admin/web/AdminController.java
+34
-0
No files found.
spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/config/AdminServerWebConfiguration.java
View file @
4a011458
...
...
@@ -16,6 +16,7 @@
package
de
.
codecentric
.
boot
.
admin
.
config
;
import
java.util.List
;
import
java.util.Map
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
...
...
@@ -59,6 +60,7 @@ import de.codecentric.boot.admin.registry.StatusUpdater;
import
de.codecentric.boot.admin.registry.store.ApplicationStore
;
import
de.codecentric.boot.admin.registry.store.SimpleApplicationStore
;
import
de.codecentric.boot.admin.registry.web.RegistryController
;
import
de.codecentric.boot.admin.web.AdminController
;
import
de.codecentric.boot.admin.web.PrefixHandlerMapping
;
import
de.codecentric.boot.admin.web.servlet.resource.ConcatenatingResourceResolver
;
import
de.codecentric.boot.admin.web.servlet.resource.PreferMinifiedFilteringResourceResolver
;
...
...
@@ -149,8 +151,10 @@ public class AdminServerWebConfiguration extends WebMvcConfigurerAdapter
@Bean
public
PrefixHandlerMapping
prefixHandlerMapping
()
{
PrefixHandlerMapping
prefixHandlerMapping
=
new
PrefixHandlerMapping
(
registryController
(),
journalController
());
Map
<
String
,
Object
>
beans
=
applicationContext
.
getBeansWithAnnotation
(
AdminController
.
class
);
PrefixHandlerMapping
prefixHandlerMapping
=
new
PrefixHandlerMapping
(
beans
.
values
().
toArray
(
new
Object
[
beans
.
size
()]));
prefixHandlerMapping
.
setPrefix
(
adminServerProperties
().
getContextPath
());
return
prefixHandlerMapping
;
}
...
...
spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/journal/web/JournalController.java
View file @
4a011458
...
...
@@ -32,13 +32,16 @@ import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
import
de.codecentric.boot.admin.event.ClientApplicationEvent
;
import
de.codecentric.boot.admin.journal.ApplicationEventJournal
;
import
de.codecentric.boot.admin.web.AdminController
;
/**
* REST-Controller for querying all client application events.
*
* @author Johannes Edmeier
*/
@AdminController
@ResponseBody
@RequestMapping
(
"/api/journal"
)
public
class
JournalController
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
JournalController
.
class
);
...
...
@@ -50,12 +53,12 @@ public class JournalController {
this
.
eventJournal
=
eventJournal
;
}
@RequestMapping
(
p
ath
=
"/api/journal"
,
p
roduces
=
MimeTypeUtils
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
produces
=
MimeTypeUtils
.
APPLICATION_JSON_VALUE
)
public
Collection
<
ClientApplicationEvent
>
getJournal
()
{
return
eventJournal
.
getEvents
();
}
@RequestMapping
(
p
ath
=
"/api/journal"
,
p
roduces
=
"text/event-stream"
)
@RequestMapping
(
produces
=
"text/event-stream"
)
public
SseEmitter
getJournalEvents
()
{
final
SseEmitter
emitter
=
new
SseEmitter
();
emitter
.
onCompletion
(
new
Runnable
()
{
...
...
spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/notify/filter/web/NotificationFilterController.java
View file @
4a011458
...
...
@@ -32,13 +32,16 @@ import de.codecentric.boot.admin.notify.filter.ApplicationIdNotificationFilter;
import
de.codecentric.boot.admin.notify.filter.ApplicationNameNotificationFilter
;
import
de.codecentric.boot.admin.notify.filter.FilteringNotifier
;
import
de.codecentric.boot.admin.notify.filter.NotificationFilter
;
import
de.codecentric.boot.admin.web.AdminController
;
/**
* REST-Controller for managing notification filters
*
* @author Johannes Edmeier
*/
@AdminController
@ResponseBody
@RequestMapping
(
"/api/notifications/filters"
)
public
class
NotificationFilterController
{
private
FilteringNotifier
filteringNotifier
;
...
...
@@ -46,13 +49,12 @@ public class NotificationFilterController {
this
.
filteringNotifier
=
filteringNotifier
;
}
@RequestMapping
(
path
=
"/api/notifications/filters"
,
method
=
{
RequestMethod
.
GET
},
produces
=
MimeTypeUtils
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
method
=
{
RequestMethod
.
GET
},
produces
=
MimeTypeUtils
.
APPLICATION_JSON_VALUE
)
public
Map
<
String
,
NotificationFilter
>
getFilters
()
{
return
filteringNotifier
.
getNotificationFilters
();
}
@RequestMapping
(
path
=
"/api/notifications/filters"
,
method
=
{
@RequestMapping
(
method
=
{
RequestMethod
.
POST
},
produces
=
MimeTypeUtils
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
addFilter
(
@RequestParam
(
name
=
"id"
,
required
=
false
)
String
id
,
@RequestParam
(
name
=
"name"
,
required
=
false
)
String
name
,
...
...
@@ -66,7 +68,7 @@ public class NotificationFilterController {
}
}
@RequestMapping
(
path
=
"/
api/notifications/filters/
{id}"
,
method
=
{
RequestMethod
.
DELETE
})
@RequestMapping
(
path
=
"/{id}"
,
method
=
{
RequestMethod
.
DELETE
})
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/registry/web/RegistryController.java
View file @
4a011458
...
...
@@ -30,11 +30,14 @@ import org.springframework.web.bind.annotation.ResponseBody;
import
de.codecentric.boot.admin.model.Application
;
import
de.codecentric.boot.admin.registry.ApplicationRegistry
;
import
de.codecentric.boot.admin.web.AdminController
;
/**
* REST controller for controlling registration of managed applications.
*/
@AdminController
@ResponseBody
@RequestMapping
(
"/api/applications"
)
public
class
RegistryController
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
RegistryController
.
class
);
...
...
@@ -51,7 +54,7 @@ public class RegistryController {
* @param app The application infos.
* @return The registered application.
*/
@RequestMapping
(
value
=
"/api/applications"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
method
=
RequestMethod
.
POST
)
public
ResponseEntity
<
Application
>
register
(
@RequestBody
Application
app
)
{
LOGGER
.
debug
(
"Register application {}"
,
app
.
toString
());
Application
registeredApp
=
registry
.
register
(
app
);
...
...
@@ -64,7 +67,7 @@ public class RegistryController {
* @param name the name to search for
* @return List
*/
@RequestMapping
(
value
=
"/api/applications"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
method
=
RequestMethod
.
GET
)
public
Collection
<
Application
>
applications
(
@RequestParam
(
value
=
"name"
,
required
=
false
)
String
name
)
{
LOGGER
.
debug
(
"Deliver registered applications with name={}"
,
name
);
...
...
@@ -81,7 +84,7 @@ public class RegistryController {
* @param id The application identifier.
* @return The registered application.
*/
@RequestMapping
(
value
=
"/
api/applications/
{id}"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
)
public
ResponseEntity
<?>
get
(
@PathVariable
String
id
)
{
LOGGER
.
debug
(
"Deliver registered application with ID '{}'"
,
id
);
Application
application
=
registry
.
getApplication
(
id
);
...
...
@@ -98,7 +101,7 @@ public class RegistryController {
* @param id The application id.
* @return the unregistered application.
*/
@RequestMapping
(
value
=
"/
api/applications/
{id}"
,
method
=
RequestMethod
.
DELETE
)
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
DELETE
)
public
ResponseEntity
<?>
unregister
(
@PathVariable
String
id
)
{
LOGGER
.
debug
(
"Unregister application with ID '{}'"
,
id
);
Application
application
=
registry
.
deregister
(
id
);
...
...
spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/web/AdminController.java
0 → 100644
View file @
4a011458
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
de
.
codecentric
.
boot
.
admin
.
web
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
/**
* Indicates that the annotated class is a mvn controller used whithin spring boot admin and
* contains handler mappings to be registered using {@link PrefixHandlerMapping}.
*
* @author Johannes Edmeier
*/
@Target
({
ElementType
.
TYPE
})
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
public
@interface
AdminController
{
}
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