An opencms module can react at various system events. For doing this, the module must provide a so-called Module Action Class that implements the org.opencms.module.I_CmsModuleAction interface (for instance by extending abstract class org.opencms.module.A_CmsModuleAction).
The methods to implement allows the class to react to:
- module initialization (once at application server startup)
- module uninstallation
- module update
- module shutdown (once at application server shut down)
You can specify that Action Class for a module when creating or editing the module by providing a complete java class, like org.opencms.mymodule.MyActionClass.
One of the most common uses of this class derives from the fact that when initialized, the action class gets a CmsObject with full Admin privileges, and that is storing this CmsObject for later use (for instance as an static object of that class).
A further step in this approach is to define static methods into that action class that take advantage of that CmsObject that can for instance create resources, delete them or create users (in general, defining an access point for privileged operations that your module or application need).
Other common uses are:
- registering property files
- registering action listeners that react to publishing, creating, etc
- creation or deletion of files at startup or shutdown
- creation or deletion of database objetcs/data at startup or shutdown
Example Actionclass touch resourceb.html when resourcea.html was published