org.springframework.cloud.client.loadbalancer.LoadBalancerInterceptor Java Examples
The following examples show how to use
org.springframework.cloud.client.loadbalancer.LoadBalancerInterceptor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RestRibbonEasyTransRpcConsumerImpl.java From EasyTransaction with Apache License 2.0 | 6 votes |
private void init(ApplicationContext ctx) { loadBalancedRestTemplate = new RestTemplate(); SpringClientFactory springClientFactory = springClientFactory(); springClientFactory.setApplicationContext(ctx); loadBalancerClient = new RibbonLoadBalancerClient(springClientFactory); //custom restTemplate LoadBalancerRequestFactory requestFactory = new LoadBalancerRequestFactory(loadBalancerClient, Collections.emptyList()); LoadBalancerInterceptor interceptor = new LoadBalancerInterceptor(loadBalancerClient, requestFactory); List<ClientHttpRequestInterceptor> interceptors = loadBalancedRestTemplate.getInterceptors(); ArrayList<ClientHttpRequestInterceptor> customedInterceptors = new ArrayList<>(interceptors.size() + 1); customedInterceptors.addAll(interceptors); customedInterceptors.add(interceptor); loadBalancedRestTemplate.setInterceptors(customedInterceptors); }
Example #2
Source File: OAuth2LoadBalancerClientAutoConfiguration.java From spring-cloud-security with Apache License 2.0 | 5 votes |
@Bean public UserInfoRestTemplateCustomizer loadBalancedUserInfoRestTemplateCustomizer( final LoadBalancerInterceptor loadBalancerInterceptor) { return new UserInfoRestTemplateCustomizer() { @Override public void customize(OAuth2RestTemplate restTemplate) { List<ClientHttpRequestInterceptor> interceptors = new ArrayList<>( restTemplate.getInterceptors()); interceptors.add(loadBalancerInterceptor); restTemplate.setInterceptors(interceptors); } }; }
Example #3
Source File: PigGatewayApplication.java From pig with MIT License | 4 votes |
@Bean LoadBalancerInterceptor loadBalancerInterceptor(LoadBalancerClient loadBalance){ return new LoadBalancerInterceptor(loadBalance); }
Example #4
Source File: FwGatewayApplication.java From fw-cloud-framework with MIT License | 4 votes |
@Bean LoadBalancerInterceptor loadBalancerInterceptor(LoadBalancerClient loadBalance) { return new LoadBalancerInterceptor(loadBalance); }
Example #5
Source File: MyfeedAutoConfig.java From myfeed with Apache License 2.0 | 4 votes |
@Bean public AsyncRestTemplate asyncRestTemplate(LoadBalancerInterceptor interceptor, LoadBalancerClient loadBalancer) { return asyncRest(interceptor, loadBalancer); }