Class DistributedFactory

java.lang.Object
com.axelor.cache.DistributedFactory

public class DistributedFactory extends Object
  • Method Details

    • getLock

      public static Lock getLock(String name)
      Returns general-purpose distributed-aware lock.
      Parameters:
      name - name of the lock
      Returns:
      distributed-aware reentrant lock
    • getLockIfDistributed

      public static Lock getLockIfDistributed(String name)
      Returns a lock that locks only when the cache is distributed.

      This is useful when no locking is needed in single-instance setup.

      Parameters:
      name - name of the lock
      Returns:
      distributed reentrant lock or no-op lock if cache is not distributed
    • getAtomicLong

      public static DistributedAtomicLong getAtomicLong(String name)
      Returns distributed-aware atomic long.
      Parameters:
      name -
      Returns:
      distributed-aware atomic long
    • getTopic

      public static AxelorTopic getTopic(String name)
      Returns a distributed publish/subscribe topic.

      The caller class is used together with the specified name as topic name.

      This is not scoped by tenant. Instead, publishers send current tenant identifier which is applied before calling listeners.

      Parameters:
      name - name of the topic
      Returns:
      distributed topic, or a local in-process topic if the cache is not distributed