Move some discovery classes to subpackages.

Create discovey.event.ParentHeartbeatEvent for passing HearbeatEvents originating in a parent context to child contexts
This commit is contained in:
Spencer Gibb
2015-01-26 21:15:16 -07:00
parent 3596e67e11
commit f8f4408972
14 changed files with 64 additions and 16 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;
* @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;
}

View File

@@ -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;

View File

@@ -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;
}
}

View File

@@ -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;
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;
/**

View File

@@ -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;

View File

@@ -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;

View File

@@ -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

View File

@@ -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;
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;

View File

@@ -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

View File

@@ -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;
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;

View File

@@ -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;
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;

View File

@@ -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;
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;