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 ContextAwareRunnable
Creates a new instance ofContextAwareRunnable
for the givenRunnable
task.static ContextAwareRunnable
Creates a new instance ofContextAwareRunnable
for the givenRunnable
task.void
run()
Executes a task within a specific context state.
-
Method Details
-
of
Creates a new instance ofContextAwareRunnable
for the givenRunnable
task.- Parameters:
task
- theRunnable
task to be executed within a context-aware environment- Returns:
- a
ContextAwareRunnable
instance wrapping the provided task
-
of
Creates a new instance ofContextAwareRunnable
for the givenRunnable
task.- Parameters:
task
- theRunnable
task to be executed within a context-aware environmentwithTransaction
- whether the task should be executed within a transactional scope- Returns:
- a
ContextAwareRunnable
instance 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.
-