|
24 | 24 | import org.slf4j.LoggerFactory; |
25 | 25 | import org.springframework.context.ApplicationContext; |
26 | 26 | import org.springframework.context.ApplicationContextAware; |
| 27 | +import org.springframework.util.Assert; |
| 28 | +import org.springframework.util.StringUtils; |
27 | 29 |
|
28 | 30 | import de.codecentric.boot.admin.event.ClientApplicationRegisteredEvent; |
29 | 31 | import de.codecentric.boot.admin.event.ClientApplicationUnregisteredEvent; |
@@ -53,21 +55,30 @@ public ApplicationRegistry(ApplicationStore store, ApplicationIdGenerator genera |
53 | 55 | * @return the registered application. |
54 | 56 | */ |
55 | 57 | public Application register(Application app) { |
56 | | - Validate.notNull(app, "Application must not be null"); |
57 | | - Validate.notNull(app.getUrl(), "URL must not be null"); |
58 | | - Validate.isTrue(checkUrl(app.getUrl()), "URL is not valid"); |
| 58 | + Assert.notNull(app, "Application must not be null"); |
| 59 | + Assert.hasText(app.getName(), "Name must not be null"); |
| 60 | + Assert.hasText(app.getHealthUrl(), "Health-URL must not be null"); |
| 61 | + Assert.isTrue(checkUrl(app.getHealthUrl()), "Health-URL is not valid"); |
| 62 | + Assert.isTrue( |
| 63 | + StringUtils.isEmpty(app.getManagementUrl()) |
| 64 | + || checkUrl(app.getManagementUrl()), "URL is not valid"); |
| 65 | + Assert.isTrue( |
| 66 | + StringUtils.isEmpty(app.getServiceUrl()) || checkUrl(app.getServiceUrl()), |
| 67 | + "URL is not valid"); |
59 | 68 |
|
60 | 69 | String applicationId = generator.generateId(app); |
61 | 70 | Validate.notNull(applicationId, "ID must not be null"); |
62 | 71 |
|
63 | | - Application newApp = new Application(app.getUrl(), app.getName(), applicationId); |
| 72 | + Application newApp = new Application(app.getHealthUrl(), app.getManagementUrl(), |
| 73 | + app.getServiceUrl(), app.getName(), applicationId); |
64 | 74 | Application oldApp = store.save(newApp); |
65 | 75 |
|
66 | 76 | if (oldApp == null) { |
67 | 77 | LOGGER.info("New Application {} registered ", newApp); |
68 | 78 | context.publishEvent(new ClientApplicationRegisteredEvent(this, newApp)); |
69 | 79 | } else { |
70 | | - if ((app.getUrl().equals(oldApp.getUrl()) && app.getName().equals(oldApp.getName()))) { |
| 80 | + if ((newApp.getId().equals(oldApp.getId()) && app.getName().equals( |
| 81 | + oldApp.getName()))) { |
71 | 82 | LOGGER.debug("Application {} refreshed", newApp); |
72 | 83 | } else { |
73 | 84 | LOGGER.warn("Application {} replaced by Application {}", newApp, oldApp); |
|
0 commit comments