当前位置: 首页>>代码示例>>Java>>正文


Java ServiceInfo类代码示例

本文整理汇总了Java中org.springframework.cloud.service.ServiceInfo的典型用法代码示例。如果您正苦于以下问题:Java ServiceInfo类的具体用法?Java ServiceInfo怎么用?Java ServiceInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ServiceInfo类属于org.springframework.cloud.service包,在下文中一共展示了ServiceInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onApplicationEvent

import org.springframework.cloud.service.ServiceInfo; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {

	if (cloud == null) {
		return;
	}

	for (ServiceInfo serviceInfo : cloud.getServiceInfos()) {

		if (serviceInfoType.isAssignableFrom(serviceInfo.getClass())) {

			PropertySource<?> propertySource = toPropertySource((T) serviceInfo);
			event.getEnvironment().getPropertySources().addFirst(propertySource);
		}
	}

}
 
开发者ID:pivotal-cf,项目名称:spring-cloud-vault-connector,代码行数:19,代码来源:ServiceInfoPropertySourceAdapter.java

示例2: getMatchOutcome

import org.springframework.cloud.service.ServiceInfo; //导入依赖的package包/类
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
		AnnotatedTypeMetadata metadata) {

	CloudFactory cloudFactory = new CloudFactory();
	try {
		Cloud cloud = cloudFactory.getCloud();
		List<ServiceInfo> serviceInfos = cloud.getServiceInfos();

		for (ServiceInfo serviceInfo : serviceInfos) {
			if (serviceInfo instanceof VaultServiceInfo) {
				return ConditionOutcome.match(String.format(
						"Found Vault service %s", serviceInfo.getId()));
			}
		}

		return ConditionOutcome.noMatch("No Vault service found");
	}
	catch (CloudException e) {
		return ConditionOutcome.noMatch("Not running in a Cloud");
	}
}
 
开发者ID:pivotal-cf,项目名称:spring-cloud-vault-connector,代码行数:23,代码来源:VaultConnectorBootstrapConfiguration.java

示例3: s3BucketServiceCreation

import org.springframework.cloud.service.ServiceInfo; //导入依赖的package包/类
@Test
public void s3BucketServiceCreation() {
    String bucketName1 = "bucket-1";
    String bucketName2 = "bucket-2";
    when(this.mockEnvironment.getEnvValue("VCAP_SERVICES"))
            .thenReturn(
                    getServicesPayload(
                            getS3BucketServicePayload("s3-1", "10.20.30.40", 80, accessKeyId, secretAccessKey, bucketName1),
                            getS3BucketServicePayload("s3-2", "10.20.30.40", 80, accessKeyId, secretAccessKey, bucketName2)
                    )
            );
    List<ServiceInfo> serviceInfos = this.testCloudConnector.getServiceInfos();
    S3ServiceInfo info1 = (S3ServiceInfo) getServiceInfo(serviceInfos, "s3-1");
    S3ServiceInfo info2 = (S3ServiceInfo) getServiceInfo(serviceInfos, "s3-2");
    assertServiceFoundOfType(info1, S3ServiceInfo.class);
    assertEquals(bucketName1, info1.getBucket());
    assertEquals(bucketName2, info2.getBucket());
    assertEquals(accessKeyId, info1.getAccessKey());
    assertEquals(accessKeyId, info2.getAccessKey());
    assertEquals(secretAccessKey, info1.getSecretKey());
    assertEquals(secretAccessKey, info2.getSecretKey());
    assertEquals(getUrl(), info1.getEndpoint());
    assertEquals(getUrl(), info2.getEndpoint());
}
 
开发者ID:spiegela,项目名称:spring-cloud-ecs-connector,代码行数:25,代码来源:CloudFoundryConnectorS3ServiceTest.java

示例4: s3NamespaceServiceCreation

import org.springframework.cloud.service.ServiceInfo; //导入依赖的package包/类
@Test
public void s3NamespaceServiceCreation() {
    when(this.mockEnvironment.getEnvValue("VCAP_SERVICES"))
            .thenReturn(
                    getServicesPayload(
                            getS3NamespaceServicePayload("s3-ns-1", "10.20.30.40", 80, accessKeyId, secretAccessKey)
                    )
            );
    List<ServiceInfo> serviceInfos = this.testCloudConnector.getServiceInfos();
    S3ServiceInfo info1 = (S3ServiceInfo) getServiceInfo(serviceInfos, "s3-ns-1");
    assertServiceFoundOfType(info1, S3ServiceInfo.class);
    assertEquals(null, info1.getBucket());
    assertEquals(accessKeyId, info1.getAccessKey());
    assertEquals(secretAccessKey, info1.getSecretKey());
    assertEquals(getUrl(), info1.getEndpoint());
}
 
开发者ID:spiegela,项目名称:spring-cloud-ecs-connector,代码行数:17,代码来源:CloudFoundryConnectorS3ServiceTest.java

示例5: provide

import org.springframework.cloud.service.ServiceInfo; //导入依赖的package包/类
@Override
public final Properties provide(ServiceInfo serviceInfo, Properties defaultConfiguration) {
    if (!canProvide(serviceInfo)) {
        throw new ConfigurationException("Cannot provide properties for: " + serviceInfo);
    }

    final RelationalServiceInfo serviceConfig = (RelationalServiceInfo) serviceInfo;
    defaultConfiguration.setProperty(PROPERTY_JDBC_URL, serviceConfig.getJdbcUrl());
    defaultConfiguration.setProperty(PROPERTY_USER_NAME, serviceConfig.getUserName());
    defaultConfiguration.setProperty(PROPERTY_PASSWORD, serviceConfig.getPassword());
    defaultConfiguration.setProperty(PROPERTY_TEST_ON_BORROW, "true");
    defaultConfiguration.put(PROPERTY_PASSWORD_CIPHER, "PlainText");

    configureConnectionPool(defaultConfiguration);

    configure(serviceConfig, defaultConfiguration);
    return defaultConfiguration;
}
 
开发者ID:cloudfoundry-community,项目名称:tomee-buildpack-resource-configuration,代码行数:19,代码来源:RelationalServicePropertiesProvider.java

示例6: SsoServiceInfoCreatorInitializer

import org.springframework.cloud.service.ServiceInfo; //导入依赖的package包/类
public SsoServiceInfoCreatorInitializer(CloudFactory cloudFactory, Environment environment) {
    this.cloudFactory = cloudFactory;
    this.environment = environment;
    List<ServiceInfo> serviceInfos = cloudFactory.getCloud().getServiceInfos();
    for(ServiceInfo s : serviceInfos) {
        if (s instanceof SsoServiceInfo) {
            Map<String, Object> map = new HashMap<String, Object>();
            SsoServiceInfo ssoServiceInfo = (SsoServiceInfo) s;
            map.put(SPRING_OAUTH2_CLIENT_ID, ssoServiceInfo.getClientId());
            map.put(SPRING_OAUTH2_CLIENT_SECRET, ssoServiceInfo.getClientSecret());
            map.put(SPRING_OAUTH2_ACCESS_TOKEN_URI, ssoServiceInfo.getAuthDomain() + "/oauth/token");
            map.put(SPRING_OAUTH2_AUTHORIZE_URI, ssoServiceInfo.getAuthDomain() + "/oauth/authorize");
            map.put(SPRING_OAUTH2_KEY_URI, ssoServiceInfo.getAuthDomain() + "/token_key");
            map.put(SSO_SERVICE_URL, ssoServiceInfo.getAuthDomain());
            map.put(SPRING_OAUTH2_USER_INFO_URI, ssoServiceInfo.getAuthDomain() + "/userinfo");
            map.put(SPRING_OAUTH2_TOKEN_INFO_URI, ssoServiceInfo.getAuthDomain() + "/check_token");
            MapPropertySource mapPropertySource = new MapPropertySource(PROPERTY_SOURCE_NAME, map);

            ((ConfigurableEnvironment) environment).getPropertySources().addFirst(mapPropertySource);
        }
    }
}
 
开发者ID:pivotal-cf,项目名称:identity-sample-apps,代码行数:23,代码来源:SsoServiceInfoCreatorInitializer.java

示例7: postgresqlServiceCreation

import org.springframework.cloud.service.ServiceInfo; //导入依赖的package包/类
@Test
public void postgresqlServiceCreation() {
	String name1 = "database-1";
	String name2 = "database-2";
	when(mockEnvironment.getEnvValue("VCAP_SERVICES"))
			.thenReturn(getServicesPayload(
					getPostgresqlServicePayload("postgresql-1", hostname, port, username, password, name1),
					getPostgresqlServicePayload("postgresql-2", hostname, port, username, password, name2)));

	List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos();
	ServiceInfo info1 = getServiceInfo(serviceInfos, "postgresql-1");
	ServiceInfo info2 = getServiceInfo(serviceInfos, "postgresql-2");

	assertServiceFoundOfType(info1, PostgresqlServiceInfo.class);
	assertServiceFoundOfType(info2, PostgresqlServiceInfo.class);

	assertJdbcUrlEqual(info1, POSTGRES_SCHEME, name1);
	assertJdbcUrlEqual(info2, POSTGRES_SCHEME, name2);

	assertUriBasedServiceInfoFields(info1, POSTGRES_SCHEME, hostname, port, username, password, name1);
	assertUriBasedServiceInfoFields(info2, POSTGRES_SCHEME, hostname, port, username, password, name2);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-connectors,代码行数:23,代码来源:CloudFoundryConnectorPostgresqlServiceTest.java

示例8: compositeServiceInfoRecursive

import org.springframework.cloud.service.ServiceInfo; //导入依赖的package包/类
@Test
public void compositeServiceInfoRecursive() {
    StubServiceInfo testServiceInfo1a = new StubServiceInfo("test-id-1a", "test-host", 1000, "test-username", "test-password");
    StubServiceInfo testServiceInfo1b = new StubServiceInfo("test-id-1b", "test-host", 1000, "test-username", "test-password");
    ServiceInfo testCompositeServiceInfo1 = new StubCompositeServiceInfo("test-composite-1",testServiceInfo1a, testServiceInfo1b);

    StubServiceInfo testServiceInfo2a = new StubServiceInfo("test-id-2a", "test-host", 1000, "test-username", "test-password");
    StubServiceInfo testServiceInfo2b = new StubServiceInfo("test-id-2b", "test-host", 1000, "test-username", "test-password");
    ServiceInfo testCompositeServiceInfo2 = new StubCompositeServiceInfo("test-composite-2",testServiceInfo2a, testServiceInfo2b);
    
    ServiceInfo testCompositeServiceInfo = new StubCompositeServiceInfo("test-composite",testCompositeServiceInfo1, testCompositeServiceInfo2);

    StubCloudConnector stubCloudConnector = CloudTestUtil.getTestCloudConnector(testCompositeServiceInfo);
    Cloud testCloud = new Cloud(stubCloudConnector, serviceConnectorCreators);
    
    assertNotNull(testCloud.getServiceInfo("test-id-1a"));
    assertNotNull(testCloud.getServiceInfo("test-id-1b"));
    assertNotNull(testCloud.getServiceInfo("test-id-2a"));
    assertNotNull(testCloud.getServiceInfo("test-id-2b"));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-connectors,代码行数:21,代码来源:CloudTest.java

示例9: postgresqlServiceCreationWithJdbcUrl

import org.springframework.cloud.service.ServiceInfo; //导入依赖的package包/类
@Test
public void postgresqlServiceCreationWithJdbcUrl() {
	String name1 = "database-1";
	String name2 = "database-2";
	when(mockEnvironment.getEnvValue("VCAP_SERVICES"))
			.thenReturn(getServicesPayload(
					getPostgresqlServicePayloadWithJdbcUrl("postgresql-1", hostname, port, username, password, name1),
					getPostgresqlServicePayloadWithJdbcUrl("postgresql-2", hostname, port, username, password, name2)));

	List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos();
	ServiceInfo info1 = getServiceInfo(serviceInfos, "postgresql-1");
	ServiceInfo info2 = getServiceInfo(serviceInfos, "postgresql-2");

	assertServiceFoundOfType(info1, PostgresqlServiceInfo.class);
	assertServiceFoundOfType(info2, PostgresqlServiceInfo.class);

	assertJdbcUrlEqual(info1, POSTGRES_SCHEME, name1);
	assertJdbcUrlEqual(info2, POSTGRES_SCHEME, name2);

	assertUriBasedServiceInfoFields(info1, POSTGRES_SCHEME, hostname, port, username, password, name1);
	assertUriBasedServiceInfoFields(info2, POSTGRES_SCHEME, hostname, port, username, password, name2);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-connectors,代码行数:23,代码来源:CloudFoundryConnectorPostgresqlServiceTest.java

示例10: registerServiceBean

import org.springframework.cloud.service.ServiceInfo; //导入依赖的package包/类
private void registerServiceBean(BeanDefinitionRegistry registry, ServiceInfo serviceInfo) {
	try {
		GenericCloudServiceConnectorFactory serviceFactory =
				new GenericCloudServiceConnectorFactory(serviceInfo.getId(), null);
		serviceFactory.setBeanFactory((BeanFactory) registry);
		serviceFactory.afterPropertiesSet();
		BeanDefinitionBuilder definitionBuilder =
				BeanDefinitionBuilder.genericBeanDefinition(ScannedServiceWrapper.class);
		definitionBuilder.addConstructorArgValue(serviceFactory);
		definitionBuilder.getRawBeanDefinition().setAttribute(
								  "factoryBeanObjectType", serviceFactory.getObjectType());
		registry.registerBeanDefinition(serviceInfo.getId(), definitionBuilder.getBeanDefinition());
	} catch (Exception ex) {
		logger.fine("Unable to create service for " + serviceInfo.getId() + " during service scanning. Skipping.");
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-connectors,代码行数:17,代码来源:CloudScanHelper.java

示例11: mysqlServiceCreation

import org.springframework.cloud.service.ServiceInfo; //导入依赖的package包/类
@Test
public void mysqlServiceCreation() {
	String name1 = "database-1";
	String name2 = "database-2";
	when(mockEnvironment.getEnvValue("VCAP_SERVICES"))
		.thenReturn(getServicesPayload(
						getMysqlServicePayload("mysql-1", hostname, port, username, password, name1),
						getMysqlServicePayload("mysql-2", hostname, port, username, password, name2)));
	List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos();

	ServiceInfo info1 = getServiceInfo(serviceInfos, "mysql-1");
	ServiceInfo info2 = getServiceInfo(serviceInfos, "mysql-2");

	assertServiceFoundOfType(info1, MysqlServiceInfo.class);
	assertServiceFoundOfType(info2, MysqlServiceInfo.class);

	assertJdbcUrlEqual(info1, MYSQL_SCHEME, name1);
	assertJdbcUrlEqual(info2, MYSQL_SCHEME, name2);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-connectors,代码行数:20,代码来源:CloudFoundryConnectorMysqlServiceTest.java

示例12: mysqlServiceCreationWithLabelNoTags

import org.springframework.cloud.service.ServiceInfo; //导入依赖的package包/类
@Test
public void mysqlServiceCreationWithLabelNoTags() {
	String name1 = "database-1";
	String name2 = "database-2";
	when(mockEnvironment.getEnvValue("VCAP_SERVICES"))
		.thenReturn(getServicesPayload(
						getMysqlServicePayloadWithLabelNoTags("mysql-1", hostname, port, username, password, name1),
						getMysqlServicePayloadWithLabelNoTags("mysql-2", hostname, port, username, password, name2)));
	List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos();

	ServiceInfo info1 = getServiceInfo(serviceInfos, "mysql-1");
	ServiceInfo info2 = getServiceInfo(serviceInfos, "mysql-2");

	assertServiceFoundOfType(info1, MysqlServiceInfo.class);
	assertServiceFoundOfType(info2, MysqlServiceInfo.class);

	assertJdbcUrlEqual(info1, MYSQL_SCHEME, name1);
	assertJdbcUrlEqual(info2, MYSQL_SCHEME, name2);

	assertUriBasedServiceInfoFields(info1, MYSQL_SCHEME, hostname, port, username, password, name1);
	assertUriBasedServiceInfoFields(info2, MYSQL_SCHEME, hostname, port, username, password, name2);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-connectors,代码行数:23,代码来源:CloudFoundryConnectorMysqlServiceTest.java

示例13: mysqlServiceCreationNoLabelNoTags

import org.springframework.cloud.service.ServiceInfo; //导入依赖的package包/类
@Test
public void mysqlServiceCreationNoLabelNoTags() {
	String name1 = "database-1";
	String name2 = "database-2";
	when(mockEnvironment.getEnvValue("VCAP_SERVICES"))
			.thenReturn(getServicesPayload(
					getMysqlServicePayloadNoLabelNoTags("mysql-1", hostname, port, username, password, name1),
					getMysqlServicePayloadNoLabelNoTags("mysql-2", hostname, port, username, password, name2)));
	List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos();

	ServiceInfo info1 = getServiceInfo(serviceInfos, "mysql-1");
	ServiceInfo info2 = getServiceInfo(serviceInfos, "mysql-2");

	assertServiceFoundOfType(info1, MysqlServiceInfo.class);
	assertServiceFoundOfType(info2, MysqlServiceInfo.class);

	assertJdbcUrlEqual(info1, MYSQL_SCHEME, name1);
	assertJdbcUrlEqual(info2, MYSQL_SCHEME, name2);

	assertUriBasedServiceInfoFields(info1, MYSQL_SCHEME, hostname, port, username, password, name1);
	assertUriBasedServiceInfoFields(info2, MYSQL_SCHEME, hostname, port, username, password, name2);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-connectors,代码行数:23,代码来源:CloudFoundryConnectorMysqlServiceTest.java

示例14: mysqlServiceCreationWithJdbcUrl

import org.springframework.cloud.service.ServiceInfo; //导入依赖的package包/类
@Test
public void mysqlServiceCreationWithJdbcUrl() {
	String name1 = "database-1";
	String name2 = "database-2";
	when(mockEnvironment.getEnvValue("VCAP_SERVICES"))
			.thenReturn(getServicesPayload(
					getMysqlServicePayloadWithJdbcUrl("mysql-1", hostname, port, username, password, name1),
					getMysqlServicePayloadWithJdbcUrl("mysql-2", hostname, port, username, password, name2)));
	List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos();

	ServiceInfo info1 = getServiceInfo(serviceInfos, "mysql-1");
	ServiceInfo info2 = getServiceInfo(serviceInfos, "mysql-2");

	assertServiceFoundOfType(info1, MysqlServiceInfo.class);
	assertServiceFoundOfType(info2, MysqlServiceInfo.class);

	assertJdbcUrlEqual(info1, MYSQL_SCHEME, name1);
	assertJdbcUrlEqual(info2, MYSQL_SCHEME, name2);

	assertUriBasedServiceInfoFields(info1, MYSQL_SCHEME, hostname, port, username, password, name1);
	assertUriBasedServiceInfoFields(info2, MYSQL_SCHEME, hostname, port, username, password, name2);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-connectors,代码行数:23,代码来源:CloudFoundryConnectorMysqlServiceTest.java

示例15: VaultConnectorBootstrapConfiguration

import org.springframework.cloud.service.ServiceInfo; //导入依赖的package包/类
public VaultConnectorBootstrapConfiguration(
		VaultConnectorGenericBackendProperties connectorVaultProperties,
		VaultGenericBackendProperties genericBackendProperties,
		Environment environment) {

	this.connectorVaultProperties = connectorVaultProperties;
	this.genericBackendProperties = genericBackendProperties;
	this.environment = environment;

	Cloud cloud;
	VaultServiceInfo vaultServiceInfo = null;

	try {
		CloudFactory cloudFactory = new CloudFactory();
		cloud = cloudFactory.getCloud();

		List<ServiceInfo> serviceInfos = cloud.getServiceInfos(VaultOperations.class);
		if (serviceInfos.size() == 1) {
			vaultServiceInfo = (VaultServiceInfo) serviceInfos.get(0);
		}
	}
	catch (CloudException e) {
		// not running in a Cloud environment
	}

	this.vaultServiceInfo = vaultServiceInfo;
}
 
开发者ID:pivotal-cf,项目名称:spring-cloud-vault-connector,代码行数:28,代码来源:VaultConnectorBootstrapConfiguration.java


注:本文中的org.springframework.cloud.service.ServiceInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。