
com.icthh.xm.commons.tenant.internal.TenantContextDataHolder Maven / Gradle / Ivy
package com.icthh.xm.commons.tenant.internal;
import com.icthh.xm.commons.tenant.Tenant;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Stack;
import java.util.function.Consumer;
import java.util.function.Supplier;
/**
* The {@link TenantContextDataHolder} class.
*/
final class TenantContextDataHolder {
/**
* Stores the current TenantContext local to the running thread.
*/
private static ThreadLocal holderInstance = ThreadLocal
.withInitial(TenantContextDataHolder::new);
/**
* Stores references to the existing TenantContexts when starting tenant flows. These references
* will be popped back, when a tenant flow is ended.
*/
private static ThreadLocal> parentHolderInstanceStack =
ThreadLocal.withInitial(Stack::new);
/**
* Registers ThreadLocal holderInstance in micrometer ContextRegistry.
* ContextRegistry is used for thread local transfer between threads in Project Reactor.
*/
static {
ThreadLocalAccessorRegistryInterceptor.register("holderInstance", holderInstance);
}
/**
* Holder for tenant instance.
*/
private ValueHolder tenant = ValueHolder.empty();
/**
* Holder for data instance.
*/
private ValueHolder
© 2015 - 2025 Weber Informatics LLC | Privacy Policy