• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ZuulProperties类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.cloud.netflix.zuul.filters.ZuulProperties的典型用法代码示例。如果您正苦于以下问题:Java ZuulProperties类的具体用法?Java ZuulProperties怎么用?Java ZuulProperties使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ZuulProperties类属于org.springframework.cloud.netflix.zuul.filters包,在下文中一共展示了ZuulProperties类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: StoreProxyRouteLocator

import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入依赖的package包/类
/**
 * Creates new instance of {@link StoreProxyRouteLocator}
 * 
 * @param servletPath the application servlet path
 * @param discovery the discovery service
 * @param properties the zuul properties
 * @param store the route store
 */
public StoreProxyRouteLocator(String servletPath, DiscoveryClient discovery,
    ZuulProperties properties, ZuulRouteService store) {
  super(servletPath, discovery, properties);
  this.store = store;
  refreshExecutor.scheduleAtFixedRate(new Runnable() {

    @Override
    public void run() {
      try {
        refresh();
      } catch (Throwable e) {
        log.error(e.getMessage(), e);
      }
    }
  }, 0, 1, TimeUnit.MINUTES);
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:25,代码来源:StoreProxyRouteLocator.java


示例2: routeStore

import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入依赖的package包/类
@ConditionalOnMissingBean(RouteStore.class)
@Bean
public RouteStore routeStore() {
    return new RouteStore() {
        @Override
        public List<ZuulProperties.ZuulRoute> getAllRoutes() {
            return Collections.emptyList();
        }

        @Override
        public void onRoutesChange(Consumer<List<ZuulProperties.ZuulRoute>> handleFunction) {
            handleFunction.accept(getAllRoutes());
        }

        @Override
        public List<ServiceRoute> getAllServiceRoutes() {
            return Collections.emptyList();
        }
    };
}
 
开发者ID:alexqdjay,项目名称:zuul-dynamic,代码行数:21,代码来源:ZuulDynamicConfig.java


示例3: shouldReportDownState

import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入依赖的package包/类
@Test
public void shouldReportDownState() {

    // given
    final ZuulProperties.ZuulRoute route = new ZuulProperties.ZuulRoute("/zuul", "proxied-service");
    zuulProperties.getRoutes().put(route.getId(), route);

    // when
    final Health health = zuulRouteHealthIndicator.health();

    // then
    assertNotNull(health);
    assertEquals(Status.DOWN, health.getStatus());
    assertNull(health.getDetails().get("available"));
    assertFalse(((Collection) health.getDetails().get("unavailable")).isEmpty());
}
 
开发者ID:jmnarloch,项目名称:zuul-route-health-spring-cloud-starter,代码行数:17,代码来源:ZuulRouteHealthIndicatorTest.java


示例4: shouldReportUpState

import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入依赖的package包/类
@Test
public void shouldReportUpState() {

    // given
    final ZuulProperties.ZuulRoute route = new ZuulProperties.ZuulRoute("/zuul", "proxied-service");
    zuulProperties.getRoutes().put(route.getId(), route);

    final List<ServiceInstance> services = new ArrayList<>();
    services.add(mock(ServiceInstance.class));
    when(discoveryClient.getInstances("proxied-service")).thenReturn(services);

    // when
    final Health health = zuulRouteHealthIndicator.health();

    // then
    assertNotNull(health);
    assertEquals(Status.UP, health.getStatus());
    assertFalse(((Collection) health.getDetails().get("available")).isEmpty());
    assertNull(health.getDetails().get("unavailable"));
}
 
开发者ID:jmnarloch,项目名称:zuul-route-health-spring-cloud-starter,代码行数:21,代码来源:ZuulRouteHealthIndicatorTest.java


示例5: getRestoredPath

import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入依赖的package包/类
private String getRestoredPath(ZuulProperties zuulProperties, Route route,
		UriComponents redirectedUriComps) {
	StringBuilder path = new StringBuilder();
	String redirectedPathWithoutGlobal = downstreamHasGlobalPrefix(zuulProperties)
			? redirectedUriComps.getPath()
					.substring(("/" + zuulProperties.getPrefix()).length())
			: redirectedUriComps.getPath();

	if (downstreamHasGlobalPrefix(zuulProperties)) {
		path.append("/" + zuulProperties.getPrefix());
	}
	else {
		path.append(zuulHasGlobalPrefix(zuulProperties)
				? "/" + zuulProperties.getPrefix() : "");
	}

	path.append(downstreamHasRoutePrefix(route) ? "" : "/" + route.getPrefix())
			.append(redirectedPathWithoutGlobal);

	return path.toString();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:22,代码来源:LocationRewriteFilter.java


示例6: getSetter

import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入依赖的package包/类
protected static Setter getSetter(final String commandKey,
		ZuulProperties zuulProperties, IClientConfig config) {

	// @formatter:off
	Setter commandSetter = Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("RibbonCommand"))
							.andCommandKey(HystrixCommandKey.Factory.asKey(commandKey));
	final HystrixCommandProperties.Setter setter = createSetter(config, commandKey, zuulProperties);
	if (zuulProperties.getRibbonIsolationStrategy() == ExecutionIsolationStrategy.SEMAPHORE){
		final String name = ZuulConstants.ZUUL_EUREKA + commandKey + ".semaphore.maxSemaphores";
		// we want to default to semaphore-isolation since this wraps
		// 2 others commands that are already thread isolated
		final DynamicIntProperty value = DynamicPropertyFactory.getInstance()
				.getIntProperty(name, zuulProperties.getSemaphore().getMaxSemaphores());
		setter.withExecutionIsolationSemaphoreMaxConcurrentRequests(value.get());
	} else if (zuulProperties.getThreadPool().isUseSeparateThreadPools()) {
		final String threadPoolKey = zuulProperties.getThreadPool().getThreadPoolKeyPrefix() + commandKey;
		commandSetter.andThreadPoolKey(HystrixThreadPoolKey.Factory.asKey(threadPoolKey));
	}
	
	return commandSetter.andCommandPropertiesDefaults(setter);
	// @formatter:on
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:23,代码来源:AbstractRibbonCommand.java


示例7: shouldAddBackGlobalPrefixIfPresent

import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入依赖的package包/类
@Test
public void shouldAddBackGlobalPrefixIfPresent() {
	RequestContext context = RequestContext.getCurrentContext();
	ZuulProperties zuulProperties = new ZuulProperties();
	zuulProperties.setPrefix("global");
	zuulProperties.setStripPrefix(true);
	LocationRewriteFilter filter = setFilterUpWith(context, zuulProperties,
			new Route("service1", "/something/redirectingUri", "service1", "prefix",
					false, Collections.EMPTY_SET, true),
			"/global/prefix/redirectingUri",
			"/something/redirectedUri;someparam?param1=abc");
	filter.run();
	assertThat(getLocationHeader(context).second()).isEqualTo(String.format(
			"%s/global/prefix/something/redirectedUri;someparam?param1=abc",
			ZUUL_BASE_URL));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:17,代码来源:LocationRewriteFilterTests.java


示例8: shouldNotAddBackGlobalPrefixIfNotStripped

import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入依赖的package包/类
@Test
public void shouldNotAddBackGlobalPrefixIfNotStripped() {
	RequestContext context = RequestContext.getCurrentContext();
	ZuulProperties zuulProperties = new ZuulProperties();
	zuulProperties.setPrefix("global");
	zuulProperties.setStripPrefix(false);
	LocationRewriteFilter filter = setFilterUpWith(context, zuulProperties,
			new Route("service1", "/something/redirectingUri", "service1", "prefix",
					false, Collections.EMPTY_SET, true),
			"/global/prefix/redirectingUri",
			"/global/something/redirectedUri;someparam?param1=abc");
	filter.run();
	assertThat(getLocationHeader(context).second()).isEqualTo(String.format(
			"%s/global/prefix/something/redirectedUri;someparam?param1=abc",
			ZUUL_BASE_URL));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:17,代码来源:LocationRewriteFilterTests.java


示例9: setFilterUpWith

import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入依赖的package包/类
private LocationRewriteFilter setFilterUpWith(RequestContext context,
		ZuulProperties zuulProperties, Route route, String toZuulRequestUri,
		String redirectedUri) {
	MockHttpServletRequest httpServletRequest = new MockHttpServletRequest();
	httpServletRequest.setRequestURI(toZuulRequestUri);
	httpServletRequest.setServerName(ZUUL_HOST);
	httpServletRequest.setScheme(ZUUL_SCHEME);
	httpServletRequest.setServerPort(ZUUL_PORT);
	context.setRequest(httpServletRequest);

	MockHttpServletResponse httpServletResponse = new MockHttpServletResponse();
	context.getZuulResponseHeaders().add(new Pair<>("Location",
			String.format("%s%s", SERVER_BASE_URL, redirectedUri)));
	context.setResponse(httpServletResponse);

	RouteLocator routeLocator = mock(RouteLocator.class);
	when(routeLocator.getMatchingRoute(toZuulRequestUri)).thenReturn(route);
	LocationRewriteFilter filter = new LocationRewriteFilter(zuulProperties,
			routeLocator);

	return filter;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:23,代码来源:LocationRewriteFilterTests.java


示例10: createFilter

import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入依赖的package包/类
private SendResponseFilter createFilter(ZuulProperties properties, String content, String characterEncoding, MockHttpServletResponse response, boolean streamContent) throws Exception {
	HttpServletRequest request = new MockHttpServletRequest();
	RequestContext context = new RequestContext();
	context.setRequest(request);
	context.setResponse(response);

	if (characterEncoding != null) {
		response.setCharacterEncoding(characterEncoding);
	}

	if (streamContent) {
		context.setResponseDataStream(new ByteArrayInputStream(content.getBytes(characterEncoding)));
	} else {
		context.setResponseBody(content);
	}

	context.addZuulResponseHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(content.length()));

	context.set("error.status_code", HttpStatus.NOT_FOUND.value());
	RequestContext.testSetCurrentContext(context);
	SendResponseFilter filter = new SendResponseFilter(properties);
	return filter;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:24,代码来源:SendResponseFilterTests.java


示例11: testHystrixTimeoutValueRibbonTimeouts

import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入依赖的package包/类
@Test
public void testHystrixTimeoutValueRibbonTimeouts() throws Exception {
	SpringClientFactory springClientFactory = mock(SpringClientFactory.class);
	ZuulProperties zuulProperties = new ZuulProperties();
	OkHttpLoadBalancingClient loadBalancingHttpClient = mock(OkHttpLoadBalancingClient.class);
	IClientConfig clientConfig = new DefaultClientConfigImpl();
	clientConfig.set(IClientConfigKey.Keys.ConnectTimeout, 100);
	clientConfig.set(IClientConfigKey.Keys.ReadTimeout, 500);
	doReturn(loadBalancingHttpClient).when(springClientFactory).getClient(anyString(),
			eq(OkHttpLoadBalancingClient.class));
	doReturn(clientConfig).when(springClientFactory).getClientConfig(anyString());
	OkHttpRibbonCommandFactory commandFactory = new OkHttpRibbonCommandFactory(springClientFactory, zuulProperties, new HashSet<FallbackProvider>());
	RibbonCommandContext context = mock(RibbonCommandContext.class);
	doReturn("service").when(context).getServiceId();
	OkHttpRibbonCommand ribbonCommand = commandFactory.create(context);
	assertEquals(600, ribbonCommand.getProperties().executionTimeoutInMilliseconds().get().intValue());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:18,代码来源:OkHttpRibbonCommandFactoryTest.java


示例12: testHystrixTimeoutValueRibbonTimeouts

import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入依赖的package包/类
@Test
public void testHystrixTimeoutValueRibbonTimeouts() throws Exception {
	SpringClientFactory springClientFactory = mock(SpringClientFactory.class);
	ZuulProperties zuulProperties = new ZuulProperties();
	RibbonLoadBalancingHttpClient loadBalancingHttpClient = mock(RibbonLoadBalancingHttpClient.class);
	IClientConfig clientConfig = new DefaultClientConfigImpl();
	clientConfig.set(IClientConfigKey.Keys.ConnectTimeout, 100);
	clientConfig.set(IClientConfigKey.Keys.ReadTimeout, 500);
	doReturn(loadBalancingHttpClient).when(springClientFactory).getClient(anyString(),
			eq(RibbonLoadBalancingHttpClient.class));
	doReturn(clientConfig).when(springClientFactory).getClientConfig(anyString());
	HttpClientRibbonCommandFactory ribbonCommandFactory = new HttpClientRibbonCommandFactory(springClientFactory, zuulProperties, new HashSet<FallbackProvider>());
	RibbonCommandContext context = mock(RibbonCommandContext.class);
	doReturn("service").when(context).getServiceId();
	HttpClientRibbonCommand ribbonCommand = ribbonCommandFactory.create(context);
	assertEquals(600, ribbonCommand.getProperties().executionTimeoutInMilliseconds().get().intValue());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:18,代码来源:HttpClientRibbonCommandFactoryTest.java


示例13: locateRoutes

import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入依赖的package包/类
@Override
protected LinkedHashMap<String, ZuulProperties.ZuulRoute> locateRoutes() {
    LinkedHashMap<String, ZuulProperties.ZuulRoute> routeMap = super.locateRoutes();

    routeStore.getAllRoutes().forEach(route -> routeMap.put(route.getPath(), route));

    return routeMap;
}
 
开发者ID:alexqdjay,项目名称:zuul-dynamic,代码行数:9,代码来源:DynamicRouteLocator.java


示例14: locateRoutes

import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入依赖的package包/类
@Override
protected LinkedHashMap<String, ZuulRoute> locateRoutes() {
  LinkedHashMap<String, ZuulRoute> routesMap = new LinkedHashMap<String, ZuulRoute>();
  routesMap.putAll(super.locateRoutes());
  for (ZuulProperties.ZuulRoute route : findAll()) {
    routesMap.put(route.getPath(), route);
  }
  return routesMap;
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:10,代码来源:StoreProxyRouteLocator.java


示例15: findAll

import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入依赖的package包/类
private List<ZuulProperties.ZuulRoute> findAll() {
  Set<ZuulRouteDto> routers = Sets.newHashSet();
  if (!hasLoaded) {
    routers.addAll(store.loadAllRoute());
    hasLoaded = true;
  } else {
    routers.addAll(store.loadTop10Route());
  }
  routesCache.addAll(routers);
  return Lists.transform(Lists.newArrayList(routesCache),
      new Function<ZuulRouteDto, ZuulProperties.ZuulRoute>() {

        @Override
        public ZuulRoute apply(ZuulRouteDto input) {
          String id = input.getRouteId();
          String path = input.getRoutePath();
          String service_id = input.getServiceId();
          String url = input.getRouteUrl();
          boolean strip_prefix = input.getStripPrefix() != null ? input.getStripPrefix() : true;
          Boolean retryable = input.getRetryAble();
          String sensitiveHeader = input.getSensitiveHeaders();
          String[] sensitiveHeaders = null;
          if (sensitiveHeader != null) {
            sensitiveHeaders = StringUtils.split(sensitiveHeader, ",");
          } else {
            sensitiveHeaders = new String[] {};
          }
          return new ZuulRoute(id, path, service_id, url, strip_prefix, retryable,
              new HashSet<String>(Arrays.asList(sensitiveHeaders)));

        }

      });
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:35,代码来源:StoreProxyRouteLocator.java


示例16: zuulProperties

import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入依赖的package包/类
/**
 *
 */
@Bean
@RefreshScope
@ConfigurationProperties("zuul")
public ZuulProperties zuulProperties() {
    return new ZuulProperties();
}
 
开发者ID:tduni,项目名称:learn-spring-cloud,代码行数:10,代码来源:StartGatewayDynamicServer.java


示例17: getRouteHost

import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入依赖的package包/类
@Override
public String getRouteHost(ZuulWebSocketProperties.WsBrokerage wsBrokerage) {
    ZuulProperties.ZuulRoute zuulRoute = zuulProperties.getRoutes().get(wsBrokerage.getId());
    if (zuulRoute == null || StringUtils.isEmpty(zuulRoute.getServiceId())) return null;

    List<ServiceInstance> instances = discoveryClient.getInstances(zuulRoute.getServiceId());
    ServiceInstance serviceInstance = instances.get(0);
    return serviceInstance.getUri().toString();
}
 
开发者ID:mthizo247,项目名称:spring-cloud-netflix-zuul-websocket,代码行数:10,代码来源:EurekaPropertiesResolver.java


示例18: zuulPropertiesResolver

import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
public ZuulPropertiesResolver zuulPropertiesResolver(
        final ZuulProperties zuulProperties, final DiscoveryClient discoveryClient) {
    Set<ZuulPropertiesResolver> resolvers = new HashSet<>();
    resolvers.add(new UrlPropertiesResolver(zuulProperties));
    resolvers.add(new EurekaPropertiesResolver(discoveryClient, zuulProperties));

    return new CompositeZuulPropertiesResolver(resolvers);
}
 
开发者ID:mthizo247,项目名称:spring-cloud-netflix-zuul-websocket,代码行数:11,代码来源:ZuulWebSocketConfiguration.java


示例19: StoreProxyRouteLocator

import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入依赖的package包/类
/**
 * Creates new instance of {@link StoreProxyRouteLocator}
 * @param servletPath the application servlet path
 * @param discovery the discovery service
 * @param properties the zuul properties
 * @param store the route store
 */
public StoreProxyRouteLocator(String servletPath,
                              DiscoveryClient discovery,
                              ZuulProperties properties,
                              ZuulRouteStore store) {
    super(servletPath, discovery, properties);
    this.store = store;
}
 
开发者ID:jmnarloch,项目名称:zuul-route-cassandra-spring-cloud-starter,代码行数:15,代码来源:StoreProxyRouteLocator.java


示例20: addConfiguredRoutes

import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void addConfiguredRoutes(Map<String, ZuulProperties.ZuulRoute> routes) {
    for (ZuulProperties.ZuulRoute route : store.findAll()) {
        routes.put(route.getPath(), route);
    }
}
 
开发者ID:jmnarloch,项目名称:zuul-route-cassandra-spring-cloud-starter,代码行数:10,代码来源:StoreProxyRouteLocator.java



注:本文中的org.springframework.cloud.netflix.zuul.filters.ZuulProperties类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java UnsupportedTemporalTypeException类代码示例发布时间:2022-05-21
下一篇:
Java UploadResult类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap