diff --git a/spring-cloud-cloudfoundry-commons/src/main/java/org/springframework/cloud/cloudfoundry/CloudFoundryClientAutoConfiguration.java b/spring-cloud-cloudfoundry-commons/src/main/java/org/springframework/cloud/cloudfoundry/CloudFoundryClientAutoConfiguration.java index b84c43a..964db7f 100644 --- a/spring-cloud-cloudfoundry-commons/src/main/java/org/springframework/cloud/cloudfoundry/CloudFoundryClientAutoConfiguration.java +++ b/spring-cloud-cloudfoundry-commons/src/main/java/org/springframework/cloud/cloudfoundry/CloudFoundryClientAutoConfiguration.java @@ -47,8 +47,8 @@ import org.springframework.context.annotation.Lazy; * @author Scott Frederick */ @Configuration -@ConditionalOnProperty(prefix = "spring.cloud.cloudfoundry", name = { "username", - "password" }) +@ConditionalOnProperty(prefix = "spring.cloud.cloudfoundry", + name = { "username", "password" }) @ConditionalOnClass(name = { "reactor.core.publisher.Flux", "org.cloudfoundry.operations.DefaultCloudFoundryOperations", "org.cloudfoundry.reactor.client.ReactorCloudFoundryClient", diff --git a/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryAppServiceDiscoveryClient.java b/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryAppServiceDiscoveryClient.java index c782a69..8e73127 100644 --- a/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryAppServiceDiscoveryClient.java +++ b/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryAppServiceDiscoveryClient.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.cloudfoundry.discovery; import java.util.HashMap; @@ -6,6 +22,7 @@ import java.util.List; import org.cloudfoundry.operations.CloudFoundryOperations; import org.cloudfoundry.operations.applications.ApplicationDetail; import org.cloudfoundry.operations.applications.InstanceDetail; + import org.springframework.cloud.client.DefaultServiceInstance; import org.springframework.cloud.client.ServiceInstance; import org.springframework.cloud.cloudfoundry.CloudFoundryService; @@ -13,15 +30,15 @@ import org.springframework.cloud.cloudfoundry.CloudFoundryService; /** * * Discovery Client implementation using Cloud Foundry's Native DNS based Service - * Discovery + * Discovery. + * + * @author Toshiaki Maki * * @see CF App Service * Discovery Release * @see Polyglot * Service Discovery for Container Networking in Cloud Foundry - * - * @author Toshiaki Maki */ public class CloudFoundryAppServiceDiscoveryClient extends CloudFoundryDiscoveryClient { diff --git a/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryClientConfiguration.java b/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryClientConfiguration.java index 1db38c9..8a0dc51 100644 --- a/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryClientConfiguration.java +++ b/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryClientConfiguration.java @@ -17,6 +17,7 @@ package org.springframework.cloud.cloudfoundry.discovery; import org.cloudfoundry.operations.CloudFoundryOperations; + import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; @@ -38,12 +39,19 @@ import org.springframework.context.annotation.Configuration; @EnableConfigurationProperties(CloudFoundryDiscoveryProperties.class) public class CloudFoundryDiscoveryClientConfiguration { + @Bean + @ConditionalOnBean(CloudFoundryDiscoveryClient.class) + public CloudFoundryHeartbeatSender cloudFoundryHeartbeatSender( + CloudFoundryDiscoveryClient client) { + return new CloudFoundryHeartbeatSender(client); + } + @Configuration @ConditionalOnProperty(value = "spring.cloud.cloudfoundry.discovery.use-dns", havingValue = "false", matchIfMissing = true) public static class CloudFoundryDiscoveryClientConfig { @Bean @ConditionalOnMissingBean(DiscoveryClient.class) - public DiscoveryClient cloudFoundryDiscoveryClient(CloudFoundryOperations cf, + public CloudFoundryDiscoveryClient cloudFoundryDiscoveryClient(CloudFoundryOperations cf, CloudFoundryService svc, CloudFoundryDiscoveryProperties cloudFoundryDiscoveryProperties) { return new CloudFoundryDiscoveryClient(cf, svc, @@ -58,7 +66,7 @@ public class CloudFoundryDiscoveryClientConfiguration { @Bean @ConditionalOnProperty(value = "spring.cloud.cloudfoundry.discovery.use-container-ip", havingValue = "true") @ConditionalOnMissingBean(DiscoveryClient.class) - public DiscoveryClient discoveryClient( + public SimpleDnsBasedDiscoveryClient discoveryClient( ObjectProvider provider) { ServiceIdToHostnameConverter converter = provider.getIfAvailable(); return converter == null ? new SimpleDnsBasedDiscoveryClient() @@ -68,7 +76,7 @@ public class CloudFoundryDiscoveryClientConfiguration { @Bean @ConditionalOnProperty(value = "spring.cloud.cloudfoundry.discovery.use-container-ip", havingValue = "false", matchIfMissing = true) @ConditionalOnMissingBean(DiscoveryClient.class) - public DiscoveryClient cloudFoundryDiscoveryClient(CloudFoundryOperations cf, + public CloudFoundryAppServiceDiscoveryClient cloudFoundryDiscoveryClient(CloudFoundryOperations cf, CloudFoundryService svc, CloudFoundryDiscoveryProperties cloudFoundryDiscoveryProperties) { return new CloudFoundryAppServiceDiscoveryClient(cf, svc, @@ -76,11 +84,4 @@ public class CloudFoundryDiscoveryClientConfiguration { } } - @Bean - @ConditionalOnBean(CloudFoundryDiscoveryClient.class) - public CloudFoundryHeartbeatSender cloudFoundryHeartbeatSender( - CloudFoundryDiscoveryClient client) { - return new CloudFoundryHeartbeatSender(client); - } - } diff --git a/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/SimpleDnsBasedDiscoveryClient.java b/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/SimpleDnsBasedDiscoveryClient.java index 6ff3468..dd0f542 100644 --- a/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/SimpleDnsBasedDiscoveryClient.java +++ b/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/SimpleDnsBasedDiscoveryClient.java @@ -1,3 +1,18 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.cloud.cloudfoundry.discovery; @@ -9,19 +24,20 @@ import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + import org.springframework.cloud.client.DefaultServiceInstance; import org.springframework.cloud.client.ServiceInstance; import org.springframework.cloud.client.discovery.DiscoveryClient; /** * Discovery Client implementation using Cloud Foundry's Native DNS based Service - * Discovery + * Discovery. + * + * @author Toshiaki Maki * * @see Polyglot * Service Discovery for Container Networking in Cloud Foundry - * - * @author Toshiaki Maki */ public class SimpleDnsBasedDiscoveryClient implements DiscoveryClient { public static final String INTERNAL_DOMAIN = "apps.internal"; @@ -77,4 +93,4 @@ public class SimpleDnsBasedDiscoveryClient implements DiscoveryClient { public interface ServiceIdToHostnameConverter { String toHostname(String serviceId); } -} \ No newline at end of file +} diff --git a/spring-cloud-cloudfoundry-discovery/src/test/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryAppServiceDiscoveryClientTest.java b/spring-cloud-cloudfoundry-discovery/src/test/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryAppServiceDiscoveryClientTest.java index ab4cbb3..1599f7f 100644 --- a/spring-cloud-cloudfoundry-discovery/src/test/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryAppServiceDiscoveryClientTest.java +++ b/spring-cloud-cloudfoundry-discovery/src/test/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryAppServiceDiscoveryClientTest.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.cloudfoundry.discovery; import java.util.HashMap; @@ -8,6 +24,9 @@ import org.cloudfoundry.operations.applications.ApplicationDetail; import org.cloudfoundry.operations.applications.InstanceDetail; import org.junit.Before; import org.junit.Test; +import reactor.core.publisher.Flux; +import reactor.util.function.Tuples; + import org.springframework.cloud.client.DefaultServiceInstance; import org.springframework.cloud.client.ServiceInstance; import org.springframework.cloud.cloudfoundry.CloudFoundryService; @@ -16,9 +35,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; -import reactor.core.publisher.Flux; -import reactor.util.function.Tuples; - /** * @author Toshiaki Maki */ @@ -113,4 +129,4 @@ public class CloudFoundryAppServiceDiscoveryClientTest { assertThat(instances).isEmpty(); } -} \ No newline at end of file +} diff --git a/spring-cloud-cloudfoundry-discovery/src/test/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryClientConfigurationTest.java b/spring-cloud-cloudfoundry-discovery/src/test/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryClientConfigurationTest.java index aff67f5..b8a8e8c 100644 --- a/spring-cloud-cloudfoundry-discovery/src/test/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryClientConfigurationTest.java +++ b/spring-cloud-cloudfoundry-discovery/src/test/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryClientConfigurationTest.java @@ -1,8 +1,25 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.cloudfoundry.discovery; import org.cloudfoundry.operations.CloudFoundryOperations; import org.junit.Test; import org.mockito.Mockito; + import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.cloud.client.discovery.DiscoveryClient; @@ -95,4 +112,4 @@ public class CloudFoundryDiscoveryClientConfigurationTest { return Mockito.mock(CloudFoundryService.class); } } -} \ No newline at end of file +}