Class ContextAwareCallable<V>

java.lang.Object
com.axelor.concurrent.ContextAwareCallable<V>
Type Parameters:
V - the result type of the enclosed Callable
All Implemented Interfaces:
Callable<V>

public final class ContextAwareCallable<V> extends Object implements Callable<V>
A wrapper around a Callable that enables execution within a context-aware environment. This propagates contextual information such as tenant and user details, as well as the base URL and language preferences, to the execution thread of the task.
  • Method Details

    • of

      public static <V> ContextAwareCallable<V> of(Callable<V> task)
      Creates a ContextAwareCallable instance from the given Callable task. The returned ContextAwareCallable enables execution of the task in a context-aware environment.
      Type Parameters:
      V - the result type of the enclosed Callable
      Parameters:
      task - the Callable to be wrapped into a ContextAwareCallable
      Returns:
      a new ContextAwareCallable instance encapsulating the provided task
    • of

      public static <V> ContextAwareCallable<V> of(Callable<V> task, boolean withTransaction)
      Creates a ContextAwareCallable instance from the given Callable task. The returned ContextAwareCallable enables execution of the task in a context-aware environment.
      Type Parameters:
      V - the result type of the enclosed Callable
      Parameters:
      task - the Callable to be wrapped into a ContextAwareCallable
      withTransaction - whether the task should be executed within a transactional scope
      Returns:
      a new ContextAwareCallable instance encapsulating the provided task
    • call

      public V call() throws Exception
      Specified by:
      call in interface Callable<V>
      Throws:
      Exception