|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.openmrs.module.ModuleUtil
public class ModuleUtil
Utility methods for working and manipulating modules
Constructor Summary | |
---|---|
ModuleUtil()
|
Method Summary | |
---|---|
static java.lang.Boolean |
allowAdmin()
|
static java.lang.Boolean |
checkForModuleUpdates()
Iterates over the modules and checks each update.rdf file for an update |
protected static void |
checkMandatoryModulesStarted()
Looks at the |
protected static void |
checkOpenmrsCoreModulesStarted()
Looks at the list of modules in ModuleConstants.CORE_MODULES to make sure that all
modules that are core to OpenMRS are started and have at least a minimum version that OpenMRS
needs. |
static void |
checkRequiredVersion(java.lang.String version,
java.lang.String value)
This method is an enhancement of compareVersion(String, String) and adds support for
wildcard characters and upperbounds. |
static int |
compareVersion(java.lang.String version,
java.lang.String value)
Compares version to value version and value are strings like
w.x.y.z Returns 0 if either version or value is null. |
static void |
expandJar(java.io.File fileToExpand,
java.io.File tmpModuleDir,
java.lang.String name,
boolean keepFullPath)
Expand the given fileToExpand jar to the tmpModuleFile |
static java.net.URL |
file2url(java.io.File file)
Utility method to convert a File object to a local URL. |
static java.util.List<java.lang.String> |
getMandatoryModules()
Returns all modules that are marked as mandatory. |
static Module |
getModuleForPath(java.lang.String path)
Gets the module that should handle a path. |
static java.io.File |
getModuleRepository()
Gets the folder where modules are stored. |
static java.util.Collection<java.lang.String> |
getPackagesFromFile(java.io.File file)
This loops over all FILES in this jar to get the package names. |
static java.lang.String |
getPathForResource(Module module,
java.lang.String path)
Takes a global path and returns the local path within the specified module. |
static java.lang.String |
getURL(java.net.URL url)
Downloads the contents of a URL and copies them to a string (Borrowed from oreilly) |
static java.io.InputStream |
getURLStream(java.net.URL url)
Downloads the contents of a URL and copies them to a string (Borrowed from oreilly) |
static boolean |
ignoreCoreModules()
Uses the runtime properties to determine if the core modules should be enforced or not. |
static java.io.File |
insertModuleFile(java.io.InputStream inputStream,
java.lang.String filename)
Add the inputStream as a file in the modules repository |
static boolean |
matchRequiredVersions(java.lang.String version,
java.lang.String value)
This method is an enhancement of compareVersion(String, String) and adds support for
wildcard characters and upperbounds. |
protected static java.io.InputStream |
openConnectionCheckRedirects(java.net.URLConnection c)
Convenience method to follow http to https redirects. |
static org.springframework.context.support.AbstractRefreshableApplicationContext |
refreshApplicationContext(org.springframework.context.support.AbstractRefreshableApplicationContext ctx)
|
static org.springframework.context.support.AbstractRefreshableApplicationContext |
refreshApplicationContext(org.springframework.context.support.AbstractRefreshableApplicationContext ctx,
boolean isOpenmrsStartup,
Module startedModule)
Refreshes the given application context "properly" in OpenMRS. |
static void |
shutdown()
Stops the module system by calling stopModule for all modules that are currently started |
static void |
startup(java.util.Properties props)
Start up the module system with the given properties. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ModuleUtil()
Method Detail |
---|
public static void startup(java.util.Properties props) throws ModuleMustStartException, OpenmrsCoreModuleException
props
- Properties (OpenMRS runtime properties)
ModuleMustStartException
OpenmrsCoreModuleException
public static void shutdown()
public static java.io.File insertModuleFile(java.io.InputStream inputStream, java.lang.String filename)
inputStream
as a file in the modules repository
inputStream
- InputStream
to load
public static boolean matchRequiredVersions(java.lang.String version, java.lang.String value)
compareVersion(String, String)
and adds support for
wildcard characters and upperbounds. checkRequiredVersion(String, String)
internally.
version
- openmrs version number to be comparedvalue
- value in the config file for required openmrs version
version
is within the value
public static void checkRequiredVersion(java.lang.String version, java.lang.String value) throws ModuleException
compareVersion(String, String)
and adds support for
wildcard characters and upperbounds.
version
- openmrs version number to be comparedvalue
- value in the config file for required openmrs version
ModuleException
- if the version
is not within the value
public static int compareVersion(java.lang.String version, java.lang.String value)
version
to value
version and value are strings like
w.x.y.z Returns 0
if either version
or value
is null.
version
- String like w.x.y.zvalue
- String like w.x.y.z
0
if version
is equal to the argument
value
; a value less than 0
if version
is
numerically less than the argument value
; and a value greater than
0
if version
is numerically greater than the argument
value
public static java.io.File getModuleRepository()
public static java.net.URL file2url(java.io.File file) throws java.net.MalformedURLException
File
object to a local URL.
file
- a file object
java.net.MalformedURLException
- if file can't be represented as URL for some reasonpublic static void expandJar(java.io.File fileToExpand, java.io.File tmpModuleDir, java.lang.String name, boolean keepFullPath) throws java.io.IOException
fileToExpand
jar to the tmpModuleFile directory
If name
is null, the entire jar is expanded. Ifname
is not null,
then only that path/file is expanded.
- Parameters:
fileToExpand
- file pointing at a .jartmpModuleDir
- directory in which to place the filesname
- filename inside of the jar to look for and expandkeepFullPath
- if true, will recreate entire directory structure in tmpModuleDir
relating to name
. if false will start directory structure at
name
- Throws:
java.io.IOException
public static java.io.InputStream getURLStream(java.net.URL url)
url
-
protected static java.io.InputStream openConnectionCheckRedirects(java.net.URLConnection c) throws java.io.IOException
c
- the URLConnection
to open
InputStream
that is not necessarily at the same url, possibly at a 403 redirect.
java.io.IOException
#getURLStream(URL)}
public static java.lang.String getURL(java.net.URL url)
url
-
public static java.lang.Boolean checkForModuleUpdates() throws ModuleException
ModuleException
public static java.lang.Boolean allowAdmin()
public static org.springframework.context.support.AbstractRefreshableApplicationContext refreshApplicationContext(org.springframework.context.support.AbstractRefreshableApplicationContext ctx)
ModuleUtil#refreshApplicationContext(AbstractRefreshableApplicationContext, Module)
public static org.springframework.context.support.AbstractRefreshableApplicationContext refreshApplicationContext(org.springframework.context.support.AbstractRefreshableApplicationContext ctx, boolean isOpenmrsStartup, Module startedModule)
ctx
- Spring application context that needs refreshing.isOpenmrsStartup
- if this refresh is being done at application startup.startedModule
- the module that was just started and waiting on the context refresh.
protected static void checkMandatoryModulesStarted() throws ModuleException
ModuleException
- if a mandatory module isn't startedprotected static void checkOpenmrsCoreModulesStarted() throws OpenmrsCoreModuleException
ModuleConstants.CORE_MODULES
to make sure that all
modules that are core to OpenMRS are started and have at least a minimum version that OpenMRS
needs.
ModuleException
- if a module that is core to OpenMRS is not started
OpenmrsCoreModuleException
public static boolean ignoreCoreModules()
public static java.util.List<java.lang.String> getMandatoryModules()
public static java.util.Collection<java.lang.String> getPackagesFromFile(java.io.File file)
file
- jar file to look into
public static Module getModuleForPath(java.lang.String path)
Gets the module that should handle a path. The path you pass in should be a module id (in path format, i.e. /ui/springmvc, not ui.springmvc) followed by a resource. Something like the following: /ui/springmvc/css/ui.css The first running module out of the following would be returned: ui.springmvc.css ui.springmvc ui
path
-
public static java.lang.String getPathForResource(Module module, java.lang.String path)
module
- path
-
|
OpenMRS-1.7.x | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |