public class ModuleFactory
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected static java.util.Map<java.lang.String,java.util.List<Extension>> |
extensionMap |
protected static java.util.Map<java.lang.String,Module> |
loadedModules |
protected static java.util.Map<Module,ModuleClassLoader> |
moduleClassLoaders |
protected static java.util.Map<java.lang.String,Module> |
startedModules |
Constructor and Description |
---|
ModuleFactory() |
Modifier and Type | Method and Description |
---|---|
static java.util.Map<java.lang.String,java.util.List<Extension>> |
getExtensionMap()
Return the current extension map keyed on extension point id
|
static java.util.List<Extension> |
getExtensions(java.lang.String pointId)
Return all of the extensions associated with the given
pointId Returns empty
extension list if no modules extend this pointId |
static java.util.List<Extension> |
getExtensions(java.lang.String pointId,
Extension.MEDIA_TYPE type)
Return all of the extensions associated with the given
pointId Returns
getExtension(pointId) if no modules extend this pointId for given media type |
static java.util.List<GlobalProperty> |
getGlobalProperties()
Get a list of required GlobalProperties defined by the modules
|
static java.util.Collection<Module> |
getLoadedModules()
Returns all modules found/loaded into the system (started and not started)
|
static java.util.List<Module> |
getLoadedModulesCoreFirst()
Returns all modules found/loaded into the system (started and not started), with the core
modules at the start of that list
|
static java.util.Map<java.lang.String,Module> |
getLoadedModulesMap()
Returns all modules found/loaded into the system (started and not started) in the form of a
map
|
static Module |
getModuleById(java.lang.String moduleId) |
static Module |
getModuleByPackage(java.lang.String modulePackage) |
static ModuleClassLoader |
getModuleClassLoader(Module mod)
Get a module's classloader
|
static ModuleClassLoader |
getModuleClassLoader(java.lang.String moduleId)
Get a module's classloader via the module id
|
static java.util.Map<Module,ModuleClassLoader> |
getModuleClassLoaderMap()
Return all current classloaders keyed on module object
|
static java.util.Collection<ModuleClassLoader> |
getModuleClassLoaders()
Returns all module classloaders This method will not return null
|
static java.util.Set<ModuleClassLoader> |
getModuleClassLoadersForPackage(java.lang.String packageName) |
static java.util.Collection<Module> |
getModulesInStartOrder()
Gets a list of modules in the order they are supposed to be started.
|
static java.util.List<Privilege> |
getPrivileges()
Get a list of required Privileges defined by the modules
|
static Module |
getStartedModuleById(java.lang.String moduleId) |
static java.util.Collection<Module> |
getStartedModules()
Returns the modules that have been successfully started
|
static java.util.List<Module> |
getStartedModulesInOrder() |
static java.util.Map<java.lang.String,Module> |
getStartedModulesMap()
Returns the modules that have been successfully started in the form of a map<ModuleId,
Module>
|
static boolean |
isModuleStarted(Module mod)
Checks whether the given module is activated
|
static boolean |
isModuleStarted(java.lang.String moduleId)
Checks whether the given module, identified by its id, is started.
|
static boolean |
isTokenValid(DaemonToken token)
Validates the given token.
|
static void |
loadAdvice(Module module)
Loop over the given module's advice objects and load them into the Context This needs to be
called for all started modules after every restart of the Spring Application Context
|
static Module |
loadModule(java.io.File moduleFile)
Add a module (in the form of a jar file) to the list of openmrs modules Returns null if an
error occurred and/or module was not successfully loaded
|
static Module |
loadModule(java.io.File moduleFile,
java.lang.Boolean replaceIfExists)
Add a module (in the form of a jar file) to the list of openmrs modules Returns null if an
error occurred and/or module was not successfully loaded
|
static Module |
loadModule(Module module,
java.lang.Boolean replaceIfExists)
Add a module to the list of openmrs modules
|
static void |
loadModules()
Load OpenMRS modules from
OpenmrsUtil.getModuleRepository() |
static void |
loadModules(java.util.List<java.io.File> modulesToLoad)
Attempt to load the given files as OpenMRS modules
|
static Module |
startModule(Module module)
Runs through extensionPoints and then calls
BaseModuleActivator.willStart() on the
Module's activator. |
static Module |
startModuleInternal(Module module)
This method should not be called directly.
The startModule(Module) (and hence Daemon.startModule(Module) ) calls this
method in a new Thread and is authenticated as the Daemon userRuns through extensionPoints and then calls BaseModuleActivator.willStart() on the
Module's activator. |
static void |
startModules()
Try to start all of the loaded modules that have the global property moduleId.started
is set to "true" or the property does not exist.
|
static void |
stopModule(Module mod)
Runs through the advice and extension points and removes from api.
|
static void |
stopModule(Module mod,
boolean isShuttingDown)
Runs through the advice and extension points and removes from api.
Also calls mod.Activator.shutdown() |
static java.util.List<Module> |
stopModule(Module mod,
boolean skipOverStartedProperty,
boolean isFailedStartup)
Runs through the advice and extension points and removes from api.
skipOverStartedProperty should only be true when openmrs is stopping modules
because it is shutting down. |
static void |
unloadModule(Module mod)
Removes module from module repository
|
static Module |
updateModule(Module mod)
Update the module: 1) Download the new module 2) Unload the old module 3) Load/start the new
module
|
protected static java.util.Map<java.lang.String,Module> loadedModules
protected static java.util.Map<java.lang.String,Module> startedModules
protected static java.util.Map<java.lang.String,java.util.List<Extension>> extensionMap
protected static java.util.Map<Module,ModuleClassLoader> moduleClassLoaders
public static Module loadModule(java.io.File moduleFile) throws ModuleException
moduleFile
- ModuleException
public static Module loadModule(java.io.File moduleFile, java.lang.Boolean replaceIfExists) throws ModuleException
moduleFile
- replaceIfExists
- unload a module that has the same moduleId if one is loaded alreadyModuleException
public static Module loadModule(Module module, java.lang.Boolean replaceIfExists) throws ModuleException
module
- replaceIfExists
- unload a module that has the same moduleId if one is loaded alreadyModuleException
public static void loadModules()
OpenmrsUtil.getModuleRepository()
public static void loadModules(java.util.List<java.io.File> modulesToLoad)
modulesToLoad
- the list of files to try and loadpublic static void startModules()
public static java.util.List<Module> getLoadedModulesCoreFirst()
List
of the modules loaded into the system, with the core
modules first.public static java.util.Collection<Module> getLoadedModules()
Collection
of the modules loaded into the systempublic static java.util.Map<java.lang.String,Module> getLoadedModulesMap()
public static java.util.Collection<Module> getStartedModules()
Collection
of the started modulespublic static java.util.List<Module> getStartedModulesInOrder()
public static java.util.Map<java.lang.String,Module> getStartedModulesMap()
public static Module getModuleById(java.lang.String moduleId)
moduleId
- public static Module getStartedModuleById(java.lang.String moduleId)
moduleId
- public static Module getModuleByPackage(java.lang.String modulePackage)
modulePackage
- public static Module startModule(Module module) throws ModuleException
BaseModuleActivator.willStart()
on the
Module's activator. This method is run in a new thread and is authenticated as the Daemon
usermodule
- Module to startModuleException
- if the module throws any kind of error at startup or in an activatorstartModuleInternal(Module)
,
Daemon.startModule(Module)
public static Module startModuleInternal(Module module) throws ModuleException
startModule(Module)
(and hence Daemon.startModule(Module)
) calls this
method in a new Thread and is authenticated as the Daemon
userBaseModuleActivator.willStart()
on the
Module's activator.module
- Module to startModuleException
public static java.util.Set<ModuleClassLoader> getModuleClassLoadersForPackage(java.lang.String packageName)
public static void loadAdvice(Module module)
module
- public static void stopModule(Module mod)
mod
- module to stopstopModule(Module, boolean, boolean)
public static void stopModule(Module mod, boolean isShuttingDown)
mod
- the module to stopisShuttingDown
- true if this is called during the process of shutting down openmrsstopModule(Module, boolean, boolean)
public static java.util.List<Module> stopModule(Module mod, boolean skipOverStartedProperty, boolean isFailedStartup) throws ModuleMustStartException
skipOverStartedProperty
should only be true when openmrs is stopping modules
because it is shutting down. When normally stopping a module, use stopModule(Module)
(or leave value as false). This property controls whether the globalproperty is set for
startup/shutdown. Activator.shutdown()
mod
- module to stopskipOverStartedProperty
- true if we don't want to set <moduleid>.started to falseisFailedStartup
- true if this is being called as a cleanup because of a failed module
startupModuleMustStartException
public static void unloadModule(Module mod)
mod
- module to unloadpublic static java.util.List<Extension> getExtensions(java.lang.String pointId)
pointId
Returns empty
extension list if no modules extend this pointIdpointId
- public static java.util.List<Extension> getExtensions(java.lang.String pointId, Extension.MEDIA_TYPE type)
pointId
Returns
getExtension(pointId) if no modules extend this pointId for given media typepointId
- type
- Extension.MEDIA_TYPEpublic static java.util.List<Privilege> getPrivileges()
List
of the required privilegespublic static java.util.List<GlobalProperty> getGlobalProperties()
List
object of the module's global propertiespublic static boolean isModuleStarted(Module mod)
mod
- Module to checkpublic static boolean isModuleStarted(java.lang.String moduleId)
moduleId
- module id. e.g formentry, logicpublic static ModuleClassLoader getModuleClassLoader(Module mod) throws ModuleException
mod
- Module to fetch the class loader forModuleException
- if the module does not have a registered classloaderpublic static ModuleClassLoader getModuleClassLoader(java.lang.String moduleId) throws ModuleException
moduleId
- String
id of the moduleModuleException
- if this module isn't started or doesn't have a classloadergetModuleClassLoader(Module)
public static java.util.Collection<ModuleClassLoader> getModuleClassLoaders()
public static java.util.Map<Module,ModuleClassLoader> getModuleClassLoaderMap()
public static java.util.Map<java.lang.String,java.util.List<Extension>> getExtensionMap()
public static Module updateModule(Module mod) throws ModuleException
mod
- ModuleException
public static boolean isTokenValid(DaemonToken token)
It is thread safe.
token
- public static java.util.Collection<Module> getModulesInStartOrder()
Copyright © 2018 OpenMRS Inc.. All Rights Reserved.