Action classes

(Difference between revisions)
Jump to: navigation, search
(extension of original article)
Line 1: Line 1:
An opencms module can react at various system events. For doing this, the module must provide a so-called ''Module Action Class'' that is derived from the abstract class [http://www.opencms.org/export/javadoc/core/org/opencms/module/A_CmsModuleAction.html org.opencms.module.A_CmsModuleAction].
+
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 [http://www.opencms.org/export/javadoc/core/org/opencms/module/I_CmsModuleAction.html org.opencms.module.I_CmsModuleAction] interface (for instance by extending abstract class [http://www.opencms.org/export/javadoc/core/org/opencms/module/A_CmsModuleAction.html 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
 +
*publishing
 +
*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
 +
 
 
[[Category:Extending OpenCms]]
 
[[Category:Extending OpenCms]]

Revision as of 18:26, 6 May 2009

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
  • publishing
  • 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
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox