Java Code Examples for de.codecentric.boot.admin.server.domain.values.Registration#Builder

The following examples show how to use de.codecentric.boot.admin.server.domain.values.Registration#Builder . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RegistrationDeserializer.java    From Moss with Apache License 2.0 5 votes vote down vote up
@Override
public Registration deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
    JsonNode node = p.readValueAsTree();
    Registration.Builder builder = Registration.builder();

    if (node.has("name")) {
        builder.name(node.get("name").asText());
    }
    if (node.has("url")) {
        String url = node.get("url").asText();
        builder.healthUrl(url.replaceFirst("/+$", "") + "/health").managementUrl(url);
    } else {
        if (node.has("healthUrl")) {
            builder.healthUrl(node.get("healthUrl").asText());
        }
        if (node.has("managementUrl")) {
            builder.managementUrl(node.get("managementUrl").asText());
        }
        if (node.has("serviceUrl")) {
            builder.serviceUrl(node.get("serviceUrl").asText());
        }
    }

    if (node.has("metadata")) {
        Iterator<Map.Entry<String, JsonNode>> it = node.get("metadata").fields();
        while (it.hasNext()) {
            Map.Entry<String, JsonNode> entry = it.next();
            builder.metadata(entry.getKey(), entry.getValue().asText());
        }
    }
    return builder.build();
}
 
Example 2
Source File: RegistrationDeserializer.java    From spring-boot-admin with Apache License 2.0 5 votes vote down vote up
@Override
public Registration deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
	JsonNode node = p.readValueAsTree();
	Registration.Builder builder = Registration.builder();

	if (node.hasNonNull("name")) {
		builder.name(node.get("name").asText());
	}
	if (node.hasNonNull("url")) {
		String url = node.get("url").asText();
		builder.healthUrl(url.replaceFirst("/+$", "") + "/health").managementUrl(url);
	}
	else {
		if (node.hasNonNull("healthUrl")) {
			builder.healthUrl(node.get("healthUrl").asText());
		}
		if (node.hasNonNull("managementUrl")) {
			builder.managementUrl(node.get("managementUrl").asText());
		}
		if (node.hasNonNull("serviceUrl")) {
			builder.serviceUrl(node.get("serviceUrl").asText());
		}
	}

	if (node.has("metadata")) {
		Iterator<Map.Entry<String, JsonNode>> it = node.get("metadata").fields();
		while (it.hasNext()) {
			Map.Entry<String, JsonNode> entry = it.next();
			builder.metadata(entry.getKey(), entry.getValue().asText());
		}
	}

	if (node.hasNonNull("source")) {
		builder.source(node.get("source").asText());
	}

	return builder.build();
}