Commit 8cb5795d by Johannes Edmeier

Rename copying factory method to 'copyOf

parent c15b3bbc
...@@ -110,7 +110,7 @@ public class ApplicationDiscoveryListener { ...@@ -110,7 +110,7 @@ public class ApplicationDiscoveryListener {
protected String register(ServiceInstance instance) { protected String register(ServiceInstance instance) {
try { try {
Application application = converter.convert(instance); Application application = converter.convert(instance);
application = Application.create(application).withSource(SOURCE).build(); application = Application.copyOf(application).withSource(SOURCE).build();
if (application != null) { if (application != null) {
LOGGER.debug("Registering discovered application {}", application); LOGGER.debug("Registering discovered application {}", application);
return registry.register(application).getId(); return registry.register(application).getId();
......
...@@ -72,7 +72,7 @@ public class Application implements Serializable { ...@@ -72,7 +72,7 @@ public class Application implements Serializable {
return new Builder(name); return new Builder(name);
} }
public static Builder create(Application application) { public static Builder copyOf(Application application) {
return new Builder(application); return new Builder(application);
} }
......
...@@ -72,7 +72,7 @@ public class ApplicationRegistry implements ApplicationEventPublisherAware { ...@@ -72,7 +72,7 @@ public class ApplicationRegistry implements ApplicationEventPublisherAware {
StatusInfo existingStatusInfo = getExistingStatusInfo(applicationId); StatusInfo existingStatusInfo = getExistingStatusInfo(applicationId);
Application registering = Application.create(application).withId(applicationId) Application registering = Application.copyOf(application).withId(applicationId)
.withStatusInfo(existingStatusInfo).build(); .withStatusInfo(existingStatusInfo).build();
Application replaced = store.save(registering); Application replaced = store.save(registering);
......
...@@ -73,7 +73,7 @@ public class StatusUpdater implements ApplicationEventPublisherAware { ...@@ -73,7 +73,7 @@ public class StatusUpdater implements ApplicationEventPublisherAware {
StatusInfo oldStatus = application.getStatusInfo(); StatusInfo oldStatus = application.getStatusInfo();
StatusInfo newStatus = queryStatus(application); StatusInfo newStatus = queryStatus(application);
Application newState = Application.create(application).withStatusInfo(newStatus).build(); Application newState = Application.copyOf(application).withStatusInfo(newStatus).build();
store.save(newState); store.save(newState);
if (!newStatus.equals(oldStatus)) { if (!newStatus.equals(oldStatus)) {
......
...@@ -56,7 +56,7 @@ public class RegistryController { ...@@ -56,7 +56,7 @@ public class RegistryController {
*/ */
@RequestMapping(method = RequestMethod.POST) @RequestMapping(method = RequestMethod.POST)
public ResponseEntity<Application> register(@RequestBody Application application) { public ResponseEntity<Application> register(@RequestBody Application application) {
application = Application.create(application).withSource("http-api").build(); application = Application.copyOf(application).withSource("http-api").build();
LOGGER.debug("Register application {}", application.toString()); LOGGER.debug("Register application {}", application.toString());
Application registeredApp = registry.register(application); Application registeredApp = registry.register(application);
return ResponseEntity.status(HttpStatus.CREATED).body(registeredApp); return ResponseEntity.status(HttpStatus.CREATED).body(registeredApp);
......
...@@ -110,7 +110,7 @@ public class ApplicationTest { ...@@ -110,7 +110,7 @@ public class ApplicationTest {
Application app = Application.create("App").withId("-id-").withHealthUrl("http://health") Application app = Application.create("App").withId("-id-").withHealthUrl("http://health")
.withManagementUrl("http://mgmgt").withServiceUrl("http://svc") .withManagementUrl("http://mgmgt").withServiceUrl("http://svc")
.withStatusInfo(StatusInfo.ofUp()).build(); .withStatusInfo(StatusInfo.ofUp()).build();
Application copy = Application.create(app).build(); Application copy = Application.copyOf(app).build();
assertThat(app, is(copy)); assertThat(app, is(copy));
} }
} }
\ No newline at end of file
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