22 lines
556 B
Java
22 lines
556 B
Java
package com.label.common.context;
|
|
|
|
public class CompanyContext {
|
|
private static final ThreadLocal<Long> COMPANY_ID = new ThreadLocal<>();
|
|
|
|
public static void set(Long companyId) {
|
|
COMPANY_ID.set(companyId);
|
|
}
|
|
|
|
public static Long get() {
|
|
return COMPANY_ID.get();
|
|
}
|
|
|
|
public static void clear() {
|
|
COMPANY_ID.remove(); // Use remove() not set(null) to prevent memory leaks
|
|
}
|
|
|
|
private CompanyContext() { // Prevent instantiation
|
|
throw new UnsupportedOperationException("Utility class");
|
|
}
|
|
}
|