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
9b4b0901
Commit
9b4b0901
authored
Jun 17, 2014
by
Thomas Bosch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
comments
parent
548126d9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
2 deletions
+30
-2
RegistryController.java
...codecentric/boot/admin/controller/RegistryController.java
+9
-2
ApplicationRegistry.java
...e/codecentric/boot/admin/service/ApplicationRegistry.java
+21
-0
No files found.
src/main/java/de/codecentric/boot/admin/controller/RegistryController.java
View file @
9b4b0901
...
...
@@ -2,6 +2,8 @@ package de.codecentric.boot.admin.controller;
import
java.util.List
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestBody
;
...
...
@@ -12,23 +14,28 @@ import org.springframework.web.bind.annotation.ResponseBody;
import
de.codecentric.boot.admin.model.Application
;
import
de.codecentric.boot.admin.service.ApplicationRegistry
;
/**
* REST controller for controlling registration of managed applications.
*/
@Controller
public
class
RegistryController
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
RegistryController
.
class
);
@Autowired
private
ApplicationRegistry
registry
;
@RequestMapping
(
value
=
"/api/applications"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
void
register
(
@RequestBody
Application
app
)
{
System
.
out
.
println
(
"register "
+
app
);
LOGGER
.
info
(
"Register application with ID '{}' and URL '{}'"
,
app
.
getId
(),
app
.
getUrl
()
);
registry
.
register
(
app
);
}
@RequestMapping
(
value
=
"/api/applications"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
List
<
Application
>
applications
()
{
System
.
out
.
println
(
"get all
"
);
LOGGER
.
debug
(
"Deliver all registered applications
"
);
return
registry
.
getApplications
();
}
...
...
src/main/java/de/codecentric/boot/admin/service/ApplicationRegistry.java
View file @
9b4b0901
...
...
@@ -9,11 +9,20 @@ import org.springframework.stereotype.Service;
import
de.codecentric.boot.admin.model.Application
;
/**
* Registry for all applications that should be managed/administrated by the spring-boot-admin application.
*/
@Service
public
class
ApplicationRegistry
{
private
final
List
<
Application
>
registry
=
new
ArrayList
<>();
/**
* Register application.
*
* @param app
* The Application.
*/
public
void
register
(
Application
app
)
{
Validate
.
notNull
(
app
,
"Application must not be null"
);
Validate
.
notNull
(
app
.
getId
(),
"Application ID must not be null"
);
...
...
@@ -21,10 +30,22 @@ public class ApplicationRegistry {
registry
.
add
(
app
);
}
/**
* Checks, if an application is already registerd.
*
* @param app
* The application.
* @return exists?
*/
public
boolean
isRegistered
(
Application
app
)
{
return
registry
.
contains
(
app
);
}
/**
* Get a list of all registered applications.
*
* @return List.
*/
public
List
<
Application
>
getApplications
()
{
return
Collections
.
unmodifiableList
(
registry
);
}
...
...
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