rename PredicateFactory to Predicate
This commit is contained in:
@@ -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 {
|
||||
@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
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
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 {
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
@@ -7,7 +7,7 @@ import org.springframework.web.server.ServerWebExchange;
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
public interface GatewayPredicateFactory {
|
||||
public interface GatewayPredicate {
|
||||
|
||||
String getName();
|
||||
|
||||
@@ -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() {
|
||||
@@ -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(".");
|
||||
|
||||
@@ -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() {
|
||||
@@ -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() {
|
||||
@@ -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();
|
||||
Reference in New Issue
Block a user