Commit a496dc81 by Gregor Zurowski Committed by Spencer Gibb

Use constant utility classes instead of constant interfaces (#2081)

parent 8e11514e
......@@ -19,8 +19,12 @@ package org.springframework.cloud.netflix.hystrix;
/**
* @author Spencer Gibb
*/
public interface HystrixConstants {
public class HystrixConstants {
String HYSTRIX_STREAM_DESTINATION = "springCloudHystrixStream";
public static final String HYSTRIX_STREAM_DESTINATION = "springCloudHystrixStream";
private HystrixConstants() {
throw new AssertionError("Must not instantiate constant utility class");
}
}
......@@ -26,190 +26,195 @@ import com.netflix.zuul.ZuulFilter;
/**
* @author Spencer Gibb
*/
public interface FilterConstants {
public class FilterConstants {
// KEY constants -----------------------------------
/**
* Zuul {@link com.netflix.zuul.context.RequestContext} key for use in {@link org.springframework.cloud.netflix.zuul.filters.pre.ServletDetectionFilter}
*/
String IS_DISPATCHER_SERVLET_REQUEST_KEY = "isDispatcherServletRequest";
public static final String IS_DISPATCHER_SERVLET_REQUEST_KEY = "isDispatcherServletRequest";
/**
* Zuul {@link com.netflix.zuul.context.RequestContext} key for use in {@link org.springframework.cloud.netflix.zuul.filters.route.SendForwardFilter}
*/
String FORWARD_TO_KEY = "forward.to";
public static final String FORWARD_TO_KEY = "forward.to";
/**
* Zuul {@link com.netflix.zuul.context.RequestContext} key for use in TODO: determine use
*/
String PROXY_KEY = "proxy";
public static final String PROXY_KEY = "proxy";
/**
* Zuul {@link com.netflix.zuul.context.RequestContext} key for use in {@link org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter}
*/
String REQUEST_ENTITY_KEY = "requestEntity";
public static final String REQUEST_ENTITY_KEY = "requestEntity";
/**
* Zuul {@link com.netflix.zuul.context.RequestContext} key for use in to override the path of the request.
*/
String REQUEST_URI_KEY = "requestURI";
public static final String REQUEST_URI_KEY = "requestURI";
/**
* Zuul {@link com.netflix.zuul.context.RequestContext} key for use in {@link org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter}
*/
String RETRYABLE_KEY = "retryable";
public static final String RETRYABLE_KEY = "retryable";
/**
* Zuul {@link com.netflix.zuul.context.RequestContext} key for use in {@link org.springframework.cloud.netflix.zuul.filters.post.SendResponseFilter}
*/
String ROUTING_DEBUG_KEY = "routingDebug";
public static final String ROUTING_DEBUG_KEY = "routingDebug";
/**
* Zuul {@link com.netflix.zuul.context.RequestContext} key for use in {@link org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter}
*/
String SERVICE_ID_KEY = "serviceId";
public static final String SERVICE_ID_KEY = "serviceId";
// ORDER constants -----------------------------------
/**
* Filter Order for {@link DebugFilter#filterOrder()}
*/
int DEBUG_FILTER_ORDER = 1;
public static final int DEBUG_FILTER_ORDER = 1;
/**
* Filter Order for {@link org.springframework.cloud.netflix.zuul.filters.pre.FormBodyWrapperFilter#filterOrder()}
*/
int FORM_BODY_WRAPPER_FILTER_ORDER = -1;
public static final int FORM_BODY_WRAPPER_FILTER_ORDER = -1;
/**
* Filter Order for {@link org.springframework.cloud.netflix.zuul.filters.pre.PreDecorationFilter}
*/
int PRE_DECORATION_FILTER_ORDER = 5;
public static final int PRE_DECORATION_FILTER_ORDER = 5;
/**
* Filter Order for {@link org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter#filterOrder()}
*/
int RIBBON_ROUTING_FILTER_ORDER = 10;
public static final int RIBBON_ROUTING_FILTER_ORDER = 10;
/**
* Filter Order for {@link org.springframework.cloud.netflix.zuul.filters.post.SendErrorFilter#filterOrder()}
*/
int SEND_ERROR_FILTER_ORDER = 0;
public static final int SEND_ERROR_FILTER_ORDER = 0;
/**
* Filter Order for {@link SendForwardFilter#filterOrder()}
*/
int SEND_FORWARD_FILTER_ORDER = 500;
public static final int SEND_FORWARD_FILTER_ORDER = 500;
/**
* Filter Order for {@link org.springframework.cloud.netflix.zuul.filters.post.SendResponseFilter#filterOrder()}
*/
int SEND_RESPONSE_FILTER_ORDER = 1000;
public static final int SEND_RESPONSE_FILTER_ORDER = 1000;
/**
* Filter Order for {@link org.springframework.cloud.netflix.zuul.filters.route.SimpleHostRoutingFilter#filterOrder()}
*/
int SIMPLE_HOST_ROUTING_FILTER_ORDER = 100;
public static final int SIMPLE_HOST_ROUTING_FILTER_ORDER = 100;
/**
* filter order for {@link Servlet30WrapperFilter#filterOrder()}
*/
int SERVLET_30_WRAPPER_FILTER_ORDER = -2;
public static final int SERVLET_30_WRAPPER_FILTER_ORDER = -2;
/**
* filter order for {@link org.springframework.cloud.netflix.zuul.filters.pre.ServletDetectionFilter#filterOrder()}
*/
int SERVLET_DETECTION_FILTER_ORDER = -3;
public static final int SERVLET_DETECTION_FILTER_ORDER = -3;
// Zuul Filter TYPE constants -----------------------------------
/**
* {@link ZuulFilter#filterType()} error type.
*/
String ERROR_TYPE = "error";
public static final String ERROR_TYPE = "error";
/**
* {@link ZuulFilter#filterType()} post type.
*/
String POST_TYPE = "post";
public static final String POST_TYPE = "post";
/**
* {@link ZuulFilter#filterType()} pre type.
*/
String PRE_TYPE = "pre";
public static final String PRE_TYPE = "pre";
/**
* {@link ZuulFilter#filterType()} route type.
*/
String ROUTE_TYPE = "route";
public static final String ROUTE_TYPE = "route";
// OTHER constants -----------------------------------
/**
* Zuul {@link com.netflix.zuul.context.RequestContext} key for use in {@link org.springframework.cloud.netflix.zuul.filters.route.SendForwardFilter}
*/
String FORWARD_LOCATION_PREFIX = "forward:";
public static final String FORWARD_LOCATION_PREFIX = "forward:";
/**
* default http port
*/
int HTTP_PORT = 80;
public static final int HTTP_PORT = 80;
/**
* default https port
*/
int HTTPS_PORT = 443;
public static final int HTTPS_PORT = 443;
/**
* http url scheme
*/
String HTTP_SCHEME = "http";
public static final String HTTP_SCHEME = "http";
/**
* https url scheme
*/
String HTTPS_SCHEME = "https";
public static final String HTTPS_SCHEME = "https";
// HEADER constants -----------------------------------
/**
* X-* Header for the matching url. Used when routes use a url rather than serviceId
*/
String SERVICE_HEADER = "X-Zuul-Service";
public static final String SERVICE_HEADER = "X-Zuul-Service";
/**
* X-* Header for the matching serviceId
*/
String SERVICE_ID_HEADER = "X-Zuul-ServiceId";
public static final String SERVICE_ID_HEADER = "X-Zuul-ServiceId";
/**
* X-Forwarded-For Header
*/
String X_FORWARDED_FOR_HEADER = "X-Forwarded-For";
public static final String X_FORWARDED_FOR_HEADER = "X-Forwarded-For";
/**
* X-Forwarded-Host Header
*/
String X_FORWARDED_HOST_HEADER = "X-Forwarded-Host";
public static final String X_FORWARDED_HOST_HEADER = "X-Forwarded-Host";
/**
* X-Forwarded-Prefix Header
*/
String X_FORWARDED_PREFIX_HEADER = "X-Forwarded-Prefix";
public static final String X_FORWARDED_PREFIX_HEADER = "X-Forwarded-Prefix";
/**
* X-Forwarded-Port Header
*/
String X_FORWARDED_PORT_HEADER = "X-Forwarded-Port";
public static final String X_FORWARDED_PORT_HEADER = "X-Forwarded-Port";
/**
* X-Forwarded-Proto Header
*/
String X_FORWARDED_PROTO_HEADER = "X-Forwarded-Proto";
public static final String X_FORWARDED_PROTO_HEADER = "X-Forwarded-Proto";
/**
* X-Zuul-Debug Header
*/
String X_ZUUL_DEBUG_HEADER = "X-Zuul-Debug-Header";
public static final String X_ZUUL_DEBUG_HEADER = "X-Zuul-Debug-Header";
private FilterConstants() {
throw new AssertionError("Must not instantiate constant utility class");
}
}
......@@ -38,14 +38,14 @@ import lombok.Data;
*/
@Data
@ConfigurationProperties(EurekaClientConfigBean.PREFIX)
public class EurekaClientConfigBean implements EurekaClientConfig, EurekaConstants {
public class EurekaClientConfigBean implements EurekaClientConfig {
public static final String PREFIX = "eureka.client";
@Autowired(required = false)
PropertyResolver propertyResolver;
public static final String DEFAULT_URL = "http://localhost:8761" + DEFAULT_PREFIX
public static final String DEFAULT_URL = "http://localhost:8761" + EurekaConstants.DEFAULT_PREFIX
+ "/";
public static final String DEFAULT_ZONE = "defaultZone";
......
......@@ -19,8 +19,12 @@ package org.springframework.cloud.netflix.eureka;
/**
* @author Spencer Gibb
*/
public interface EurekaConstants {
public class EurekaConstants {
String DEFAULT_PREFIX = "/eureka";
public static final String DEFAULT_PREFIX = "/eureka";
private EurekaConstants() {
throw new AssertionError("Must not instantiate constant utility class");
}
}
......@@ -23,7 +23,6 @@ import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.netflix.eureka.EurekaConstants;
import org.springframework.core.env.PropertyResolver;
import com.netflix.eureka.EurekaServerConfig;
......@@ -36,7 +35,7 @@ import lombok.Data;
*/
@Data
@ConfigurationProperties(EurekaServerConfigBean.PREFIX)
public class EurekaServerConfigBean implements EurekaServerConfig, EurekaConstants {
public class EurekaServerConfigBean implements EurekaServerConfig {
public static final String PREFIX = "eureka.server";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment