Commit 5accd407 by Thomas Bosch

some comments

parent efa71e4c
...@@ -12,6 +12,12 @@ import de.codecentric.boot.admin.config.WebappConfig; ...@@ -12,6 +12,12 @@ import de.codecentric.boot.admin.config.WebappConfig;
@Import(WebappConfig.class) @Import(WebappConfig.class)
public class SpringBootAdmin { public class SpringBootAdmin {
/**
* Starting point for application to boot.
*
* @param args
* Passed arguments.
*/
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(SpringBootAdmin.class, args); SpringApplication.run(SpringBootAdmin.class, args);
} }
......
...@@ -14,16 +14,25 @@ import de.codecentric.boot.admin.service.ApplicationRegistry; ...@@ -14,16 +14,25 @@ import de.codecentric.boot.admin.service.ApplicationRegistry;
@Configuration @Configuration
public class WebappConfig extends WebMvcConfigurerAdapter { public class WebappConfig extends WebMvcConfigurerAdapter {
/**
* Add JSON MessageConverter to send JSON objects to web clients.
*/
@Override @Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
converters.add(new MappingJackson2HttpMessageConverter()); converters.add(new MappingJackson2HttpMessageConverter());
} }
/**
* Controller with REST-API for spring-boot applications to register itself.
*/
@Bean @Bean
public RegistryController registryController() { public RegistryController registryController() {
return new RegistryController(); return new RegistryController();
} }
/**
* Registry for all registered application.
*/
@Bean @Bean
public ApplicationRegistry applicationRegistry() { public ApplicationRegistry applicationRegistry() {
return new ApplicationRegistry(); return new ApplicationRegistry();
......
...@@ -26,6 +26,13 @@ public class RegistryController { ...@@ -26,6 +26,13 @@ public class RegistryController {
@Autowired @Autowired
private ApplicationRegistry registry; private ApplicationRegistry registry;
/**
* Register an application within this admin application.
*
* @param app
* The application infos.
* @return The registered application.
*/
@RequestMapping(value = "/api/applications", method = RequestMethod.POST) @RequestMapping(value = "/api/applications", method = RequestMethod.POST)
@ResponseBody @ResponseBody
public Application register(@RequestBody Application app) { public Application register(@RequestBody Application app) {
...@@ -33,6 +40,13 @@ public class RegistryController { ...@@ -33,6 +40,13 @@ public class RegistryController {
return registry.register(app); return registry.register(app);
} }
/**
* Get a single application out of the registry.
*
* @param id
* The application identifier.
* @return The registered application.
*/
@RequestMapping(value = "/api/application/{id}", method = RequestMethod.GET) @RequestMapping(value = "/api/application/{id}", method = RequestMethod.GET)
@ResponseBody @ResponseBody
public Application get(@PathVariable String id) { public Application get(@PathVariable String id) {
...@@ -40,6 +54,11 @@ public class RegistryController { ...@@ -40,6 +54,11 @@ public class RegistryController {
return registry.getApplication(id); return registry.getApplication(id);
} }
/**
* List all registered applications.
*
* @return List.
*/
@RequestMapping(value = "/api/applications", method = RequestMethod.GET) @RequestMapping(value = "/api/applications", method = RequestMethod.GET)
@ResponseBody @ResponseBody
public List<Application> applications() { public List<Application> applications() {
......
...@@ -11,7 +11,8 @@ import org.springframework.stereotype.Service; ...@@ -11,7 +11,8 @@ import org.springframework.stereotype.Service;
import de.codecentric.boot.admin.model.Application; import de.codecentric.boot.admin.model.Application;
/** /**
* Registry for all applications that should be managed/administrated by the spring-boot-admin application. * Registry for all applications that should be managed/administrated by the spring-boot-admin application. This
* registry is just "in-memory", so that after a restart all applications have to be registered again.
*/ */
@Service @Service
public class ApplicationRegistry { public class ApplicationRegistry {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment