Package com.axelor.concurrent
Class ContextAwareRunnable
java.lang.Object
com.axelor.concurrent.ContextAwareRunnable
- All Implemented Interfaces:
Runnable
A wrapper around a
Runnable 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 Summary
Modifier and TypeMethodDescriptionstatic ContextAwareRunnableCreates a new instance ofContextAwareRunnablefor the givenRunnabletask.static ContextAwareRunnableCreates a new instance ofContextAwareRunnablefor the givenRunnabletask.voidrun()Executes a task within a specific context state.
-
Method Details
-
of
Creates a new instance ofContextAwareRunnablefor the givenRunnabletask.- Parameters:
task- theRunnabletask to be executed within a context-aware environment- Returns:
- a
ContextAwareRunnableinstance wrapping the provided task
-
of
Creates a new instance ofContextAwareRunnablefor the givenRunnabletask.- Parameters:
task- theRunnabletask to be executed within a context-aware environmentwithTransaction- whether the task should be executed within a transactional scope- Returns:
- a
ContextAwareRunnableinstance wrapping the provided task
-
run
public void run()Executes a task within a specific context state. The method ensures that the provided context is applied during the task execution and restores the previous context upon completion. Optionally, the task can be executed within a transactional scope if enabled.
-