Module Types

The OpenHierarchy framework handles three different types of modules; foreground modules, background modules and filter modules. Each module type serves a different purpose but are all managed by the framework which controls module life cycle and module invocation.

The image above shows how the view is combined with output from diffrent module types.

 

Foreground modules are used to generate the main content of a view and have full access to both the HttpServletRequest and the HttpServletResponse objects which enables them to send redirects and write directly to the response output stream. The latter can be used for bypassing the framework core if necessary. The framework will only invoke a single foreground module per request.

Background modules are like a simplified form of Portlets which add content to the view but only have access to the HttpServletRequest object and thus cannot send redirects or write directly to the response output stream. Unlike foreground modules, multiple background modules can be invoked by the framework for a single request.

Filter modules are an almost exact counterpart of the standard javax.servlet.Filter class but with the ability to be managed at runtime instead of via the web.xml file, and also with better access to the OpenHierarchy framework.

Lifecycle

All module types share the following life cycle:

The init() method is called when the module is instantiated and if it executes successfully without throwing exceptions, the module is added to the module cache and thereby made available to incoming requests.

A started module can at any time have it's update() method called which signals that the settings of the module has been updated.

The unload() is called when the module is removed from the module cache and is no longer available to incoming requests. The module should free up all it's resources at this point.

Foreground Modules

Foreground modules are usually the module type handling most of the business logic and the generated views. They are very flexible and have few limitations to how the request and response can be handled. A foreground module can be compared to a normal Servlet but with certain extensions for added functionality and error handling.

Each foreground module has an alias which in combination with the context path and the alias of the previous sections in the hierarchy forms the URL of the module.

Background Modules

Background modules are as the name implies usually used to handle background tasks and generate content to be showed in the "background" of the generated view. Unlike foreground modules, which have an unique URL based on their alias, background modules can have multiple aliases containing wildcards and regular expressions but are not invoked directly. Instead, background modules are invoked upon requests made to foreground modules.

Filter Modules

Filter modules are used the same way as ordinary javax.servlet.Filter implementations and use the same type of filter chain style invocation. Like background modules the filter modules can have multiple aliases containing wildcards and regular expressions.

Latest release

 

Latest blog posts

Latest forum posts