Extract common config utility into a separate package

This commit is contained in:
Dave Syer
2015-02-06 10:14:11 +00:00
parent 376065c41a
commit 222b33af29
7 changed files with 19 additions and 24 deletions

View File

@@ -39,25 +39,21 @@ import org.springframework.core.annotation.Order;
*/
@Configuration
@ConditionalOnClass(HealthIndicator.class)
@ConditionalOnBean(DiscoveryClient.class)
@ConditionalOnProperty(value = "spring.cloud.discovery.enabled", matchIfMissing = true)
@Order(0)
public class CommonsClientAutoConfiguration {
@Configuration
@ConditionalOnBean(DiscoveryClient.class)
@ConditionalOnProperty(value = "spring.cloud.discovery.enabled", matchIfMissing = true)
protected static class HealthConfiguration {
@Bean
public DiscoveryClientHealthIndicator instancesHealthIndicator(
DiscoveryClient discoveryClient) {
return new DiscoveryClientHealthIndicator(discoveryClient);
}
@Bean
public DiscoveryCompositeHealthIndicator discoveryHealthIndicator(
HealthAggregator aggregator, List<DiscoveryHealthIndicator> indicators) {
return new DiscoveryCompositeHealthIndicator(aggregator, indicators);
}
@Bean
public DiscoveryClientHealthIndicator instancesHealthIndicator(
DiscoveryClient discoveryClient) {
return new DiscoveryClientHealthIndicator(discoveryClient);
}
@Bean
public DiscoveryCompositeHealthIndicator discoveryHealthIndicator(
HealthAggregator aggregator, List<DiscoveryHealthIndicator> indicators) {
return new DiscoveryCompositeHealthIndicator(aggregator, indicators);
}
}

View File

@@ -21,8 +21,6 @@ package org.springframework.cloud.client;
*/
public interface ServiceInstance {
// TODO: name? Server? HostAndPort? Instance?
public String getServiceId();
public String getHost();

View File

@@ -17,7 +17,7 @@
package org.springframework.cloud.client.circuitbreaker;
import org.springframework.boot.bind.RelaxedPropertyResolver;
import org.springframework.cloud.client.SingleImplementationImportSelector;
import org.springframework.cloud.util.SingleImplementationImportSelector;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;

View File

@@ -17,7 +17,7 @@
package org.springframework.cloud.client.discovery;
import org.springframework.boot.bind.RelaxedPropertyResolver;
import org.springframework.cloud.client.SingleImplementationImportSelector;
import org.springframework.cloud.util.SingleImplementationImportSelector;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.cloud.client;
package org.springframework.cloud.util;
import java.util.ArrayList;
import java.util.Collections;

View File

@@ -1,4 +1,4 @@
# Bootstrap Configuration
# AutoConfiguration
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.springframework.cloud.client.CommonsClientAutoConfiguration,\
org.springframework.cloud.client.discovery.noop.NoopDiscoveryClientAutoConfiguration

View File

@@ -14,9 +14,10 @@
* limitations under the License.
*/
package org.springframework.cloud.client;
package org.springframework.cloud.util;
import org.junit.Test;
import org.springframework.cloud.util.SingleImplementationImportSelector;
import static org.junit.Assert.assertEquals;