Module Config File
The module config file gives vital information about the module to OpenMRS. The config file is parsed and this causes appropriate files to be loaded/cached.
The xml doctype for the config file should be defined as:
<!DOCTYPE module PUBLIC "-//OpenMRS//DTD OpenMRS Config 1.0//EN"
"http://resources.openmrs.org/doctype/config-1.2.dtd">
id: Very important. Should be unique for all modules. Serves as the module's identifier
name: Descriptive name used for display purposes
version: Should be in the form of x.x Used for compatibility comparisons
description: Text describing the module. Used for display
require_version: Text giving the minimum version of the core OpenMRS that is required to run this module. (Example: 1.1.0)
As of v1.6, version can specify an upper bound as well: valid values now: "1.2.*", or "1.2.2 - 1.2.3", or "1.2.* - 1.3.*", etc
require_modules: Allows you list modules that this module depends on.
activator: full path to activator. Must implement org.openmrs.module.Activator Contains startup/shutdown code for the module
updateURL: Http URL to the location of the update.rdf file
mandatory: A value of 'true' here means that if this module doesn't start, OpenMRS should not start. Requires config-1.3.dtd and OpenMRS 1.6. See Mandatory Module.
extension
- Must have child elements 'point', and 'class'.
- See extension points
- point: String referring to the unique extension point labeled the same in the code
- class: Full path to the java class that will be called. Must implement org.openmrs.module.Extension
advice
- Must have child elements 'point', and 'class'.
- See Aspect Oriented Programming (AOP)
- point: String referring to one of the interface of one of the services: i.e. org.openmrs.api.PatientService
- class: Full path to the java class that will be called. Must implement org.aopalliance.aop.Advice or org.springframework.aop.Advisor
privilege
- If the privilege doesn't exist in the OpenMRS system when the module is started, the privilege is added
- Must have child elements 'name, and 'description'.
- name: privilege name. Should be unique across OpenMRS
- description: Text describing the privilege. Added as default description.
globalProperty
- If the global property doesn't exist in the OpenMRS system when the module is started, the property is added
- 'property' and 'description' are required. 'defaultValue' is optional
- property: Name of the global property
- defaultValue: Value of the property if it doesn't exist (defaults to the empty string)
- description: Text describing the property.
dwr
- Contains dwr code similar to what would be put in dwr.xml
- Should contain an 'allow' and an optional 'signatures' element.
servlet
- Servlets defined by modules are accessed via /openmrs/moduleServlet/moduleId/servlet-name
- Must contain both 'servlet-name' and 'servlet-class' elements
- See Module Servlets
- servlet-name: name/path used for the servlet
- servlet-class: Full path to the java class implementing javax.servlet.http.HttpServlet
filter
- Filters defined by modules are executed within the context of the ModuleFilter, which is defined in web.xml. This filter executes for every request, and iterates over every filter defined by each module.
- Configuration follows the same conventions as the Servlet specification - each "filter' element must contain both 'filter-name' and 'filter-class' elements, and supports optional "init-param" elements in order to pass any parameters into the 'filter-class' upon initialization.
- filter-name: unique name to identify the filter
- filter-class: Full path to the java class implementing javax.servlet.Filter
- init-param:
- param-name: name of the parameter to pass into the filter
- param-value: value of the parameter to pass into the filter
filter-mapping
- Filter mappings defined by modules are used to determine which Filters should execute for which requests. Configuration of these also follows directly from the Servlet specification.
- filter-name: unique name as defined by a filter element for which this mapping applies
- One of the following url-pattern or servlet-name elements must then be included:
- url-pattern: Tries to match the URL pattern specified here against the request URI to determine if this filter should be run for each request. Examples are:
- */ or * - Matches every request
- *.js - Matches every request for a file with a .js extension
- /foo/* - Matches every request whose URI starts with /foo/
- servlet-name - Tries to match a servlet that matches the specified servlet-name
- url-pattern: Tries to match the URL pattern specified here against the request URI to determine if this filter should be run for each request. Examples are:
messages
- lang: two letter language for the locale
- file: name of the file (i.e. messages.properties or messages_*.properties)
The elements id, name, version, package, author, description, and activator are all required. The remaining elements are optional.
