org.springframework.cloud.netflix.ribbon.SpringClientFactory Java Examples

The following examples show how to use org.springframework.cloud.netflix.ribbon.SpringClientFactory. 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: SofaTracerFeignContext.java    From sofa-tracer with Apache License 2.0 6 votes vote down vote up
private Object wrapperFeignClient(Object bean) {
    // not need to wrapper
    if (bean instanceof SofaTracerFeignClient
        || bean instanceof SofaTracerLoadBalancedFeignClient) {
        return bean;
    }
    if (bean instanceof Client) {
        // LoadBalancerFeignClient Type Wrapper to SofaTracerLoadBalancedFeignClient
        if (bean instanceof LoadBalancerFeignClient
            && !(bean instanceof SofaTracerLoadBalancedFeignClient)) {
            return new SofaTracerLoadBalancedFeignClient(
                newSofaTracerFeignClient(((LoadBalancerFeignClient) bean).getDelegate()),
                beanFactory.getBean(CachingSpringLoadBalancerFactory.class),
                beanFactory.getBean(SpringClientFactory.class));
        }
        return newSofaTracerFeignClient((Client) bean);
    }
    return bean;
}
 
Example #2
Source File: TracedFeignBeanFactory.java    From java-spring-cloud with Apache License 2.0 6 votes vote down vote up
public Object from(Object bean) {
  if (bean instanceof TracingClient || bean instanceof LoadBalancedTracedFeign) {
    return bean;
  }

  if (bean instanceof Client) {
    if (bean instanceof LoadBalancerFeignClient) {
      return new LoadBalancedTracedFeign(
          buildTracingClient(((LoadBalancerFeignClient) bean).getDelegate(), tracer),
          beanFactory.getBean(CachingSpringLoadBalancerFactory.class),
          beanFactory.getBean(SpringClientFactory.class));
    }
    return buildTracingClient((Client) bean, tracer);
  }

  return bean;
}
 
Example #3
Source File: RestRibbonEasyTransRpcConsumerImpl.java    From EasyTransaction with Apache License 2.0 6 votes vote down vote up
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 #4
Source File: RouteListener.java    From spring-cloud-formula with Apache License 2.0 5 votes vote down vote up
public RouteListener(ApplicationContext applicationContext, SpringClientFactory springClientFactory,
                     RouteProperties routeProperties, ConfigurableEnvironment configurableEnvironment,
                     RouteMatcher routeMatcher) {
    this.applicationContext = applicationContext;
    this.springClientFactory = springClientFactory;
    this.routeProperties = routeProperties;
    this.configurableEnvironment = configurableEnvironment;
    this.routeMatcher = routeMatcher;
}
 
Example #5
Source File: ProxyController.java    From haven-platform with Apache License 2.0 5 votes vote down vote up
@Autowired
public ProxyController(HttpProxy httpProxy, SpringClientFactory springClientFactory) {
    this.httpProxy = httpProxy;

    RibbonLoadBalancerContext context = springClientFactory.getLoadBalancerContext(SERVICEID);
    IClientConfig clientConfig = springClientFactory.getClientConfig(SERVICEID);
    ILoadBalancer loadBalancer = springClientFactory.getLoadBalancer(SERVICEID);
    HttpClientLoadBalancerErrorHandler requestSpecificRetryHandler = getRequestSpecificRetryHandler(clientConfig);

    this.commandBuilder = LoadBalancerCommand.builder()
            .withRetryHandler(requestSpecificRetryHandler)
            .withLoadBalancerContext(context)
            .withClientConfig(clientConfig)
            .withLoadBalancer(loadBalancer);
}
 
Example #6
Source File: SeataFeignObjectWrapper.java    From spring-cloud-alibaba with Apache License 2.0 5 votes vote down vote up
SpringClientFactory clientFactory() {
	if (this.springClientFactory == null) {
		this.springClientFactory = this.beanFactory
				.getBean(SpringClientFactory.class);
	}
	return this.springClientFactory;
}
 
Example #7
Source File: SeataLoadBalancerFeignClient.java    From spring-cloud-alibaba with Apache License 2.0 5 votes vote down vote up
SeataLoadBalancerFeignClient(Client delegate,
		CachingSpringLoadBalancerFactory lbClientFactory,
		SpringClientFactory clientFactory,
		SeataFeignObjectWrapper seataFeignObjectWrapper) {
	super((Client) seataFeignObjectWrapper.wrap(delegate), lbClientFactory,
			clientFactory);
}
 
Example #8
Source File: RestRibbonEasyTransRpcConsumerImpl.java    From EasyTransaction with Apache License 2.0 5 votes vote down vote up
public SpringClientFactory springClientFactory() {
	SpringClientFactory factory = new SpringClientFactory();
	ArrayList<RibbonClientSpecification> list = new ArrayList<RibbonClientSpecification>(configurations);
	list.add(new RibbonClientSpecification("default.easytrans", new Class[]{RestEasyTransactionConfiguration.class}));
	factory.setConfigurations(list);
	return factory;
}
 
Example #9
Source File: NetflixRibbonGrayAutoConfiguration.java    From spring-cloud-gray with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public ServerExplainer<Server> ribbonServerExplainer(SpringClientFactory springClientFactory){
    return new RibbonServerExplainer(springClientFactory);
}
 
Example #10
Source File: ApimlRibbonRetryFactory.java    From api-layer with Eclipse Public License 2.0 4 votes vote down vote up
public ApimlRibbonRetryFactory(SpringClientFactory clientFactory, RetryListener... listeners) {
    super(clientFactory);
    this.listeners = listeners;
}
 
Example #11
Source File: RibbonServerExplainer.java    From spring-cloud-gray with Apache License 2.0 4 votes vote down vote up
public RibbonServerExplainer(SpringClientFactory springClientFactory) {
    this.springClientFactory = springClientFactory;
}
 
Example #12
Source File: GrayClientRibbonNacosAutoConfiguration.java    From spring-cloud-gray with Apache License 2.0 4 votes vote down vote up
@Bean
public ServerExplainer<Server> serverExplainer(SpringClientFactory springClientFactory){
    return new NacosServerExplainer(springClientFactory);
}
 
Example #13
Source File: NacosServerExplainer.java    From spring-cloud-gray with Apache License 2.0 4 votes vote down vote up
public NacosServerExplainer(SpringClientFactory springClientFactory) {
    this.springClientFactory = springClientFactory;
}
 
Example #14
Source File: EurekaServerExplainer.java    From spring-cloud-gray with Apache License 2.0 4 votes vote down vote up
public EurekaServerExplainer(SpringClientFactory springClientFactory) {
    this.springClientFactory = springClientFactory;
}
 
Example #15
Source File: SofaTracerLoadBalancedFeignClient.java    From sofa-tracer with Apache License 2.0 4 votes vote down vote up
public SofaTracerLoadBalancedFeignClient(Client client,
                                         CachingSpringLoadBalancerFactory cachingSpringLoadBalancerFactory,
                                         SpringClientFactory clientFactory) {
    super(client, cachingSpringLoadBalancerFactory, clientFactory);
}
 
Example #16
Source File: TracedFeignBeanFactory.java    From java-spring-cloud with Apache License 2.0 4 votes vote down vote up
public LoadBalancedTracedFeign(Client delegate,
                               CachingSpringLoadBalancerFactory lbClientFactory,
                               SpringClientFactory clientFactory) {
  super(delegate, lbClientFactory, clientFactory);
}
 
Example #17
Source File: ZwitscherBoardApplication.java    From cloud-native-zwitscher with MIT License 4 votes vote down vote up
@Bean
@LoadBalanced
public RestTemplate zwitscherServiceRestTemplate(SpringClientFactory clientFactory) {
    RibbonClientHttpRequestFactory requestFactory = new RibbonClientHttpRequestFactory(clientFactory);
    return new RestTemplate(requestFactory);
}
 
Example #18
Source File: RouteConfig.java    From spring-cloud-formula with Apache License 2.0 4 votes vote down vote up
@Bean
public RouteListener routeListener(ApplicationContext applicationContext, SpringClientFactory springClientFactory,
                                   RouteProperties routeProperties, ConfigurableEnvironment environment,
                                   RouteMatcher routeMatcher) {
    return new RouteListener(applicationContext, springClientFactory, routeProperties, environment, routeMatcher);
}
 
Example #19
Source File: Application.java    From haven-platform with Apache License 2.0 4 votes vote down vote up
@Bean
public Servlet dispatcherServlet(HttpProxy httpProxy, SpringClientFactory springClientFactory) {
    return new ProxyController(httpProxy, springClientFactory);
}
 
Example #20
Source File: GatewayApplication.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
public SpringClientFactory springClientFactory() {
    SpringClientFactory factory = new SpringClientFactory();
    factory.setConfigurations(this.configurations);
    return factory;
}
 
Example #21
Source File: ExponentialBackoffRetryFactory.java    From tutorials with MIT License 4 votes vote down vote up
public ExponentialBackoffRetryFactory(SpringClientFactory clientFactory) {
    super(clientFactory);
}
 
Example #22
Source File: ExponentialRandomBackoffRetryFactory.java    From tutorials with MIT License 4 votes vote down vote up
public ExponentialRandomBackoffRetryFactory(SpringClientFactory clientFactory) {
    super(clientFactory);
}
 
Example #23
Source File: FixedBackoffRetryFactory.java    From tutorials with MIT License 4 votes vote down vote up
public FixedBackoffRetryFactory(SpringClientFactory clientFactory) {
    super(clientFactory);
}