use of org.springframework.cloud.service.ServiceInfo in project spring-cloud-connectors by spring-cloud.
the class ServiceConnectorCreatorRegistry method flatten.
private static List<ServiceInfo> flatten(List<ServiceInfo> serviceInfos) {
List<ServiceInfo> flattened = new ArrayList<ServiceInfo>();
for (ServiceInfo serviceInfo : serviceInfos) {
if (serviceInfo instanceof CompositeServiceInfo) {
// recursively flatten any CompositeServiceInfos
CompositeServiceInfo compositeServiceInfo = (CompositeServiceInfo) serviceInfo;
flattened.addAll(flatten(compositeServiceInfo.getServiceInfos()));
} else {
flattened.add(serviceInfo);
}
}
return flattened;
}
use of org.springframework.cloud.service.ServiceInfo in project spring-cloud-connectors by spring-cloud.
the class ServiceConnectorCreatorRegistry method getSingletonServiceConnector.
/**
* Get the singleton service connector for the given connector type, configured with the given config
*
* @param <SC> The class of the service connector to return.
* @param serviceConnectorType The expected class of service connector such as, DataSource.class.
* @param serviceConnectorConfig service connector configuration (such as pooling parameters).
* @return the single service connector of the specified type with the given configuration applied
*
*/
public <SC> SC getSingletonServiceConnector(Class<SC> serviceConnectorType, ServiceConnectorConfig serviceConnectorConfig) {
List<ServiceInfo> matchingServiceInfos = getServiceInfos(serviceConnectorType);
if (matchingServiceInfos.size() != 1) {
throw new CloudException("No unique service matching " + serviceConnectorType + " found. Expected 1, found " + matchingServiceInfos.size());
}
ServiceInfo matchingServiceInfo = matchingServiceInfos.get(0);
return getServiceConnector(matchingServiceInfo, serviceConnectorType, serviceConnectorConfig);
}
use of org.springframework.cloud.service.ServiceInfo in project spring-cloud-connectors by spring-cloud.
the class LocalConfigConnectorMysqlServiceTest method serviceCreation.
@Test
public void serviceCreation() {
List<ServiceInfo> services = connector.getServiceInfos();
ServiceInfo service = getServiceInfo(services, "maria");
assertNotNull(service);
assertTrue(service instanceof MysqlServiceInfo);
assertUriParameters((MysqlServiceInfo) service);
}
use of org.springframework.cloud.service.ServiceInfo in project spring-cloud-connectors by spring-cloud.
the class LocalConfigConnectorPostgresqlServiceTest method serviceCreation.
@Test
public void serviceCreation() {
List<ServiceInfo> services = connector.getServiceInfos();
ServiceInfo service = getServiceInfo(services, "ingres");
assertNotNull(service);
assertTrue(service instanceof PostgresqlServiceInfo);
assertUriParameters((PostgresqlServiceInfo) service);
}
use of org.springframework.cloud.service.ServiceInfo in project spring-cloud-connectors by spring-cloud.
the class LocalConfigConnectorRedisServiceTest method serviceCreation.
@Test
public void serviceCreation() {
List<ServiceInfo> services = connector.getServiceInfos();
ServiceInfo service = getServiceInfo(services, "blue");
assertNotNull(service);
assertTrue(service instanceof RedisServiceInfo);
assertUriParameters((RedisServiceInfo) service);
}
Aggregations