public class ModuleFactory extends Object
Modifier and Type | Field and Description |
---|---|
protected static Map<String,List<Extension>> |
extensionMap |
protected static Map<String,Module> |
loadedModules |
protected static Map<Module,ModuleClassLoader> |
moduleClassLoaders |
protected static Map<String,Module> |
startedModules |
Constructor and Description |
---|
ModuleFactory() |
Modifier and Type | Method and Description |
---|---|
static Map<String,List<Extension>> |
getExtensionMap()
Return the current extension map keyed on extension point id
|
static List<Extension> |
getExtensions(String pointId)
Return all of the extensions associated with the given
pointId Returns empty
extension list if no modules extend this pointId |
static List<Extension> |
getExtensions(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 List<GlobalProperty> |
getGlobalProperties()
Get a list of required GlobalProperties defined by the modules
|
static Collection<Module> |
getLoadedModules()
Returns all modules found/loaded into the system (started and not started)
|
static 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 Map<String,Module> |
getLoadedModulesMap()
Returns all modules found/loaded into the system (started and not started) in the form of a
map
|
static Module |
getModuleById(String moduleId) |
static Module |
getModuleByPackage(String modulePackage) |
static ModuleClassLoader |
getModuleClassLoader(Module mod)
Get a module's classloader
|
static ModuleClassLoader |
getModuleClassLoader(String moduleId)
Get a module's classloader via the module id
|
static Map<Module,ModuleClassLoader> |
getModuleClassLoaderMap()
Return all current classloaders keyed on module object
|
static Collection<ModuleClassLoader> |
getModuleClassLoaders()
Returns all module classloaders This method will not return null
|
static List<Privilege> |
getPrivileges()
Get a list of required Privileges defined by the modules
|
static Module |
getStartedModuleById(String moduleId) |
static Collection<Module> |
getStartedModules()
Returns the modules that have been successfully started
|
static Map<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 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(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(File moduleFile,
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,
Boolean replaceIfExists)
Add a module to the list of openmrs modules
|
static void |
loadModules()
Load OpenMRS modules from
OpenmrsUtil.getModuleRepository() |
static void |
loadModules(List<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 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 Map<Module,ModuleClassLoader> moduleClassLoaders
public static Module loadModule(File moduleFile) throws ModuleException
moduleFile
- ModuleException
public static Module loadModule(File moduleFile, 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, 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(List<File> modulesToLoad)
modulesToLoad
- the list of files to try and loadpublic static void startModules()
public static List<Module> getLoadedModulesCoreFirst()
List
of the modules loaded into the system, with the core
modules first.public static Collection<Module> getLoadedModules()
Collection
of the modules loaded into the systempublic static Map<String,Module> getLoadedModulesMap()
public static Collection<Module> getStartedModules()
Collection
of the started modulespublic static Map<String,Module> getStartedModulesMap()
public static Module getModuleById(String moduleId)
moduleId
- public static Module getStartedModuleById(String moduleId)
moduleId
- public static Module getModuleByPackage(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 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 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 List<Extension> getExtensions(String pointId)
pointId
Returns empty
extension list if no modules extend this pointIdpointId
- public static List<Extension> getExtensions(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 List<Privilege> getPrivileges()
List
of the required privilegespublic static List<GlobalProperty> getGlobalProperties()
List
object of the module's global propertiespublic static boolean isModuleStarted(Module mod)
mod
- Module to checkpublic 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(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 Collection<ModuleClassLoader> getModuleClassLoaders()
public static Map<Module,ModuleClassLoader> getModuleClassLoaderMap()
public static Map<String,List<Extension>> getExtensionMap()
public static Module updateModule(Module mod) throws ModuleException
mod
- ModuleException
Copyright © 2018 OpenMRS LLC.. All Rights Reserved.