All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.sphere.sdk.client.BlockingSphereClientImpl Maven / Gradle / Ivy

Go to download

This SDK is announced to be deprecated latest by 31 December 2022, please follow more details on SDK deprecation plan https://docs.commercetools.com/api/releases/2021-08-31-announced-long-term-support-plan-for-commercetools-sdks. We recommend you to use our new SDK here https://docs.commercetools.com/sdk/jvm-sdk#java-sdk-v2.

There is a newer version: 2.16.0
Show newest version
package io.sphere.sdk.client;

import io.sphere.sdk.models.Base;

import java.time.Duration;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.TimeUnit;

import static io.sphere.sdk.client.SphereClientUtils.blockingWait;

final class BlockingSphereClientImpl extends Base implements BlockingSphereClient {

    private final SphereClient delegate;
    private final long defaultTimeout;
    private final TimeUnit unit;

    public BlockingSphereClientImpl(final SphereClient delegate, final long defaultTimeout, final TimeUnit unit) {
        this.delegate = delegate;
        this.defaultTimeout = defaultTimeout;
        this.unit = unit;
    }

    @Override
    public void close() {
        delegate.close();
    }

    @Override
    public  CompletionStage execute(final SphereRequest sphereRequest) {
        return delegate.execute(sphereRequest);
    }

    @Override
    public  T executeBlocking(final SphereRequest sphereRequest) {
        return executeBlocking(sphereRequest, defaultTimeout, unit);
    }

    @Override
    public  T executeBlocking(final SphereRequest sphereRequest, final long timeout, final TimeUnit unit) {
        final CompletionStage completionStage = execute(sphereRequest);
        return blockingWait(completionStage, sphereRequest, timeout, unit);
    }

    @Override
    public  T executeBlocking(final SphereRequest sphereRequest, final Duration duration) {
        return executeBlocking(sphereRequest, duration.toMillis(), TimeUnit.MILLISECONDS);
    }

    @Override
    public SphereApiConfig getConfig() {
        return this.delegate.getConfig();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy