|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.openmrs.module.ModuleFactory
public class ModuleFactory
Methods for loading, starting, stopping, and storing OpenMRS modules
Field Summary | |
---|---|
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 Summary | |
---|---|
ModuleFactory()
|
Method Summary | |
---|---|
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.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.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 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 |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
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
Constructor Detail |
---|
public ModuleFactory()
Method Detail |
---|
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 already
ModuleException
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 already
ModuleException
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.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
user
module
- Module to start
ModuleException
- 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 start
ModuleException
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
startup
ModuleMustStartException
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 pointId
pointId
-
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 type
pointId
- type
- Extension.MEDIA_TYPE
public 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 check
public static ModuleClassLoader getModuleClassLoader(Module mod) throws ModuleException
mod
- Module to fetch the class loader for
ModuleException
- if the module does not have a registered classloaderpublic static ModuleClassLoader getModuleClassLoader(java.lang.String moduleId) throws ModuleException
moduleId
- String
id of the module
ModuleException
- 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
|
OpenMRS-1.7.x | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |