org.springframework.cloud.app.ApplicationInstanceInfo Java Examples

The following examples show how to use org.springframework.cloud.app.ApplicationInstanceInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HerokuConnector.java    From spring-cloud-connectors with Apache License 2.0 5 votes vote down vote up
@Override
public ApplicationInstanceInfo getApplicationInstanceInfo() {
	try {
		return applicationInstanceInfoCreator.createApplicationInstanceInfo();
	} catch (Exception e) {
		throw new CloudException(e);
	}
}
 
Example #2
Source File: LatticeConnector.java    From spring-cloud-lattice with Apache License 2.0 5 votes vote down vote up
@Override
public ApplicationInstanceInfo getApplicationInstanceInfo() {
	String instanceGuid = environment.getEnvValue("INSTANCE_GUID");
	String processGuid = environment.getEnvValue("PROCESS_GUID");
	//TODO: read receptor?
	HashMap<String, Object> map = new HashMap<>();
	return new BasicApplicationInstanceInfo(instanceGuid, processGuid, map);
}
 
Example #3
Source File: ApplicationInstanceInfoCreator.java    From spring-cloud-connectors with Apache License 2.0 5 votes vote down vote up
public ApplicationInstanceInfo createApplicationInstanceInfo() {
	String appname = environment.getEnvValue("SPRING_CLOUD_APP_NAME");
	if (appname == null) {
		logger.warning("Environment variable SPRING_CLOUD_APP_NAME not set. App name set to <unknown>");
		appname = "<unknown>";
	}
	
	String dyno = environment.getEnvValue("DYNO");

	Map<String,Object> appProperties = new HashMap<String, Object>();
	appProperties.put("port", environment.getEnvValue("PORT"));
	appProperties.put("host", environment.getHost());
	
	return new BasicApplicationInstanceInfo(dyno, appname, appProperties);
}
 
Example #4
Source File: CloudFoundryConnector.java    From spring-cloud-connectors with Apache License 2.0 5 votes vote down vote up
@Override
public ApplicationInstanceInfo getApplicationInstanceInfo() {
	try {
		@SuppressWarnings("unchecked")
		Map<String, Object> rawApplicationInstanceInfo 
			= objectMapper.readValue(environment.getEnvValue("VCAP_APPLICATION"), Map.class);
		return applicationInstanceInfoCreator.createApplicationInstanceInfo(rawApplicationInstanceInfo);
	} catch (Exception e) {
		throw new CloudException(e);
	} 
}
 
Example #5
Source File: CloudScanHelper.java    From spring-cloud-connectors with Apache License 2.0 5 votes vote down vote up
public void registerApplicationInstanceBean(BeanDefinitionRegistry registry) {
	initializeCloud(registry);

	BeanDefinitionBuilder definitionBuilder =
			BeanDefinitionBuilder.genericBeanDefinition(ApplicationInstanceInfoWrapper.class);
	definitionBuilder.addConstructorArgValue(cloud);
	definitionBuilder.getRawBeanDefinition().setAttribute(
							  "factoryBeanObjectType", ApplicationInstanceInfo.class);
	registry.registerBeanDefinition("spring.cloud.appplicationInstanceInfo", definitionBuilder.getBeanDefinition());
}
 
Example #6
Source File: CloudTestUtil.java    From spring-cloud-connectors with Apache License 2.0 4 votes vote down vote up
public static StubCloudConnector getTestCloudConnector(ApplicationInstanceInfo applicationInstanceInfo, ServiceInfo... serviceInfos) {
	final StubCloudConnector stubCloudConnector = getTestCloudConnector(serviceInfos);
	stubCloudConnector.setApplicationInstance(applicationInstanceInfo);
	
	return stubCloudConnector;
}
 
Example #7
Source File: LocalConfigConnector.java    From spring-cloud-connectors with Apache License 2.0 4 votes vote down vote up
@Override
public ApplicationInstanceInfo getApplicationInstanceInfo() {
	return new BasicApplicationInstanceInfo(UUID.randomUUID().toString(), findProperty(APP_ID_PROPERTY),
			Collections.<String, Object>emptyMap());
}
 
Example #8
Source File: ApplicationInstanceInfoCreator.java    From spring-cloud-connectors with Apache License 2.0 4 votes vote down vote up
public ApplicationInstanceInfo createApplicationInstanceInfo(Map<String, Object> applicationInstanceData) {
	String instanceId = (String) applicationInstanceData.get("instance_id");
	String appId = (String) applicationInstanceData.get("name"); 

	return new BasicApplicationInstanceInfo(instanceId, appId, applicationInstanceData);
}
 
Example #9
Source File: CloudScanJavaConfigTest.java    From spring-cloud-connectors with Apache License 2.0 4 votes vote down vote up
@Test
public void cloudScanIntroducesApplicationInstanceInfo() {
	ApplicationContext testContext = getTestApplicationContext();

	assertNotNull(testContext.getBean(ApplicationInstanceInfo.class));
}
 
Example #10
Source File: CloudScanHelper.java    From spring-cloud-connectors with Apache License 2.0 4 votes vote down vote up
@Override
public Class<?> getObjectType() {
	return ApplicationInstanceInfo.class;
}
 
Example #11
Source File: CloudScanHelper.java    From spring-cloud-connectors with Apache License 2.0 4 votes vote down vote up
@Override
public ApplicationInstanceInfo getObject() throws Exception {
	return cloud.getApplicationInstanceInfo();
}
 
Example #12
Source File: AbstractCloudConnectorTest.java    From spring-cloud-connectors with Apache License 2.0 4 votes vote down vote up
@Override
public ApplicationInstanceInfo getApplicationInstanceInfo() {
	return null;
}
 
Example #13
Source File: ExampleController.java    From building-microservices with Apache License 2.0 4 votes vote down vote up
public ExampleController(JdbcTemplate jdbc, ApplicationInstanceInfo info) {
	this.jdbc = jdbc;
	this.info = info;
}
 
Example #14
Source File: CloudTestUtil.java    From spring-cloud-connectors with Apache License 2.0 4 votes vote down vote up
public void setApplicationInstance(ApplicationInstanceInfo applicationInstance) {
	this.applicationInstance = applicationInstance;
}
 
Example #15
Source File: CloudTestUtil.java    From spring-cloud-connectors with Apache License 2.0 4 votes vote down vote up
@Override
public ApplicationInstanceInfo getApplicationInstanceInfo() {
	return applicationInstance;
}
 
Example #16
Source File: CloudConfig.java    From hello-spring-cloud with Apache License 2.0 4 votes vote down vote up
@Bean
public ApplicationInstanceInfo applicationInfo() {
    return cloud().getApplicationInstanceInfo();
}
 
Example #17
Source File: MockCloudConnector.java    From spring-cloud-services-connector with Apache License 2.0 4 votes vote down vote up
public ApplicationInstanceInfo getApplicationInstanceInfo() {
	return instance.getApplicationInstanceInfo();
}
 
Example #18
Source File: MockCloudConnector.java    From spring-cloud-sso-connector with Apache License 2.0 4 votes vote down vote up
public ApplicationInstanceInfo getApplicationInstanceInfo() {
    return instance.getApplicationInstanceInfo();
}
 
Example #19
Source File: ExampleController.java    From building-microservices with Apache License 2.0 4 votes vote down vote up
@RequestMapping("/cloudinfo")
public ApplicationInstanceInfo info() {
	return this.info;
}
 
Example #20
Source File: CloudConnector.java    From spring-cloud-connectors with Apache License 2.0 2 votes vote down vote up
/**
 * Get information about the application instance.
 * 
 * <p>
 * This method cannot return <code>null</code>, since that would imply there is no application instance.
 * 
 * @return info
 */
ApplicationInstanceInfo getApplicationInstanceInfo();
 
Example #21
Source File: Cloud.java    From spring-cloud-connectors with Apache License 2.0 2 votes vote down vote up
/**
 * @see CloudConnector#getApplicationInstanceInfo()
 *
 * @return information about the application instance
 */
public ApplicationInstanceInfo getApplicationInstanceInfo() {
	return cloudConnector.getApplicationInstanceInfo();
}