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

io.soffa.service.context.TenantContext Maven / Gradle / Ivy

package io.soffa.service.context;

import io.soffa.commons.lang.TextUtil;

import java.util.Optional;

public class TenantContext {

    private static final ThreadLocal current = new ThreadLocal<>();

    public synchronized static void set(String value) {
        if (TextUtil.isEmpty(value)) {
            current.remove();
        } else {
            current.set(value);
        }
    }

    public synchronized static void clear() {
        current.remove();
    }

    public static Optional get() {
        return Optional.ofNullable(current.get());
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy