SentinelInvocationHandler(Target<?> target, Map<Method, MethodHandler> dispatch) { this.target = checkNotNull(target, "target"); this.dispatch = checkNotNull(dispatch, "dispatch"); }
FescarFeignClient(BeanFactory beanFactory) { this.beanFactory = beanFactory; this.delegate = new Client.Default(null, null); }
@Override public void apply(final RequestTemplate requestTemplate) { requestTemplate.header(CommonConstant.TX_TRANSACTION_GROUP, TxTransactionLocal.getInstance().getTxGroupId()); }
@Bean @Scope("prototype") public Feign.Builder feignBuilder() { return Feign.builder().requestInterceptor(new RestTemplateInterceptor()); }
@Override public Integer statusCode(Response response) { return response.status(); }
public List<MethodMetadata> parseAndValidatateMetadata(Class<?> targetType) { List<MethodMetadata> metas = this.delegate.parseAndValidatateMetadata(targetType); for (int i = 0; metas != null && i < metas.size(); i++) { MethodMetadata meta = metas.get(i); if (meta.returnType() == void.class) { meta.returnType(Void.class); } } return metas == null ? new ArrayList<MethodMetadata>() : metas; }
@Override public List<MethodMetadata> parseAndValidatateMetadata(Class<?> targetType) { List<MethodMetadata> metadatas = delegate.parseAndValidatateMetadata(targetType); metadatas.forEach(metadata -> metadataMap .put(targetType.getName() + metadata.configKey(), metadata)); return metadatas; }
@RequestLine("GET /greeting") String greeting();
@Override public String url(Request request) { return request.url(); }
private String getHeaderValue(Request req, String headerName) { Map<String, Collection<String>> headers = req.headers(); Collection<String> values = headers.get(headerName); String value = null; if (values != null && values.isEmpty() == false) { String[] array = new String[values.size()]; values.toArray(array); value = array[0]; } return value; }
@Bean Request.Options feignOptions() { return new Request.Options(5000, 5000); }
@Override public String method(Request request) { return request.method(); }
Object executeTraceFeignClient(Object bean, ProceedingJoinPoint pjp) throws IOException { Object[] args = pjp.getArgs(); Request request = (Request) args[0]; Request.Options options = (Request.Options) args[1]; return ((Client) bean).execute(request, options); }
@Override public Feign build() { super.invocationHandlerFactory( (target, dispatch) -> new DecoratorInvocationHandler(target, dispatch, invocationDecorator)); return super.build(); }
SentinelInvocationHandler(Target<?> target, Map<Method, MethodHandler> dispatch, FallbackFactory fallbackFactory) { this.target = checkNotNull(target, "target"); this.dispatch = checkNotNull(dispatch, "dispatch"); this.fallbackFactory = fallbackFactory; this.fallbackMethodMap = toFallbackMethod(dispatch); }
@Override public Response execute(Request request, Request.Options options) throws IOException { Request modifiedRequest = getModifyRequest(request); try { return this.delegate.execute(modifiedRequest, options); } finally { } }
public DecoratorInvocationHandler(Target<?> target, Map<Method, MethodHandler> dispatch, FeignDecorator invocationDecorator) { this.target = checkNotNull(target, "target"); checkNotNull(dispatch, "dispatch"); this.decoratedDispatch = decorateMethodHandlers(dispatch, invocationDecorator, target); }