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

org.zodiac.sentinel.base.support.AbstratcInitFunc Maven / Gradle / Ivy

package org.zodiac.sentinel.base.support;

import java.util.concurrent.atomic.AtomicBoolean;

import com.alibaba.csp.sentinel.init.InitFunc;

public abstract class AbstratcInitFunc implements InitFunc {

    private final AtomicBoolean initialized = new AtomicBoolean(false);

    protected AbstratcInitFunc() {
    }

    @Override
    public final void init() throws Exception {
        if (initialized.compareAndSet(false, true)) {
            try {
                this.initialize();
            } catch (Exception e) {
                initialized.compareAndSet(true, false);
                throw new Exception(e);
            }
        }
    }

    protected abstract void initialize() throws Exception;

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy