org.springframework.boot.cloud.CloudPlatform Java Examples
The following examples show how to use
org.springframework.boot.cloud.CloudPlatform.
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: ApplicationConfiguration.java From bookstore-service-broker with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnCloudPlatform(CloudPlatform.CLOUD_FOUNDRY) public ApplicationInformation cloudFoundryApplicationInformation(Environment environment) { String uri = environment.getProperty("vcap.application.uris[0]"); String baseUrl = UriComponentsBuilder.newInstance() .scheme("https") .host(uri) .build() .toUriString(); return new ApplicationInformation(baseUrl); }
Example #2
Source File: SchedulerPerPlatformTest.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
@Test public void testLocalSchedulerEnabled() { assertFalse("K8s should be disabled", context.getEnvironment().containsProperty("kubernetes_service_host")); assertFalse("CF should be disabled", CloudPlatform.CLOUD_FOUNDRY.isActive(context.getEnvironment())); Scheduler scheduler = context.getBean(Scheduler.class); assertNotNull(scheduler); assertTrue(scheduler.getClass().getName().contains("LocalSchedulerAutoConfiguration")); }
Example #3
Source File: SchedulerPerPlatformTest.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
@Test public void testKubernetesSchedulerEnabled() { assertTrue("K8s should be enabled", context.getEnvironment().containsProperty("kubernetes_service_host")); assertFalse("CF should be disabled", CloudPlatform.CLOUD_FOUNDRY.isActive(context.getEnvironment())); KubernetesSchedulerProperties props = context.getBean(KubernetesSchedulerProperties.class); assertNotNull(props); }
Example #4
Source File: SchedulerPerPlatformTest.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
@Test public void testCloudFoundryScheudlerEnabled() { assertFalse("K8s should be disabled", context.getEnvironment().containsProperty("kubernetes_service_host")); assertTrue("CF should be enabled", CloudPlatform.CLOUD_FOUNDRY.isActive(context.getEnvironment())); CloudFoundrySchedulerProperties props = context.getBean(CloudFoundrySchedulerProperties.class); assertNotNull(props); }
Example #5
Source File: CfDataSourceEnvironmentPostProcessor.java From java-cfenv with Apache License 2.0 | 4 votes |
@Override public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { increaseInvocationCount(); if (CloudPlatform.CLOUD_FOUNDRY.isActive(environment)) { CfJdbcEnv cfJdbcEnv = new CfJdbcEnv(); CfJdbcService cfJdbcService = null; try { cfJdbcService = cfJdbcEnv.findJdbcService(); cfJdbcService = this.isEnabled(cfJdbcService, environment) ? cfJdbcService : null; } catch (Exception e) { List<CfJdbcService> jdbcServices = cfJdbcEnv.findJdbcServices().stream() .filter(service -> this.isEnabled(service, environment)) .collect(Collectors.toList()); if (jdbcServices.size() > 1) { if (invocationCount == 1) { DEFERRED_LOG.debug( "Skipping execution of CfDataSourceEnvironmentPostProcessor. " + e.getMessage()); } return; } cfJdbcService = jdbcServices.size() == 1 ? jdbcServices.get(0) : null; } if (cfJdbcService != null) { ConnectorLibraryDetector.assertNoConnectorLibrary(); Map<String, Object> properties = new LinkedHashMap<>(); properties.put("spring.datasource.url", cfJdbcService.getJdbcUrl()); properties.put("spring.datasource.username", cfJdbcService.getUsername()); properties.put("spring.datasource.password", cfJdbcService.getPassword()); Object driverClassName = cfJdbcService.getDriverClassName(); if (driverClassName != null) { properties.put("spring.datasource.driver-class-name", driverClassName); } MutablePropertySources propertySources = environment.getPropertySources(); if (propertySources.contains( CommandLinePropertySource.COMMAND_LINE_PROPERTY_SOURCE_NAME)) { propertySources.addAfter( CommandLinePropertySource.COMMAND_LINE_PROPERTY_SOURCE_NAME, new MapPropertySource("cfenvjdbc", properties)); } else { propertySources .addFirst(new MapPropertySource("cfenvjdbc", properties)); } if (invocationCount == 1) { DEFERRED_LOG.info( "Setting spring.datasource properties from bound service [" + cfJdbcService.getName() + "]"); } } } else { DEFERRED_LOG.debug( "Not setting spring.datasource.url, not in Cloud Foundry Environment"); } }
Example #6
Source File: ClusterNotAvailableConfiguration.java From spring-boot-data-geode with Apache License 2.0 | 4 votes |
@Override public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { return !CloudPlatform.CLOUD_FOUNDRY.isActive(context.getEnvironment()); }
Example #7
Source File: ClientSecurityAutoConfiguration.java From spring-boot-data-geode with Apache License 2.0 | 4 votes |
private boolean isCloudFoundryEnvironment(Environment environment) { return CloudPlatform.CLOUD_FOUNDRY.isActive(environment); }
Example #8
Source File: SchedulerPerPlatformTest.java From spring-cloud-dataflow with Apache License 2.0 | 4 votes |
@Test(expected = NoSuchBeanDefinitionException.class) public void testLocalSchedulerEnabled() { assertFalse(context.getEnvironment().containsProperty("kubernetes_service_host")); assertFalse(CloudPlatform.CLOUD_FOUNDRY.isActive(context.getEnvironment())); context.getBean(Scheduler.class); }
Example #9
Source File: ClientProperties.java From spring-boot-admin with Apache License 2.0 | 4 votes |
public boolean isAutoDeregistration(Environment environment) { return (this.autoDeregistration != null) ? this.autoDeregistration : (CloudPlatform.getActive(environment) != null); }