io.smilego.tenant.TenantContext Maven / Gradle / Ivy
package io.smilego.tenant;
import io.smilego.tenant.util.LogBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class TenantContext {
private static final Logger log = LoggerFactory.getLogger(TenantContext.class);
public static final String TENANT_HEADER = "X-TENANT-ID";
public TenantContext() {}
private static final InheritableThreadLocal currentTenant = new InheritableThreadLocal<>();
public static void setTenantId(String tenantId) {
log.debug(LogBuilder.of()
.header("Setting tenant context")
.row("Tenant: {}", tenantId)
.build());
currentTenant.set(tenantId);
}
public static String getTenantId() {
return currentTenant.get();
}
public static void clear(){
currentTenant.remove();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy