A module activator provides means for module developers to register their modules with the core API so that they get notified during application startup, shutdown and when the spring applicationContext gets refreshed. This is useful for things like caching of some module specific resources at application startup or cleanup of special resources before the application shuts down.

A module Activator class MUST implement the interface 'org.openmrs.module.ModuleActivator'. There is an abstract class 'org.openmrs.module.BaseModuleActivator' that is optionally available as a default implementation and "buffer" against changes. We recommend extending the abstract class in your module for "forward compatibility" sake. These are available in version 1.7.0 and later.

If you need your module to support earlier versions up to 1.6.x, your activator class should implement the deprecated 'org.openmrs.module.Activator' which has only 2 methods. ModuleActivator gives more control to the developer with its 6 methods and so is preferred over the older and simpler Activator interface.

Below is the break down of the methods that are provided by the new ModuleActivator interface and abstract class. Please see the Basic Module for a code example of how to register and write module activators for your modules.

Methods in 'org.openmrs.module.ModuleActivator'

(Available with version 1.7.x and later)

Methods available in older 'org.openmrs.module.Activator'

(Deprecated and available with version 1.6.x or earlier)