1222 DefaultSchemaRegistryClient should accept a custom RestTemplate.

Added protected accessors to allow subclasses access to RestTemplate and endpoint fields.
This commit is contained in:
jmaxwell
2018-02-13 14:30:45 -06:00
committed by Oleg Zhurakousky
parent d8a9471012
commit c2b3194fb9

View File

@@ -36,7 +36,16 @@ public class DefaultSchemaRegistryClient implements SchemaRegistryClient {
private String endpoint = "http://localhost:8990";
public DefaultSchemaRegistryClient() {
this.template = new RestTemplate();
this(new RestTemplate());
}
public DefaultSchemaRegistryClient(RestTemplate restTemplate) {
Assert.notNull(restTemplate,"restTemplate cannot be null.");
this.template = restTemplate;
}
protected String getEndpoint() {
return this.endpoint;
}
public void setEndpoint(String endpoint) {
@@ -44,6 +53,15 @@ public class DefaultSchemaRegistryClient implements SchemaRegistryClient {
this.endpoint = endpoint;
}
protected RestTemplate getRestTemplate() {
return this.template;
}
public void setRestTemplate(RestTemplate restTemplate) {
Assert.notNull(restTemplate,"restTemplate cannot be null.");
this.template = restTemplate;
}
@Override
public SchemaRegistrationResponse register(String subject, String format, String schema) {
Map<String, String> requestBody = new HashMap<>();