Browse Source

rename PredicateFactory to Predicate

pull/41/head
Spencer Gibb 8 years ago
parent
commit
7a1bde3c3f
No known key found for this signature in database
GPG Key ID: 7788A47380690861
  1. 42
      src/main/java/org/springframework/cloud/gateway/config/GatewayAutoConfiguration.java
  2. 22
      src/main/java/org/springframework/cloud/gateway/handler/GatewayPredicateHandlerMapping.java
  3. 2
      src/main/java/org/springframework/cloud/gateway/handler/predicate/CookiePredicate.java
  4. 2
      src/main/java/org/springframework/cloud/gateway/handler/predicate/GatewayPredicate.java
  5. 2
      src/main/java/org/springframework/cloud/gateway/handler/predicate/HeaderPredicate.java
  6. 2
      src/main/java/org/springframework/cloud/gateway/handler/predicate/HostPredicate.java
  7. 2
      src/main/java/org/springframework/cloud/gateway/handler/predicate/MethodPredicate.java
  8. 2
      src/main/java/org/springframework/cloud/gateway/handler/predicate/QueryPredicate.java
  9. 2
      src/main/java/org/springframework/cloud/gateway/handler/predicate/UrlPredicate.java

42
src/main/java/org/springframework/cloud/gateway/config/GatewayAutoConfiguration.java

@ -8,15 +8,15 @@ import org.springframework.cloud.gateway.actuate.GatewayEndpoint; @@ -8,15 +8,15 @@ import org.springframework.cloud.gateway.actuate.GatewayEndpoint;
import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.filter.RouteToRequestUrlFilter;
import org.springframework.cloud.gateway.handler.GatewayFilteringWebHandler;
import org.springframework.cloud.gateway.handler.predicate.CookiePredicateFactory;
import org.springframework.cloud.gateway.handler.predicate.HeaderPredicateFactory;
import org.springframework.cloud.gateway.handler.predicate.HostPredicateFactory;
import org.springframework.cloud.gateway.handler.predicate.GatewayPredicateFactory;
import org.springframework.cloud.gateway.handler.predicate.CookiePredicate;
import org.springframework.cloud.gateway.handler.predicate.GatewayPredicate;
import org.springframework.cloud.gateway.handler.predicate.HeaderPredicate;
import org.springframework.cloud.gateway.handler.predicate.HostPredicate;
import org.springframework.cloud.gateway.handler.GatewayWebHandler;
import org.springframework.cloud.gateway.handler.GatewayPredicateHandlerMapping;
import org.springframework.cloud.gateway.handler.predicate.MethodPredicateFactory;
import org.springframework.cloud.gateway.handler.predicate.QueryPredicateFactory;
import org.springframework.cloud.gateway.handler.predicate.UrlPredicateFactory;
import org.springframework.cloud.gateway.handler.predicate.MethodPredicate;
import org.springframework.cloud.gateway.handler.predicate.QueryPredicate;
import org.springframework.cloud.gateway.handler.predicate.UrlPredicate;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
@ -60,38 +60,38 @@ public class GatewayAutoConfiguration { @@ -60,38 +60,38 @@ public class GatewayAutoConfiguration {
@Bean
public GatewayPredicateHandlerMapping gatewayPredicateHandlerMapping(GatewayProperties properties,
GatewayFilteringWebHandler webHandler,
List<GatewayPredicateFactory> predicateFactories) {
return new GatewayPredicateHandlerMapping(webHandler, predicateFactories, properties);
List<GatewayPredicate> predicates) {
return new GatewayPredicateHandlerMapping(webHandler, predicates, properties);
}
@Bean
public CookiePredicateFactory cookiePredicateFactory() {
return new CookiePredicateFactory();
public CookiePredicate cookiePredicate() {
return new CookiePredicate();
}
@Bean
public HeaderPredicateFactory headerPredicateFactory() {
return new HeaderPredicateFactory();
public HeaderPredicate headerPredicate() {
return new HeaderPredicate();
}
@Bean
public HostPredicateFactory hostPredicateFactory() {
return new HostPredicateFactory();
public HostPredicate hostPredicate() {
return new HostPredicate();
}
@Bean
public MethodPredicateFactory methodPredicateFactory() {
return new MethodPredicateFactory();
public MethodPredicate methodPredicate() {
return new MethodPredicate();
}
@Bean
public QueryPredicateFactory queryPredicateFactory() {
return new QueryPredicateFactory();
public QueryPredicate queryPredicate() {
return new QueryPredicate();
}
@Bean
public UrlPredicateFactory urlPredicateFactory() {
return new UrlPredicateFactory();
public UrlPredicate urlPredicate() {
return new UrlPredicate();
}
@Configuration

22
src/main/java/org/springframework/cloud/gateway/handler/GatewayPredicateHandlerMapping.java

@ -9,7 +9,7 @@ import org.springframework.beans.BeansException; @@ -9,7 +9,7 @@ import org.springframework.beans.BeansException;
import org.springframework.cloud.gateway.config.GatewayProperties;
import org.springframework.cloud.gateway.config.Route;
import org.springframework.cloud.gateway.config.PredicateDefinition;
import org.springframework.cloud.gateway.handler.predicate.GatewayPredicateFactory;
import org.springframework.cloud.gateway.handler.predicate.GatewayPredicate;
import org.springframework.web.reactive.handler.AbstractHandlerMapping;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebHandler;
@ -24,25 +24,25 @@ import static org.springframework.cloud.gateway.filter.GatewayFilter.GATEWAY_ROU @@ -24,25 +24,25 @@ import static org.springframework.cloud.gateway.filter.GatewayFilter.GATEWAY_ROU
*/
public class GatewayPredicateHandlerMapping extends AbstractHandlerMapping {
private Map<String, GatewayPredicateFactory> predicateFactories = new LinkedHashMap<>();
private Map<String, GatewayPredicate> predicates = new LinkedHashMap<>();
private GatewayProperties properties;
private WebHandler webHandler;
private List<Route> routes;
public GatewayPredicateHandlerMapping(WebHandler webHandler, List<GatewayPredicateFactory> predicateFactories, GatewayProperties properties) {
public GatewayPredicateHandlerMapping(WebHandler webHandler, List<GatewayPredicate> predicates, GatewayProperties properties) {
this.webHandler = webHandler;
this.properties = properties;
for (GatewayPredicateFactory factory : predicateFactories) {
if (this.predicateFactories.containsKey(factory.getName())) {
this.logger.warn("A GatewayPredicateFactory named "+ factory.getName()
+ " already exists, class: " + this.predicateFactories.get(factory.getName())
for (GatewayPredicate factory : predicates) {
if (this.predicates.containsKey(factory.getName())) {
this.logger.warn("A GatewayPredicate named "+ factory.getName()
+ " already exists, class: " + this.predicates.get(factory.getName())
+ ". It will be overwritten.");
}
this.predicateFactories.put(factory.getName(), factory);
this.predicates.put(factory.getName(), factory);
if (logger.isInfoEnabled()) {
logger.info("Loaded GatewayPredicateFactory [" + factory.getName() + "]");
logger.info("Loaded GatewayPredicate [" + factory.getName() + "]");
}
}
@ -126,9 +126,9 @@ public class GatewayPredicateHandlerMapping extends AbstractHandlerMapping { @@ -126,9 +126,9 @@ public class GatewayPredicateHandlerMapping extends AbstractHandlerMapping {
}
private Predicate<ServerWebExchange> lookup(PredicateDefinition predicate) {
GatewayPredicateFactory found = this.predicateFactories.get(predicate.getName());
GatewayPredicate found = this.predicates.get(predicate.getName());
if (found == null) {
throw new IllegalArgumentException("Unable to find GatewayPredicateFactory with name " + predicate.getName());
throw new IllegalArgumentException("Unable to find GatewayPredicate with name " + predicate.getName());
}
return found.create(predicate.getValue(), predicate.getArgs());
}

2
src/main/java/org/springframework/cloud/gateway/handler/predicate/CookiePredicateFactory.java → src/main/java/org/springframework/cloud/gateway/handler/predicate/CookiePredicate.java

@ -10,7 +10,7 @@ import org.springframework.web.server.ServerWebExchange; @@ -10,7 +10,7 @@ import org.springframework.web.server.ServerWebExchange;
/**
* @author Spencer Gibb
*/
public class CookiePredicateFactory implements GatewayPredicateFactory {
public class CookiePredicate implements GatewayPredicate {
@Override
public String getName() {

2
src/main/java/org/springframework/cloud/gateway/handler/predicate/GatewayPredicateFactory.java → src/main/java/org/springframework/cloud/gateway/handler/predicate/GatewayPredicate.java

@ -7,7 +7,7 @@ import org.springframework.web.server.ServerWebExchange; @@ -7,7 +7,7 @@ import org.springframework.web.server.ServerWebExchange;
/**
* @author Spencer Gibb
*/
public interface GatewayPredicateFactory {
public interface GatewayPredicate {
String getName();

2
src/main/java/org/springframework/cloud/gateway/handler/predicate/HeaderPredicateFactory.java → src/main/java/org/springframework/cloud/gateway/handler/predicate/HeaderPredicate.java

@ -9,7 +9,7 @@ import org.springframework.web.server.ServerWebExchange; @@ -9,7 +9,7 @@ import org.springframework.web.server.ServerWebExchange;
/**
* @author Spencer Gibb
*/
public class HeaderPredicateFactory implements GatewayPredicateFactory {
public class HeaderPredicate implements GatewayPredicate {
@Override
public String getName() {

2
src/main/java/org/springframework/cloud/gateway/handler/predicate/HostPredicateFactory.java → src/main/java/org/springframework/cloud/gateway/handler/predicate/HostPredicate.java

@ -9,7 +9,7 @@ import org.springframework.web.server.ServerWebExchange; @@ -9,7 +9,7 @@ import org.springframework.web.server.ServerWebExchange;
/**
* @author Spencer Gibb
*/
public class HostPredicateFactory implements GatewayPredicateFactory {
public class HostPredicate implements GatewayPredicate {
private PathMatcher pathMatcher = new AntPathMatcher(".");

2
src/main/java/org/springframework/cloud/gateway/handler/predicate/MethodPredicateFactory.java → src/main/java/org/springframework/cloud/gateway/handler/predicate/MethodPredicate.java

@ -8,7 +8,7 @@ import org.springframework.web.server.ServerWebExchange; @@ -8,7 +8,7 @@ import org.springframework.web.server.ServerWebExchange;
/**
* @author Spencer Gibb
*/
public class MethodPredicateFactory implements GatewayPredicateFactory {
public class MethodPredicate implements GatewayPredicate {
@Override
public String getName() {

2
src/main/java/org/springframework/cloud/gateway/handler/predicate/QueryPredicateFactory.java → src/main/java/org/springframework/cloud/gateway/handler/predicate/QueryPredicate.java

@ -8,7 +8,7 @@ import org.springframework.web.server.ServerWebExchange; @@ -8,7 +8,7 @@ import org.springframework.web.server.ServerWebExchange;
/**
* @author Spencer Gibb
*/
public class QueryPredicateFactory implements GatewayPredicateFactory {
public class QueryPredicate implements GatewayPredicate {
@Override
public String getName() {

2
src/main/java/org/springframework/cloud/gateway/handler/predicate/UrlPredicateFactory.java → src/main/java/org/springframework/cloud/gateway/handler/predicate/UrlPredicate.java

@ -10,7 +10,7 @@ import org.springframework.web.server.support.HttpRequestPathHelper; @@ -10,7 +10,7 @@ import org.springframework.web.server.support.HttpRequestPathHelper;
/**
* @author Spencer Gibb
*/
public class UrlPredicateFactory implements GatewayPredicateFactory {
public class UrlPredicate implements GatewayPredicate {
private PathMatcher pathMatcher = new AntPathMatcher();
private HttpRequestPathHelper pathHelper = new HttpRequestPathHelper();
Loading…
Cancel
Save