Search in sources :

Example 1 with HttpResources

use of reactor.netty.http.HttpResources in project spring-framework by spring-projects.

the class ReactorResourceFactoryTests method globalResources.

@Test
void globalResources() throws Exception {
    this.resourceFactory.setUseGlobalResources(true);
    this.resourceFactory.afterPropertiesSet();
    HttpResources globalResources = HttpResources.get();
    assertThat(this.resourceFactory.getConnectionProvider()).isSameAs(globalResources);
    assertThat(this.resourceFactory.getLoopResources()).isSameAs(globalResources);
    assertThat(globalResources.isDisposed()).isFalse();
    this.resourceFactory.destroy();
    assertThat(globalResources.isDisposed()).isTrue();
}
Also used : HttpResources(reactor.netty.http.HttpResources) Test(org.junit.jupiter.api.Test)

Example 2 with HttpResources

use of reactor.netty.http.HttpResources in project spring-framework by spring-projects.

the class ReactorResourceFactory method afterPropertiesSet.

@Override
public void afterPropertiesSet() {
    if (this.useGlobalResources) {
        Assert.isTrue(this.loopResources == null && this.connectionProvider == null, "'useGlobalResources' is mutually exclusive with explicitly configured resources");
        HttpResources httpResources = HttpResources.get();
        if (this.globalResourcesConsumer != null) {
            this.globalResourcesConsumer.accept(httpResources);
        }
        this.connectionProvider = httpResources;
        this.loopResources = httpResources;
    } else {
        if (this.loopResources == null) {
            this.manageLoopResources = true;
            this.loopResources = this.loopResourcesSupplier.get();
        }
        if (this.connectionProvider == null) {
            this.manageConnectionProvider = true;
            this.connectionProvider = this.connectionProviderSupplier.get();
        }
    }
}
Also used : HttpResources(reactor.netty.http.HttpResources)

Aggregations

HttpResources (reactor.netty.http.HttpResources)2 Test (org.junit.jupiter.api.Test)1