An MDF module is responsible for processing a series of metadata sets passed to it either by the application or by its upstream module. In addition to providing an interface for receiving a metadata set, a module also provides an interface for receiving initialisation information and for connecting the module to a downstream module.
In Java, the interface for an MDF module looks like this:
public interface MDFModule {
public boolean init(Hashtable metadata);
public void rcv(Hashtable metadata);
public void chain(MDFModule module);
}
NOTE: This specification gives interface specifications using Java. However, an MDF framework may be implemented in any language that provides support for key-based lookup. Similarly, this specification uses a Java Hashtable (java.util.Hashtable) for the property/value map - obviously implementations in other languages should use whatever construct is available for providing a key-based lookup table.
The init() function is invoked either by the application (for the module at the start of the processing chain) or by the upstream module (for all other modules in the processing chain) at the start of each metadata processing session. The module may examine the received metadata set to see if any property/value pairs provide configuration information for the module and use the values found to initialise itself prior to receiving the first metadata set for processing. If a fatal error is encountered by a module while it is initialising (for example if some required resource is not available), then the module should return FALSE from the init() function without invoking any downstream modules. In all other cases, after initialising itself, the module MUST call the init() function of its downstream module and return the value returned from the downstream modules init() function. A module SHOULD NOT modify the metadata set received for initialisation purposes. It is recognised that in some (rare) cases, the initialisation status of one module may influence the initialisation process of some other modules in the chain and so while it is allowed for a module to modify a metadata set during the initialisation processing, it is recommended that this be done only with extreme caution. Only after all modules in the chain have processed the metadata set provided for initialisation should the application begin passing metadata sets for processing.
The rcv() function is invoked by the upstream module (or the application if the module has no upstream module) once for each metadata set. A module MAY perform any processing in response to this module that it likes. A module MAY modify the received metadata set in any way. A module MAY generate one or more additional metadata sets and pass those to the rcv() function of the downstream module. A module MAY refuse to pass the received metadata set on to the downstream module (effectively terminating all processing of that metadata set).
The chain() function is invoked by the application to notify a module of its downstream module. The module must record this downstream module's interface address for the purpose of invoking init() and rcv() functions on the downstream module. A module MAY support multiple downstream modules, however the semantics of doing so are not constrained by this specification. However, if a module only supports a single downstream module, the module passed to the chain() function MUST replace the existing downstream module if there is one.
| Up: MDF Technical Specification | |
| Previous: Definitions | Next: MDF Module Conventions |