private void registerSupplier(ExecutableMethod<?, ?> method, String functionId) { ClassLoadingReporter.reportBeanPresent(method.getReturnType().getType()); suppliers.put(functionId, method); }
Class<?> javaReturnType = returnType.getType(); if (Publishers.isConvertibleToPublisher(javaReturnType) || isFuture) { boolean isSingle = Publishers.isSingle(javaReturnType) || isFuture || context.getValue(Consumes.class, "single", Boolean.class).orElse(false); Argument<?> publisherArgument = returnType.asArgument().getFirstTypeVariable().orElse(Argument.OBJECT_ARGUMENT); request, returnType.asArgument().getFirstTypeVariable().orElse(Argument.OBJECT_ARGUMENT), errorType ); } else if (void.class == javaReturnType) { try { return blockingHttpClient.retrieve( request, returnType.asArgument(), errorType ); } catch (RuntimeException t) {
Class<Object> javaReturnType = returnType.getType(); if (Publishers.isConvertibleToPublisher(javaReturnType)) { Maybe flowable = functionDefinition.firstElement().flatMap(def -> { def, body, Argument.of(Maybe.class, returnType.getFirstTypeVariable().orElse(Argument.OBJECT_ARGUMENT)) ); }); flowable = flowable.switchIfEmpty(Maybe.error(new FunctionNotFoundException(functionName))); return ConversionService.SHARED.convert(flowable, returnType.asArgument()).orElseThrow(() -> new FunctionExecutionException("Unsupported reactive type: " + returnType.getType())); } else { return functionInvoker.invoke(def, body, returnType.asArgument());
/** * @return The return type as an argument */ default Argument<T> asArgument() { Collection<Argument<?>> values = getTypeVariables().values(); return Argument.of(getType(), values.toArray(new Argument[0])); }
private void processHttpMethods(Collection<BeanDefinition<?>> clientBeans) { for (BeanDefinition<?> clientBean : clientBeans) { final Optional<Class[]> additionalTypes = clientBean.getValue(TypeHint.class, Class[].class); additionalTypes.ifPresent(classes -> { for (Class aClass : classes) { ClassLoadingReporter.reportBeanPresent(aClass); } }); final Collection<? extends ExecutableMethod<?, ?>> executableMethods = clientBean.getExecutableMethods(); executableMethods.parallelStream().forEach((Consumer<ExecutableMethod<?, ?>>) executableMethod -> { if (executableMethod.hasStereotype(HttpMethodMapping.class)) { final ReturnType<?> returnType = executableMethod.getReturnType(); final Class<?> javaType = returnType.getType(); if (!ClassUtils.isJavaLangType(javaType)) { ClassLoadingReporter.reportBeanPresent(javaType); } reportArguments(returnType.getTypeParameters()); reportArguments(executableMethod.getArguments()); } }); } }
Class<?> javaReturnType = genericReturnType.getType(); Optional<Class<?>> javaPayloadType = genericReturnType.getFirstTypeVariable().map(arg -> arg.getType()); Optional<Argument<?>> generic = genericReturnType.getFirstTypeVariable(); if (generic.isPresent()) {
/** * @param targetMethod The {@link MethodExecutionHandle} * @return A String with the target method */ protected String getMethodString(MethodExecutionHandle targetMethod) { return new StringBuilder() .append(targetMethod.getReturnType().asArgument().getTypeString(false)) .append(" ") .append(targetMethod.getDeclaringType().getName()) .append('.') .append(targetMethod.getMethodName()) .append("(") .append(Arrays .stream(targetMethod.getArguments()) .map(argument -> argument.getType().getName() + " " + argument.getName()) .collect(Collectors.joining(", "))) .append(")") .toString(); } }
private boolean isResponsePublisher(ReturnType<?> genericReturnType, Class<?> javaReturnType) { return Publishers.isConvertibleToPublisher(javaReturnType) && genericReturnType.getFirstTypeVariable().map(arg -> HttpResponse.class.isAssignableFrom(arg.getType())).orElse(false); }
@Override public Optional<ExecutorService> select(MethodReference method) { if (method.hasStereotype(NonBlocking.class)) { return Optional.empty(); } else { Class returnType = method.getReturnType().getType(); if (isNonBlocking(returnType)) { return Optional.empty(); } if (HttpResponse.class.isAssignableFrom(returnType)) { Optional<Argument<?>> generic = method.getReturnType().getFirstTypeVariable(); if (generic.isPresent()) { Class argumentType = generic.get().getType(); if (isNonBlocking(argumentType)) { return Optional.empty(); } } } } return Optional.of(ioExecutor); }
/** * @param targetMethod The {@link MethodExecutionHandle} * @return A String with the target method */ protected String getMethodString(MethodExecutionHandle targetMethod) { return new StringBuilder() .append(targetMethod.getReturnType().asArgument().getTypeString(false)) .append(" ") .append(targetMethod.getDeclaringType().getName()) .append('.') .append(targetMethod.getMethodName()) .append("(") .append(Arrays .stream(targetMethod.getArguments()) .map(argument -> argument.getType().getName() + " " + argument.getName()) .collect(Collectors.joining(", "))) .append(")") .toString(); } }
@Override public List<MediaType> getProduces() { Optional<Argument<?>> firstTypeVariable = executableMethod.getReturnType().getFirstTypeVariable(); if (firstTypeVariable.isPresent() && Event.class.isAssignableFrom(firstTypeVariable.get().getType())) { return Collections.singletonList(MediaType.TEXT_EVENT_STREAM_TYPE); } else { return abstractRoute.getProduces(); } }
private void registerBiFunction(ExecutableMethod<?, ?> method, String functionId) { ClassLoadingReporter.reportBeanPresent(method.getReturnType().getType()); for (Class argumentType : method.getArgumentTypes()) { ClassLoadingReporter.reportBeanPresent(argumentType); } biFunctions.put(functionId, method); }
Class<Object> javaReturnType = returnType.getType(); if (Publishers.isConvertibleToPublisher(javaReturnType)) { ConversionService<?> conversionService = ConversionService.SHARED; .convert(retryObservable, returnType.asArgument()) .orElseThrow(() -> new IllegalStateException("Unconvertible Reactive type: " + result));
private Object interceptPublisher(MethodInvocationContext<Object, Object> context, ReturnType returnTypeObject, Class returnType) { CacheOperation cacheOperation = new CacheOperation(context, returnType); AnnotationValue<Cacheable> cacheable = cacheOperation.cacheable; if (cacheable != null) { SingleSubscriberPublisher<Object> publisher = buildPublisher(context, returnTypeObject, cacheOperation, cacheable); Optional converted = ConversionService.SHARED.convert(publisher, ConversionContext.of(returnTypeObject.asArgument())); if (converted.isPresent()) { return converted.get(); } else { throw new UnsupportedOperationException("Cannot convert publisher into target type: " + returnType); } } else { return context.proceed(); } }
Object key = keyGenerator.generateKey(context, params); CompletableFuture<Object> thisFuture = new CompletableFuture<>(); Argument<?> firstTypeVariable = returnTypeObject.getFirstTypeVariable().orElse(Argument.of(Object.class)); asyncCache.get(key, firstTypeVariable).whenComplete((BiConsumer<Optional<?>, Throwable>) (o, throwable) -> { if (throwable == null && o.isPresent()) {
private void registerFunction(ExecutableMethod<?, ?> method, String functionId) { ClassLoadingReporter.reportBeanPresent(method.getReturnType().getType()); for (Class argumentType : method.getArgumentTypes()) { ClassLoadingReporter.reportBeanPresent(argumentType); } functions.put(functionId, method); } }
Class<?> javaReturnType = returnType.getType(); if (Publishers.isConvertibleToPublisher(javaReturnType) || isFuture) { boolean isSingle = Publishers.isSingle(javaReturnType) || isFuture || context.getValue(Consumes.class, "single", Boolean.class).orElse(false); Argument<?> publisherArgument = returnType.asArgument().getFirstTypeVariable().orElse(Argument.OBJECT_ARGUMENT); request, returnType.asArgument().getFirstTypeVariable().orElse(Argument.OBJECT_ARGUMENT), errorType ); } else if (void.class == javaReturnType) { try { return blockingHttpClient.retrieve( request, returnType.asArgument(), errorType ); } catch (RuntimeException t) {
.convert(recoveryFlowable, context.getReturnType().asArgument()) .orElseThrow(() -> new FallbackException("Unsupported Reactive type: " + result));
ClassLoadingReporter.reportBeanPresent(method.getReturnType().getType()); for (Class argumentType : method.getArgumentTypes()) { ClassLoadingReporter.reportBeanPresent(argumentType);
Class<?> javaReturnType = returnType.getType(); if (Publishers.isConvertibleToPublisher(javaReturnType) || isFuture) { boolean isSingle = Publishers.isSingle(javaReturnType) || isFuture || context.getValue(Consumes.class, "single", Boolean.class).orElse(false); Argument<?> publisherArgument = returnType.asArgument().getFirstTypeVariable().orElse(Argument.OBJECT_ARGUMENT); request, returnType.asArgument().getFirstTypeVariable().orElse(Argument.OBJECT_ARGUMENT), errorType ); } else if (void.class == javaReturnType) { try { return blockingHttpClient.retrieve( request, returnType.asArgument(), errorType ); } catch (RuntimeException t) {