Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update some javadocs
  • Loading branch information
spencergibb committed Nov 4, 2016
commit 60896a3bacd98ff0dae25ea01be746afae91cf4c
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,15 @@
import org.springframework.core.env.Environment;

/**
* Lifecycle methods that may be useful and common to various DiscoveryClient implementations.
* Lifecycle methods that may be useful and common to {@link ServiceRegistry} implementations.
*
* TODO: document the lifecycle
*
* @param <R> registration type passed to the {@link ServiceRegistry}.
*
* @author Spencer Gibb
*/
//TODO: rename to AbstractServiceRegistryLifecycle or AbstractAutoServiceRegistration?
public abstract class AbstractDiscoveryLifecycle<R> implements DiscoveryLifecycle,
ApplicationContextAware, ApplicationListener<EmbeddedServletContainerInitializedEvent> {

Expand Down Expand Up @@ -123,18 +129,16 @@ public void start() {
protected abstract void setConfiguredPort(int port);

/**
* @return if the management service should be registered with the DiscoveryService
* @return if the management service should be registered with the {@link ServiceRegistry}
*/
protected boolean shouldRegisterManagement() {
return getManagementPort() != null && ManagementServerPortUtils.isDifferent(this.context);
}

/**
* @return the object used to configure the DiscoveryClient
* @return the object used to configure the registration
*/
protected Object getConfiguration() {
return null;
}
protected abstract Object getConfiguration();

protected abstract R getRegistration();

Expand All @@ -145,35 +149,35 @@ protected ServiceRegistry<R> getServiceRegistry() {
}

/**
* Register the local service with the DiscoveryClient
* Register the local service with the {@link ServiceRegistry}
*/
protected void register() {
this.serviceRegistry.register(getRegistration());
}

/**
* Register the local management service with the DiscoveryClient
* Register the local management service with the {@link ServiceRegistry}
*/
protected void registerManagement() {
this.serviceRegistry.register(getManagementRegistration());
}

/**
* De-register the local service with the DiscoveryClient
* De-register the local service with the {@link ServiceRegistry}
*/
protected void deregister() {
this.serviceRegistry.deregister(getRegistration());
}

/**
* De-register the local management service with the DiscoveryClient
* De-register the local management service with the {@link ServiceRegistry}
*/
protected void deregisterManagement() {
this.serviceRegistry.deregister(getManagementRegistration());
}

/**
* @return if the DiscoveryClient is enabled
* @return true, if the {@link DiscoveryLifecycle} is enabled
*/
protected abstract boolean isEnabled();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.springframework.cloud.client.serviceregistry;

/**
* TODO: write javadoc
* @author Spencer Gibb
*/
public interface ServiceRegistry<R> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ public boolean isDeregistered() {

public static class TestDiscoveryLifecycle extends AbstractDiscoveryLifecycle<TestRegistration> {
private int port = 0;
private boolean registered = false;
private boolean deregistered = false;

protected TestDiscoveryLifecycle() {
super(new TestServiceRegistry());
Expand All @@ -112,6 +110,11 @@ protected TestRegistration getManagementRegistration() {
return null;
}

@Override
protected Object getConfiguration() {
return null;
}

@Override
protected boolean isEnabled() {
return true;
Expand Down