Browse Source

Move some discovery classes to subpackages.

Create discovey.event.ParentHeartbeatEvent for passing HearbeatEvents originating in a parent context to child contexts
pull/15/head
Spencer Gibb 10 years ago
parent
commit
f8f4408972
  1. 6
      src/main/java/org/springframework/cloud/client/CommonsClientAutoConfiguration.java
  2. 1
      src/main/java/org/springframework/cloud/client/discovery/AbstractDiscoveryLifecycle.java
  3. 6
      src/main/java/org/springframework/cloud/client/discovery/event/HeartbeatEvent.java
  4. 2
      src/main/java/org/springframework/cloud/client/discovery/event/InstanceRegisteredEvent.java
  5. 40
      src/main/java/org/springframework/cloud/client/discovery/event/ParentHeartbeatEvent.java
  6. 3
      src/main/java/org/springframework/cloud/client/discovery/health/DiscoveryClientHealthIndicator.java
  7. 2
      src/main/java/org/springframework/cloud/client/discovery/health/DiscoveryCompositeHealthIndicator.java
  8. 2
      src/main/java/org/springframework/cloud/client/discovery/health/DiscoveryHealthIndicator.java
  9. 3
      src/main/java/org/springframework/cloud/client/discovery/noop/NoopDiscoveryClient.java
  10. 4
      src/main/java/org/springframework/cloud/client/discovery/noop/NoopDiscoveryClientAutoConfiguration.java
  11. 2
      src/main/resources/META-INF/spring.factories
  12. 3
      src/test/java/org/springframework/cloud/client/discovery/health/DiscoveryCompositeHealthIndicatorTests.java
  13. 3
      src/test/java/org/springframework/cloud/client/discovery/noop/NoopDiscoveryClientConfigurationAdditionalTests.java
  14. 3
      src/test/java/org/springframework/cloud/client/discovery/noop/NoopDiscoveryClientConfigurationTests.java

6
src/main/java/org/springframework/cloud/client/CommonsClientAutoConfiguration.java

@ -25,9 +25,9 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; @@ -25,9 +25,9 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.client.discovery.DiscoveryClientHealthIndicator;
import org.springframework.cloud.client.discovery.DiscoveryCompositeHealthIndicator;
import org.springframework.cloud.client.discovery.DiscoveryHealthIndicator;
import org.springframework.cloud.client.discovery.health.DiscoveryClientHealthIndicator;
import org.springframework.cloud.client.discovery.health.DiscoveryCompositeHealthIndicator;
import org.springframework.cloud.client.discovery.health.DiscoveryHealthIndicator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;

1
src/main/java/org/springframework/cloud/client/discovery/AbstractDiscoveryLifecycle.java

@ -20,6 +20,7 @@ import javax.annotation.PreDestroy; @@ -20,6 +20,7 @@ import javax.annotation.PreDestroy;
import org.springframework.beans.BeansException;
import org.springframework.boot.actuate.autoconfigure.ManagementServerProperties;
import org.springframework.cloud.client.discovery.event.InstanceRegisteredEvent;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.core.env.Environment;

6
src/main/java/org/springframework/cloud/client/discovery/DiscoveryHeartbeatEvent.java → src/main/java/org/springframework/cloud/client/discovery/event/HeartbeatEvent.java

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.cloud.client.discovery;
package org.springframework.cloud.client.discovery.event;
import org.springframework.context.ApplicationEvent;
@ -22,11 +22,11 @@ import org.springframework.context.ApplicationEvent; @@ -22,11 +22,11 @@ import org.springframework.context.ApplicationEvent;
* @author Spencer Gibb
*/
@SuppressWarnings("serial")
public class DiscoveryHeartbeatEvent extends ApplicationEvent {
public class HeartbeatEvent extends ApplicationEvent {
private final Object value;
public DiscoveryHeartbeatEvent(Object source, Object value) {
public HeartbeatEvent(Object source, Object value) {
super(source);
this.value = value;
}

2
src/main/java/org/springframework/cloud/client/discovery/InstanceRegisteredEvent.java → src/main/java/org/springframework/cloud/client/discovery/event/InstanceRegisteredEvent.java

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.cloud.client.discovery;
package org.springframework.cloud.client.discovery.event;
import org.springframework.context.ApplicationEvent;

40
src/main/java/org/springframework/cloud/client/discovery/event/ParentHeartbeatEvent.java

@ -0,0 +1,40 @@ @@ -0,0 +1,40 @@
/*
* Copyright 2013-2015 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
*
* http://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.client.discovery.event;
import org.springframework.context.ApplicationEvent;
/**
* Heartbeat Event that a Parent ApplicationContext can send to a child Context.
* Useful when config server is located via DiscoveryClient
* @author Spencer Gibb
*/
@SuppressWarnings("serial")
public class ParentHeartbeatEvent extends ApplicationEvent {
private final Object value;
public ParentHeartbeatEvent(Object source, Object value) {
super(source);
this.value = value;
}
public Object getValue() {
return this.value;
}
}

3
src/main/java/org/springframework/cloud/client/discovery/DiscoveryClientHealthIndicator.java → src/main/java/org/springframework/cloud/client/discovery/health/DiscoveryClientHealthIndicator.java

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.cloud.client.discovery;
package org.springframework.cloud.client.discovery.health;
import java.util.List;
@ -22,6 +22,7 @@ import lombok.extern.apachecommons.CommonsLog; @@ -22,6 +22,7 @@ import lombok.extern.apachecommons.CommonsLog;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.Status;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.core.Ordered;
/**

2
src/main/java/org/springframework/cloud/client/discovery/DiscoveryCompositeHealthIndicator.java → src/main/java/org/springframework/cloud/client/discovery/health/DiscoveryCompositeHealthIndicator.java

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

2
src/main/java/org/springframework/cloud/client/discovery/DiscoveryHealthIndicator.java → src/main/java/org/springframework/cloud/client/discovery/health/DiscoveryHealthIndicator.java

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.cloud.client.discovery;
package org.springframework.cloud.client.discovery.health;
import org.springframework.boot.actuate.health.Health;

3
src/main/java/org/springframework/cloud/client/discovery/NoopDiscoveryClient.java → src/main/java/org/springframework/cloud/client/discovery/noop/NoopDiscoveryClient.java

@ -14,12 +14,13 @@ @@ -14,12 +14,13 @@
* limitations under the License.
*/
package org.springframework.cloud.client.discovery;
package org.springframework.cloud.client.discovery.noop;
import java.util.Collections;
import java.util.List;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
/**
* @author Dave Syer

4
src/main/java/org/springframework/cloud/client/discovery/NoopDiscoveryClientAutoConfiguration.java → src/main/java/org/springframework/cloud/client/discovery/noop/NoopDiscoveryClientAutoConfiguration.java

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.cloud.client.discovery;
package org.springframework.cloud.client.discovery.noop;
import java.net.InetAddress;
import java.net.UnknownHostException;
@ -30,6 +30,8 @@ import org.springframework.boot.context.embedded.EmbeddedServletContainer; @@ -30,6 +30,8 @@ import org.springframework.boot.context.embedded.EmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedWebApplicationContext;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.client.DefaultServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.client.discovery.event.InstanceRegisteredEvent;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Bean;

2
src/main/resources/META-INF/spring.factories

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

3
src/test/java/org/springframework/cloud/client/discovery/DiscoveryCompositeHealthIndicatorTests.java → src/test/java/org/springframework/cloud/client/discovery/health/DiscoveryCompositeHealthIndicatorTests.java

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.cloud.client.discovery;
package org.springframework.cloud.client.discovery.health;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@ -31,6 +31,7 @@ import org.springframework.boot.actuate.health.HealthAggregator; @@ -31,6 +31,7 @@ import org.springframework.boot.actuate.health.HealthAggregator;
import org.springframework.boot.actuate.health.OrderedHealthAggregator;
import org.springframework.boot.actuate.health.Status;
import org.springframework.cloud.client.CommonsClientAutoConfiguration;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;

3
src/test/java/org/springframework/cloud/client/discovery/NoopDiscoveryClientConfigurationAdditionalTests.java → src/test/java/org/springframework/cloud/client/discovery/noop/NoopDiscoveryClientConfigurationAdditionalTests.java

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
package org.springframework.cloud.client.discovery;
package org.springframework.cloud.client.discovery.noop;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@ -10,6 +10,7 @@ import org.springframework.boot.SpringApplication; @@ -10,6 +10,7 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

3
src/test/java/org/springframework/cloud/client/discovery/NoopDiscoveryClientConfigurationTests.java → src/test/java/org/springframework/cloud/client/discovery/noop/NoopDiscoveryClientConfigurationTests.java

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
package org.springframework.cloud.client.discovery;
package org.springframework.cloud.client.discovery.noop;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -6,6 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired; @@ -6,6 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
Loading…
Cancel
Save