/** * Configure a processor function to customize Unmarshaller instances. * @param processor the function to use * @since 5.1.3 */ public void setUnmarshallerProcessor(Function<Unmarshaller, Unmarshaller> processor) { this.unmarshallerProcessor = this.unmarshallerProcessor.andThen(processor); }
/** * Configure a processor function to customize Marshaller instances. * @param processor the function to use * @since 5.1.3 */ public void setMarshallerProcessor(Function<Marshaller, Marshaller> processor) { this.marshallerProcessor = this.marshallerProcessor.andThen(processor); }
@Override public void addUrlTransformer(Function<String, String> transformer) { Assert.notNull(transformer, "'encoder' must not be null"); this.urlTransformer = this.urlTransformer.andThen(transformer); }
/** * Configure a processor function to customize Unmarshaller instances. * @param processor the function to use * @since 5.1.3 */ public void setUnmarshallerProcessor(Function<Unmarshaller, Unmarshaller> processor) { this.unmarshallerProcessor = this.unmarshallerProcessor.andThen(processor); }
/** * Configure a processor function to customize Marshaller instances. * @param processor the function to use * @since 5.1.3 */ public void setMarshallerProcessor(Function<Marshaller, Marshaller> processor) { this.marshallerProcessor = this.marshallerProcessor.andThen(processor); }
@Override public void addUrlTransformer(Function<String, String> transformer) { Assert.notNull(transformer, "'encoder' must not be null"); this.urlTransformer = this.urlTransformer.andThen(transformer); }
public void thenApplyWithContext(Function<Result, Result> fn) { this.resultFuture = resultFuture.thenApply(fn.compose(beforeContext).andThen(afterContext)); }
public void thenApplyWithContext(Function<Result, Result> fn) { this.resultFuture = resultFuture.thenApply(fn.compose(beforeContext).andThen(afterContext)); }
/** * Constructor with externally managed Reactor Netty resources, including * {@link LoopResources} for event loop threads, and {@link ConnectionProvider} * for the connection pool. * <p>This constructor should be used only when you don't want the client * to participate in the Reactor Netty global resources. By default the * client participates in the Reactor Netty global resources held in * {@link reactor.netty.http.HttpResources}, which is recommended since * fixed, shared resources are favored for event loop concurrency. However, * consider declaring a {@link ReactorResourceFactory} bean with * {@code globalResources=true} in order to ensure the Reactor Netty global * resources are shut down when the Spring ApplicationContext is closed. * @param factory the resource factory to obtain the resources from * @param mapper a mapper for further initialization of the created client * @since 5.1 */ public ReactorClientHttpConnector(ReactorResourceFactory factory, Function<HttpClient, HttpClient> mapper) { this.httpClient = defaultInitializer.andThen(mapper).apply(initHttpClient(factory)); }
@Override public final V computeIfAbsent(final K key, final Function<? super K, ? extends V> mappingFunction) { return map.computeIfAbsent(key, mappingFunction.<V>andThen(v -> { keyUsed(key); limit(); return v; })); }
@Test public void composeResourceLookupFunction() throws Exception { ClassPathResource defaultResource = new ClassPathResource("response.txt", getClass()); Function<ServerRequest, Mono<Resource>> lookupFunction = new PathResourceLookupFunction("/resources/**", new ClassPathResource("org/springframework/web/reactive/function/server/")); Function<ServerRequest, Mono<Resource>> customLookupFunction = lookupFunction.andThen(resourceMono -> resourceMono .switchIfEmpty(Mono.just(defaultResource))); MockServerRequest request = MockServerRequest.builder() .uri(new URI("http://localhost/resources/foo")) .build(); Mono<Resource> result = customLookupFunction.apply(request); StepVerifier.create(result) .expectNextMatches(resource -> { try { return defaultResource.getFile().equals(resource.getFile()); } catch (IOException ex) { return false; } }) .expectComplete() .verify(); }
final StepVerifier.Step<O> inputFusedConditionalOutputConditionalTryNext(OperatorScenario<I, PI, O, PO> scenario) { return StepVerifier.create(scenario.body() .andThen(this::conditional) .apply(anySource(scenario)), Math.max(scenario.producerCount(), scenario.receiverCount())) .consumeSubscriptionWith(s -> s.request(0)); }
final StepVerifier.Step<O> inputFusedAsyncOutputFusedAsyncConditional(OperatorScenario<I, PI, O, PO> scenario) { UnicastProcessor<I> up = UnicastProcessor.create(); return StepVerifier.create(scenario.body() .andThen(this::conditional) .apply(withFluxSource(up))) .expectFusion(Fuseable.ASYNC) .then(() -> testUnicastSource(scenario, up)); }
@SuppressWarnings("unchecked") final StepVerifier.Step<O> inputFusedErrorOutputFusedConditional(OperatorScenario<I, PI, O, PO> scenario) { UnicastProcessor<I> up = UnicastProcessor.create(); return StepVerifier.create(scenario.body() .andThen(this::conditional) .apply(up.as(f -> withFluxSource(new FluxFuseableExceptionOnPoll<>( f, exception()))))) .then(testUnicastDropPath(scenario, up)); }