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

io.smallrye.faulttolerance.standalone.StandaloneSpi Maven / Gradle / Ivy

There is a newer version: 6.7.1
Show newest version
package io.smallrye.faulttolerance.standalone;

import java.lang.reflect.Type;
import java.util.function.Function;

import io.smallrye.faulttolerance.api.CircuitBreakerMaintenance;
import io.smallrye.faulttolerance.api.FaultTolerance;
import io.smallrye.faulttolerance.api.Guard;
import io.smallrye.faulttolerance.api.Spi;
import io.smallrye.faulttolerance.api.TypedGuard;
import io.smallrye.faulttolerance.core.apiimpl.BuilderLazyDependencies;
import io.smallrye.faulttolerance.core.apiimpl.FaultToleranceImpl;
import io.smallrye.faulttolerance.core.apiimpl.GuardImpl;
import io.smallrye.faulttolerance.core.apiimpl.TypedGuardImpl;

public class StandaloneSpi implements Spi {
    static class EagerDependenciesHolder {
        static final EagerDependencies INSTANCE = new EagerDependencies();
    }

    static class LazyDependenciesHolder {
        static final BuilderLazyDependencies INSTANCE = StandaloneFaultTolerance.getLazyDependencies();
    }

    @Override
    public boolean applies() {
        return true;
    }

    @Override
    public int priority() {
        return 0;
    }

    @Override
    public Guard.Builder newGuardBuilder() {
        return new GuardImpl.BuilderImpl(EagerDependenciesHolder.INSTANCE, () -> LazyDependenciesHolder.INSTANCE);
    }

    @Override
    public  TypedGuard.Builder newTypedGuardBuilder(Type type) {
        return new TypedGuardImpl.BuilderImpl<>(EagerDependenciesHolder.INSTANCE, () -> LazyDependenciesHolder.INSTANCE,
                type);
    }

    @Override
    @Deprecated(forRemoval = true)
    public  FaultTolerance.Builder newBuilder(Function, R> finisher) {
        return new FaultToleranceImpl.BuilderImpl<>(EagerDependenciesHolder.INSTANCE, () -> LazyDependenciesHolder.INSTANCE,
                null, finisher);
    }

    @Override
    @Deprecated(forRemoval = true)
    public  FaultTolerance.Builder newAsyncBuilder(Class asyncType, Function, R> finisher) {
        return new FaultToleranceImpl.BuilderImpl<>(EagerDependenciesHolder.INSTANCE, () -> LazyDependenciesHolder.INSTANCE,
                asyncType, finisher);
    }

    @Override
    public CircuitBreakerMaintenance circuitBreakerMaintenance() {
        return EagerDependenciesHolder.INSTANCE.cbMaintenance;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy