本文整理汇总了Java中com.netflix.zuul.ZuulFilter类的典型用法代码示例。如果您正苦于以下问题:Java ZuulFilter类的具体用法?Java ZuulFilter怎么用?Java ZuulFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ZuulFilter类属于com.netflix.zuul包,在下文中一共展示了ZuulFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createZuulFilter
import com.netflix.zuul.ZuulFilter; //导入依赖的package包/类
private ZuulFilter createZuulFilter(int position) {
Integer filterCount = 0;
if(properties.getFilters().size() >= (position+1)) {
Bucket4JConfiguration filter = properties.getFilters().get(position);
filterCount++;
FilterConfiguration filterConfig = buildFilterConfig(filter, cacheManager, zuulExpressionParser(), beanFactory);
return new ZuulRateLimitFilter(filterConfig);
}
return null;
}
示例2: invoke
import com.netflix.zuul.ZuulFilter; //导入依赖的package包/类
@ReadOperation
public Map<String, List<Map<String, Object>>> invoke() {
// Map of filters by type
final Map<String, List<Map<String, Object>>> filterMap = new TreeMap<>();
for (ZuulFilter filter : this.filterRegistry.getAllFilters()) {
// Ensure that we have a list to store filters of each type
if (!filterMap.containsKey(filter.filterType())) {
filterMap.put(filter.filterType(), new ArrayList<>());
}
final Map<String, Object> filterInfo = new LinkedHashMap<>();
filterInfo.put("class", filter.getClass().getName());
filterInfo.put("order", filter.filterOrder());
filterInfo.put("disabled", filter.isFilterDisabled());
filterInfo.put("static", filter.isStaticFilter());
filterMap.get(filter.filterType()).add(filterInfo);
}
return filterMap;
}
示例3: sampleFilter
import com.netflix.zuul.ZuulFilter; //导入依赖的package包/类
@Bean
public ZuulFilter sampleFilter() {
return new ZuulFilter() {
@Override
public String filterType() {
return PRE_TYPE;
}
@Override
public boolean shouldFilter() {
return true;
}
@Override
public Object run() {
return null;
}
@Override
public int filterOrder() {
return 0;
}
};
}
示例4: sampleFilter
import com.netflix.zuul.ZuulFilter; //导入依赖的package包/类
@Bean
public ZuulFilter sampleFilter() {
return new ZuulFilter() {
@Override
public String filterType() {
return PRE_TYPE;
}
@Override
public boolean shouldFilter() {
return true;
}
@Override
public Object run() {
return null;
}
@Override
public int filterOrder() {
return 0;
}
};
}
示例5: rateLimiterPreFilter
import com.netflix.zuul.ZuulFilter; //导入依赖的package包/类
@Bean
public ZuulFilter rateLimiterPreFilter(final RateLimiter rateLimiter,
final RateLimitProperties rateLimitProperties,
final RouteLocator routeLocator,
final RateLimitKeyGenerator rateLimitKeyGenerator) {
return new RateLimitPreFilter(rateLimitProperties, routeLocator, urlPathHelper, rateLimiter,
rateLimitKeyGenerator);
}
示例6: rateLimiterPostFilter
import com.netflix.zuul.ZuulFilter; //导入依赖的package包/类
@Bean
public ZuulFilter rateLimiterPostFilter(final RateLimiter rateLimiter,
final RateLimitProperties rateLimitProperties,
final RouteLocator routeLocator,
final RateLimitKeyGenerator rateLimitKeyGenerator) {
return new RateLimitPostFilter(rateLimitProperties, routeLocator, urlPathHelper, rateLimiter,
rateLimitKeyGenerator);
}
示例7: testZuulFilters
import com.netflix.zuul.ZuulFilter; //导入依赖的package包/类
@Test
public void testZuulFilters() {
this.context.refresh();
Map<String, ZuulFilter> zuulFilterMap = context.getBeansOfType(ZuulFilter.class);
assertThat(zuulFilterMap.size()).isEqualTo(2);
assertThat(zuulFilterMap.keySet()).containsExactly("rateLimiterPreFilter", "rateLimiterPostFilter");
}
开发者ID:marcosbarbero,项目名称:spring-cloud-zuul-ratelimit,代码行数:9,代码来源:RateLimitAutoConfigurationTest.java
示例8: ZuulFilterInitializer
import com.netflix.zuul.ZuulFilter; //导入依赖的package包/类
public ZuulFilterInitializer(Map<String, ZuulFilter> filters,
CounterFactory counterFactory,
TracerFactory tracerFactory,
FilterLoader filterLoader,
FilterRegistry filterRegistry) {
this.filters = filters;
this.counterFactory = counterFactory;
this.tracerFactory = tracerFactory;
this.filterLoader = filterLoader;
this.filterRegistry = filterRegistry;
}
示例9: contextInitialized
import com.netflix.zuul.ZuulFilter; //导入依赖的package包/类
@PostConstruct
public void contextInitialized() {
log.info("Starting filter initializer");
TracerFactory.initialize(tracerFactory);
CounterFactory.initialize(counterFactory);
for (Map.Entry<String, ZuulFilter> entry : this.filters.entrySet()) {
filterRegistry.put(entry.getKey(), entry.getValue());
}
}
示例10: contextDestroyed
import com.netflix.zuul.ZuulFilter; //导入依赖的package包/类
@PreDestroy
public void contextDestroyed() {
log.info("Stopping filter initializer");
for (Map.Entry<String, ZuulFilter> entry : this.filters.entrySet()) {
filterRegistry.remove(entry.getKey());
}
clearLoaderCache();
TracerFactory.initialize(null);
CounterFactory.initialize(null);
}
示例11: testPreFilter
import com.netflix.zuul.ZuulFilter; //导入依赖的package包/类
@Bean
public ZuulFilter testPreFilter() {
return new FailureFilter() {
@Override
public String filterType() {
return PRE_TYPE;
}
};
}
示例12: testRouteFilter
import com.netflix.zuul.ZuulFilter; //导入依赖的package包/类
@Bean
public ZuulFilter testRouteFilter() {
return new FailureFilter() {
@Override
public String filterType() {
return ROUTE_TYPE;
}
};
}
示例13: testPostFilter
import com.netflix.zuul.ZuulFilter; //导入依赖的package包/类
@Bean
public ZuulFilter testPostFilter() {
return new FailureFilter() {
@Override
public String filterType() {
return POST_TYPE;
}
};
}
示例14: sampleFilter
import com.netflix.zuul.ZuulFilter; //导入依赖的package包/类
@Bean
public ZuulFilter sampleFilter() {
return new ZuulFilter() {
@Override
public String filterType() {
return PRE_TYPE;
}
@Override
public boolean shouldFilter() {
return true;
}
@Override
public Object run() {
if (RequestContext.getCurrentContext().getRequest().getParameterMap()
.containsKey("override")) {
Map<String, List<String>> overridden = new HashMap<>();
overridden.put("key", Arrays.asList("overridden"));
RequestContext.getCurrentContext()
.setRequestQueryParams(overridden);
}
return null;
}
@Override
public int filterOrder() {
return 0;
}
};
}
示例15: zuulFilter1
import com.netflix.zuul.ZuulFilter; //导入依赖的package包/类
@Bean
@Conditional(ConfigCondition1.class)
public ZuulFilter zuulFilter1() {
return createZuulFilter(0);
}