public class Daemon
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
protected static class |
Daemon.DaemonThread
Thread class used by the
startModule(Module) and
executeScheduledTask(Task) methods so that the returned object and the
exception thrown can be returned to calling class |
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
DAEMON_USER_UUID
The uuid defined for the daemon user object
|
protected static java.lang.ThreadLocal<User> |
daemonThreadUser |
protected static java.lang.ThreadLocal<java.lang.Boolean> |
isDaemonThread |
Constructor and Description |
---|
Daemon() |
Modifier and Type | Method and Description |
---|---|
static void |
executeScheduledTask(Task task)
Executes the given task in a new thread that is authenticated as the daemon user.
|
static User |
getDaemonThreadUser() |
static boolean |
isDaemonThread() |
static java.lang.Thread |
runInDaemonThread(java.lang.Runnable runnable,
DaemonToken token)
Executes the given runnable in a new thread that is authenticated as the daemon user.
|
static void |
runInDaemonThreadAndWait(java.lang.Runnable runnable,
DaemonToken token)
Executes the given runnable in a new thread that is authenticated as the daemon user and wait
for the thread to finish.
|
static java.lang.Thread |
runInNewDaemonThread(java.lang.Runnable runnable)
Call this method if you are inside a Daemon thread (for example in a Module activator or a
scheduled task) and you want to start up a new parallel Daemon thread.
|
static void |
runStartupForService(OpenmrsService service)
Calls the
OpenmrsService.onStartup() method, as a daemon, for an instance
implementing the OpenmrsService interface. |
static Module |
startModule(Module module)
This method should not be called directly.
|
protected static final java.lang.String DAEMON_USER_UUID
protected static final java.lang.ThreadLocal<java.lang.Boolean> isDaemonThread
protected static final java.lang.ThreadLocal<User> daemonThreadUser
public static Module startModule(Module module) throws ModuleException
ModuleFactory.startModule(Module)
method uses this to start the given module in a new thread that is authenticated as the
daemon usermodule
- the module to startModuleException
public static void executeScheduledTask(Task task) throws java.lang.Throwable
TimerSchedulerTask
during actual task executiontask
- the task to runjava.lang.Throwable
public static java.lang.Thread runInNewDaemonThread(java.lang.Runnable runnable)
runnable
- what to run in a new threadThread
public static boolean isDaemonThread()
Context.hasPrivilege(String)
public static User getDaemonThreadUser()
public static void runStartupForService(OpenmrsService service) throws ModuleException
OpenmrsService.onStartup()
method, as a daemon, for an instance
implementing the OpenmrsService
interface.openmrsService
- instance implementing the OpenmrsService
interface.ModuleException
public static java.lang.Thread runInDaemonThread(java.lang.Runnable runnable, DaemonToken token)
runnable
- an object implementing the Runnable
interface.token
- the token required to run code as the daemon userThread
public static void runInDaemonThreadAndWait(java.lang.Runnable runnable, DaemonToken token)
runnable
- an object implementing the Runnable
interface.token
- the token required to run code as the daemon userCopyright © 2018 OpenMRS Inc.. All Rights Reserved.