public static Type bodyActualType(MethodMetadata methodMetadata) { return getBodyActualType(methodMetadata.bodyType()); }
public static WebReactiveHttpClient webClient(MethodMetadata methodMetadata, WebClient webClient) { final Type returnType = methodMetadata.returnType(); Type returnPublisherType = ((ParameterizedType) returnType).getRawType(); ParameterizedTypeReference<Object> returnActualType = ParameterizedTypeReference.forType( resolveLastTypeParameter(returnType, (Class<?>) returnPublisherType)); ParameterizedTypeReference<Object> bodyActualType = ofNullable( getBodyActualType(methodMetadata.bodyType())) .map(type -> ParameterizedTypeReference.forType(type)) .orElse(null); return new WebReactiveHttpClient(webClient, bodyActualType, returnPublisherType, returnActualType); }
public static WebReactiveHttpClient webClient(MethodMetadata methodMetadata, WebClient webClient) { final Type returnType = methodMetadata.returnType(); Type returnPublisherType = ((ParameterizedType) returnType).getRawType(); ParameterizedTypeReference<Object> returnActualType = ParameterizedTypeReference.forType( resolveLastTypeParameter(returnType, (Class<?>) returnPublisherType)); ParameterizedTypeReference<Object> bodyActualType = ofNullable( getBodyActualType(methodMetadata.bodyType())) .map(type -> ParameterizedTypeReference.forType(type)) .orElse(null); return new WebReactiveHttpClient(webClient, bodyActualType, rx2ToReactor(returnPublisherType), returnActualType); }
public WebReactiveHttpClient(MethodMetadata methodMetadata, WebClient webClient, ReactiveHttpRequestInterceptor requestInterceptor, ReactiveStatusHandler statusHandler, boolean decode404) { this.webClient = webClient; this.metadata = methodMetadata; this.requestInterceptor = requestInterceptor; this.statusHandler = statusHandler; this.decode404 = decode404; this.logger = new Logger(); this.methodTag = methodMetadata.configKey().substring(0, methodMetadata.configKey().indexOf('(')); Type bodyType = methodMetadata.bodyType(); bodyActualType = getBodyActualType(bodyType); final Type returnType = methodMetadata.returnType(); returnPublisherType = ((ParameterizedType) returnType).getRawType(); returnActualType = ParameterizedTypeReference.forType( resolveLastTypeParameter(returnType, (Class<?>) returnPublisherType)); }
public static JettyReactiveHttpClient jettyClient( MethodMetadata methodMetadata, HttpClient httpClient, JsonFactory jsonFactory, ObjectMapper objectMapper) { final Type returnType = methodMetadata.returnType(); Class returnPublisherType = (Class)((ParameterizedType) returnType).getRawType(); Class returnActualType = getClass(resolveLastTypeParameter(returnType, returnPublisherType)); Class bodyActualType = getClass(getBodyActualType(methodMetadata.bodyType())); return new JettyReactiveHttpClient(httpClient, bodyActualType, returnPublisherType, returnActualType, jsonFactory, objectMapper.writerFor(bodyActualType), objectMapper.readerFor(returnActualType)); }
@Override protected RequestTemplate resolve(Object[] argv, RequestTemplate mutable, Map<String, Object> variables) { Object body = argv[metadata.bodyIndex()]; checkArgument(body != null, "Body parameter %s was null", metadata.bodyIndex()); try { encoder.encode(body, metadata.bodyType(), mutable); } catch (EncodeException e) { throw e; } catch (RuntimeException e) { throw new EncodeException(e.getMessage(), e); } return super.resolve(argv, mutable, variables); } }
@Override protected RequestTemplate resolve( final Object[] argv, final RequestTemplate mutable, final Map<String, Object> variables) { final Object body = argv[metadata.bodyIndex()]; checkNotNull(body, "Body parameter %s was null", metadata.bodyIndex()); try { encoder.encode(body, metadata.bodyType(), mutable); } catch (final EncodeException encodeException) { throw encodeException; } catch (final RuntimeException unexpectedException) { throw new EncodeException(unexpectedException.getMessage(), unexpectedException); } return super.resolve(argv, mutable, variables); } }
public static JettyReactiveHttpClient jettyClient( MethodMetadata methodMetadata, HttpClient httpClient, JsonFactory jsonFactory, ObjectMapper objectMapper) { final Type returnType = methodMetadata.returnType(); Class returnPublisherType = (Class)((ParameterizedType) returnType).getRawType(); Type returnActualType = resolveLastTypeParameter(returnType, returnPublisherType); Type bodyActualType = getBodyActualType(methodMetadata.bodyType()); ObjectWriter bodyWriter = bodyActualType != null ? objectMapper.writerFor(objectMapper.constructType(bodyActualType)) : null; ObjectReader responseReader = objectMapper.readerFor(objectMapper.constructType(returnActualType)); return new JettyReactiveHttpClient(httpClient, getClass(bodyActualType), returnPublisherType, getClass(returnActualType), jsonFactory, bodyWriter, responseReader); }
public static Java11ReactiveHttpClient jettyClient( MethodMetadata methodMetadata, HttpClient httpClient, JsonFactory jsonFactory, ObjectMapper objectMapper) { final Type returnType = methodMetadata.returnType(); Class returnPublisherType = (Class)((ParameterizedType) returnType).getRawType(); Type returnActualType = resolveLastTypeParameter(returnType, returnPublisherType); Type bodyActualType = getBodyActualType(methodMetadata.bodyType()); ObjectWriter bodyWriter = bodyActualType != null ? objectMapper.writerFor(objectMapper.constructType(bodyActualType)) : null; ObjectReader responseReader = objectMapper.readerFor(objectMapper.constructType(returnActualType)); return new Java11ReactiveHttpClient(httpClient, getClass(bodyActualType), returnPublisherType, getClass(returnActualType), jsonFactory, bodyWriter, responseReader); }
checkState(data.bodyIndex() == null, "Method has too many Body parameters: %s", method); data.bodyIndex(i); data.bodyType(Types.resolve(targetType, targetType, method.getGenericParameterTypes()[i]));
data.bodyType(Types.resolve(targetType, targetType, genericParameterTypes[i]));