Class TenantAware

java.lang.Object
java.lang.Thread
com.axelor.db.tenants.TenantAware
All Implemented Interfaces:
Runnable

@Deprecated public class TenantAware extends Thread
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.

  • Constructor Details

    • TenantAware

      public TenantAware(Runnable task)
      Deprecated.
      Constructs a TenantAware using the current tenant.
      Parameters:
      task - the task to execute
  • Method Details

    • tenantId

      public TenantAware tenantId(String tenantId)
      Deprecated.
      Specify the tenant identifier
      Parameters:
      tenantId - the tenant identifier
      Returns:
      this
    • tenantHost

      public TenantAware tenantHost(String tenantHost)
      Deprecated.
      Specify the tenant host
      Parameters:
      tenantHost - the tenant host
      Returns:
      this
    • withTransaction

      public TenantAware withTransaction(boolean 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.
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Thread