For an incoming request, the module servlet selects its associated module to be the current module for this request and delegates action processing to it. The module selects an action, executes it and dispatches according to the action's result.

The term module is used as a synonym for module controller.

Module Context

Here are some details of the module context implementation used by the Calyxo Control component:

  • getName() - answers the module's servlet name.
  • getInitParameter(String name) - answers the module's servlet configuration init parameter for the given name.
  • getPath(String action) - answers a context-relative path for the specified action path, according to the module's servlet mapping. The action may have a query and/or anchor appended.
  • getClassLoader() - answers the module class loader that has been set either as a constructor parameter or via the setClassLoader method. If no class loader has been set, answers getClass().getClassLoader().
  • Module scope is simulated by maintaining a hash map.

Module Initialization

A module servlet creates its module when it gets initialized by the servlet container. The module then starts to initialize itself in several steps:

  1. Create and install the module's i18n support - The i18n support class may be given by module init parameter i18n-support. If it is omitted, de.odysseus.calyxo.control.impl.DefaultI18nSupport is taken as default, which uses Java's resource bundle mechanism.
  2. Create and install the module's message support - The message support class may be given by module init parameter message-support. If it is omitted, de.odysseus.calyxo.control.impl.DefaultMessageSupport is taken as default, which saves messages into session scope.
  3. Create and install the calyxo.base and calyxo.control accessors.
  4. Parse the control configuration file - the context-relative path to the configuration file is taken from module init parameter config. The parse results in a tree of objects corresponding to the configuration elements.
  5. Load plugins - Instantiate and initialize Plugin objects.
  6. Create and initialize actions - Instantiate and initialize Action and Filter objects and combine them into a command chain.
  7. Create and initialize exception handlers - Instantiate and initialize ExceptionHandler objects.

Once initialized, the module is ready for action processing.

Action Processing

For some module-relative path, action processing involves the following steps:

  1. Lookup the action for the requested path. If there's no action for that path, try path "/*". If there's neither action, throw an exception.
  2. Invoke the action by executing its command chain.
  3. If the action throws an exception, search for an exception handler and - if one could be found - invoke it; otherwise, throw the exception again.
  4. If the action returned a dispatch configuration, select a dispatcher and invoke it.