Package com.axelor.db.tenants
Class TenantAware
java.lang.Object
java.lang.Thread
com.axelor.db.tenants.TenantAware
- All Implemented Interfaces:
Runnable
Deprecated.
A Thread implementation that makes a thread tenant-aware by setting the tenant configuration
before executing its task and clearing it afterward.
This class ensures that any operations performed in the thread are associated with the correct
tenant. It uses a tenant resolver (e.g., TenantResolver
) to set and manage the tenant
information during thread execution.
By default, it will run the task inside a new transaction.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
ConstructorsConstructorDescriptionTenantAware
(Runnable task) Deprecated.Constructs a TenantAware using the current tenant. -
Method Summary
Modifier and TypeMethodDescriptionvoid
run()
Deprecated.tenantHost
(String tenantHost) Deprecated.Specify the tenant hostDeprecated.Specify the tenant identifierwithTransaction
(boolean withTransaction) Deprecated.Whether the task should run inside a new transactionMethods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yield
-
Constructor Details
-
TenantAware
Deprecated.Constructs a TenantAware using the current tenant.- Parameters:
task
- the task to execute
-
-
Method Details
-
tenantId
Deprecated.Specify the tenant identifier- Parameters:
tenantId
- the tenant identifier- Returns:
- this
-
tenantHost
Deprecated.Specify the tenant host- Parameters:
tenantHost
- the tenant host- Returns:
- this
-
withTransaction
Deprecated.Whether the task should run inside a new transaction- Parameters:
withTransaction
- false to not open a transaction, else true- Returns:
- this
-
run
public void run()Deprecated.
-
ContextAwareRunnable
orContextAwareCallable
instead