pull up URI-based common functionality into core abstract base class
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package org.springframework.cloud.service;
|
||||
|
||||
import org.springframework.cloud.ServiceInfoCreator;
|
||||
import org.springframework.cloud.AbstractCloudConnector.KeyValuePair;
|
||||
|
||||
public abstract class UriBasedServiceInfoCreator<SI extends ServiceInfo> implements
|
||||
ServiceInfoCreator<ServiceInfo, KeyValuePair> {
|
||||
|
||||
private final String uriScheme;
|
||||
|
||||
public UriBasedServiceInfoCreator(String uriScheme) {
|
||||
this.uriScheme = uriScheme;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept(KeyValuePair serviceData) {
|
||||
return serviceData.getValue().toString().startsWith(uriScheme + "://");
|
||||
}
|
||||
|
||||
public abstract SI createServiceInfo(String id, String uri);
|
||||
|
||||
@Override
|
||||
public SI createServiceInfo(KeyValuePair serviceData) {
|
||||
return createServiceInfo(serviceData.getKey(), serviceData.getValue());
|
||||
}
|
||||
}
|
||||
@@ -1,30 +1,17 @@
|
||||
package org.springframework.cloud.heroku;
|
||||
|
||||
import org.springframework.cloud.AbstractCloudConnector.KeyValuePair;
|
||||
import org.springframework.cloud.ServiceInfoCreator;
|
||||
import org.springframework.cloud.service.ServiceInfo;
|
||||
import org.springframework.cloud.service.UriBasedServiceInfoCreator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ramnivas Laddad
|
||||
*
|
||||
*/
|
||||
public abstract class HerokuServiceInfoCreator<SI extends ServiceInfo> implements ServiceInfoCreator<SI,KeyValuePair> {
|
||||
public abstract class HerokuServiceInfoCreator<SI extends ServiceInfo> extends UriBasedServiceInfoCreator<SI> {
|
||||
|
||||
private String urlProtocol;
|
||||
|
||||
public HerokuServiceInfoCreator(String urlProtocol) {
|
||||
this.urlProtocol = urlProtocol;
|
||||
}
|
||||
|
||||
public boolean accept(KeyValuePair serviceData) {
|
||||
return serviceData.getValue().toString().startsWith(urlProtocol + "://");
|
||||
}
|
||||
|
||||
public abstract SI createServiceInfo(String id, String uri);
|
||||
|
||||
public SI createServiceInfo(KeyValuePair serviceData) {
|
||||
return createServiceInfo(serviceData.getKey(), serviceData.getValue());
|
||||
public HerokuServiceInfoCreator(String uriScheme) {
|
||||
super(uriScheme);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user