org.springframework.cloud.openfeign.FeignContext Java Examples
The following examples show how to use
org.springframework.cloud.openfeign.FeignContext.
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: TargeterInvocationHandler.java From spring-cloud-alibaba with Apache License 2.0 | 6 votes |
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { /** * args[0]: FeignClientFactoryBean factory args[1]: Feign.Builder feign args[2]: * FeignContext context args[3]: Target.HardCodedTarget<T> target */ FeignContext feignContext = cast(args[2]); Target.HardCodedTarget<?> target = cast(args[3]); // Execute Targeter#target method first method.setAccessible(true); // Get the default proxy object Object defaultProxy = method.invoke(bean, args); // Create Dubbo Proxy if required return createDubboProxyIfRequired(feignContext, target, defaultProxy); }
Example #2
Source File: SeataContextBeanPostProcessor.java From spring-cloud-alibaba with Apache License 2.0 | 5 votes |
@Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof FeignContext && !(bean instanceof SeataFeignContext)) { return new SeataFeignContext(getSeataFeignObjectWrapper(), (FeignContext) bean); } return bean; }
Example #3
Source File: TargeterInvocationHandler.java From spring-cloud-alibaba with Apache License 2.0 | 5 votes |
private Object createDubboProxyIfRequired(FeignContext feignContext, Target target, Object defaultProxy) { DubboInvocationHandler dubboInvocationHandler = createDubboInvocationHandler( feignContext, target, defaultProxy); if (dubboInvocationHandler == null) { return defaultProxy; } return newProxyInstance(target.type().getClassLoader(), new Class<?>[] { target.type() }, dubboInvocationHandler); }
Example #4
Source File: TargeterInvocationHandler.java From spring-cloud-alibaba with Apache License 2.0 | 5 votes |
private DubboInvocationHandler createDubboInvocationHandler(FeignContext feignContext, Target target, Object defaultFeignClientProxy) { // Service name equals @FeignClient.name() String serviceName = target.name(); Class<?> targetType = target.type(); // Get Contract Bean from FeignContext Contract contract = feignContext.getInstance(serviceName, Contract.class); DubboTransportedMethodMetadataResolver resolver = new DubboTransportedMethodMetadataResolver( environment, contract); Map<DubboTransportedMethodMetadata, RestMethodMetadata> feignRestMethodMetadataMap = resolver .resolve(targetType); if (feignRestMethodMetadataMap.isEmpty()) { // @DubboTransported method was not // found from the Client interface if (logger.isDebugEnabled()) { logger.debug("@{} method was not found in the Feign target type[{}]", DubboTransported.class.getSimpleName(), targetType.getName()); } return null; } // Update Metadata repository.initializeMetadata(serviceName); Map<Method, FeignMethodMetadata> feignMethodMetadataMap = getFeignMethodMetadataMap( serviceName, feignRestMethodMetadataMap); InvocationHandler defaultFeignClientInvocationHandler = Proxy .getInvocationHandler(defaultFeignClientProxy); DubboInvocationHandler dubboInvocationHandler = new DubboInvocationHandler( feignMethodMetadataMap, defaultFeignClientInvocationHandler, classLoader, contextFactory); return dubboInvocationHandler; }
Example #5
Source File: FeignContextBeanPostProcessor.java From java-spring-cloud with Apache License 2.0 | 5 votes |
@Override public Object postProcessBeforeInitialization(Object bean, String name) throws BeansException { if (bean instanceof FeignContext && !(bean instanceof TraceFeignContext)) { return new TraceFeignContext(tracer, (FeignContext) bean, beanFactory, spanDecorators); } return bean; }
Example #6
Source File: FeignTracingAutoConfigurationTest.java From java-spring-cloud with Apache License 2.0 | 5 votes |
@Test public void loadFeignTracingByDefault() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); context.register(FeignContextConfig.class, TracerConfig.class, FeignTracingAutoConfiguration.class); context.refresh(); FeignContext feignContext = context.getBean(TraceFeignContext.class); assertNotNull(feignContext); }
Example #7
Source File: FeignContextBeanPostProcessor.java From spring-cloud-sleuth with Apache License 2.0 | 5 votes |
@Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof FeignContext && !(bean instanceof TraceFeignContext)) { return new TraceFeignContext(traceFeignObjectWrapper(), (FeignContext) bean); } return bean; }
Example #8
Source File: SeataFeignContext.java From spring-cloud-alibaba with Apache License 2.0 | 4 votes |
SeataFeignContext(SeataFeignObjectWrapper seataFeignObjectWrapper, FeignContext delegate) { this.seataFeignObjectWrapper = seataFeignObjectWrapper; this.delegate = delegate; }
Example #9
Source File: SentinelFeign.java From spring-cloud-alibaba with Apache License 2.0 | 4 votes |
@Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; feignContext = this.applicationContext.getBean(FeignContext.class); }
Example #10
Source File: TraceFeignContext.java From java-spring-cloud with Apache License 2.0 | 4 votes |
TraceFeignContext(Tracer tracer, FeignContext delegate, BeanFactory beanFactory, List<FeignSpanDecorator> spanDecorators) { this.delegate = delegate; this.tracedFeignBeanFactory = new TracedFeignBeanFactory(tracer, beanFactory, spanDecorators); }
Example #11
Source File: TraceFeignContext.java From spring-cloud-sleuth with Apache License 2.0 | 4 votes |
TraceFeignContext(TraceFeignObjectWrapper traceFeignObjectWrapper, FeignContext delegate) { this.traceFeignObjectWrapper = traceFeignObjectWrapper; this.delegate = delegate; }