Search in sources :

Example 6 with ServiceInfo

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;
}
Also used : ServiceInfo(org.springframework.cloud.service.ServiceInfo) CompositeServiceInfo(org.springframework.cloud.service.CompositeServiceInfo) CompositeServiceInfo(org.springframework.cloud.service.CompositeServiceInfo) ArrayList(java.util.ArrayList)

Example 7 with ServiceInfo

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);
}
Also used : ServiceInfo(org.springframework.cloud.service.ServiceInfo) CompositeServiceInfo(org.springframework.cloud.service.CompositeServiceInfo)

Example 8 with ServiceInfo

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);
}
Also used : ServiceInfo(org.springframework.cloud.service.ServiceInfo) MysqlServiceInfo(org.springframework.cloud.service.common.MysqlServiceInfo) MysqlServiceInfo(org.springframework.cloud.service.common.MysqlServiceInfo) Test(org.junit.Test)

Example 9 with ServiceInfo

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);
}
Also used : ServiceInfo(org.springframework.cloud.service.ServiceInfo) PostgresqlServiceInfo(org.springframework.cloud.service.common.PostgresqlServiceInfo) PostgresqlServiceInfo(org.springframework.cloud.service.common.PostgresqlServiceInfo) Test(org.junit.Test)

Example 10 with ServiceInfo

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);
}
Also used : ServiceInfo(org.springframework.cloud.service.ServiceInfo) RedisServiceInfo(org.springframework.cloud.service.common.RedisServiceInfo) RedisServiceInfo(org.springframework.cloud.service.common.RedisServiceInfo) Test(org.junit.Test)

Aggregations

ServiceInfo (org.springframework.cloud.service.ServiceInfo)47 Test (org.junit.Test)37 MysqlServiceInfo (org.springframework.cloud.service.common.MysqlServiceInfo)16 AmqpServiceInfo (org.springframework.cloud.service.common.AmqpServiceInfo)8 HashMap (java.util.HashMap)6 CompositeServiceInfo (org.springframework.cloud.service.CompositeServiceInfo)5 MongoServiceInfo (org.springframework.cloud.service.common.MongoServiceInfo)5 PostgresqlServiceInfo (org.springframework.cloud.service.common.PostgresqlServiceInfo)5 RedisServiceInfo (org.springframework.cloud.service.common.RedisServiceInfo)4 ArrayList (java.util.ArrayList)3 UriBasedServiceInfo (org.springframework.cloud.service.UriBasedServiceInfo)3 DB2ServiceInfo (org.springframework.cloud.service.common.DB2ServiceInfo)3 OracleServiceInfo (org.springframework.cloud.service.common.OracleServiceInfo)3 SqlServerServiceInfo (org.springframework.cloud.service.common.SqlServerServiceInfo)3 StubCloudConnector (org.springframework.cloud.CloudTestUtil.StubCloudConnector)2 StubCompositeServiceInfo (org.springframework.cloud.CloudTestUtil.StubCompositeServiceInfo)2 StubServiceInfo (org.springframework.cloud.CloudTestUtil.StubServiceInfo)2 BaseServiceInfo (org.springframework.cloud.service.BaseServiceInfo)2 RelationalServiceInfo (org.springframework.cloud.service.common.RelationalServiceInfo)2 SmtpServiceInfo (org.springframework.cloud.service.common.SmtpServiceInfo)2