This section describes some additional conventions to enable improved reusability of MDF processing modules.
A simple MDF module is defined as a module which receives a metadata set from an upstream module, performs some internal processing which MAY modify the received metadata set and that then passes that metadata set on to its downstream module. This is anticipated to be the most common form of module and so worthy of support in all implementations of MDF. The simple module interface should add the following functions to the basic module interface:
public boolean initialise(Hashtable metadata);
public void process(Hashtable metadata);
public void notify(hashtable metadata);
The initialise() function is provided as an overrideable function within which classes derived from the simple module may specify their own initialisation code. The derived classes do not need to be responsible for passing the metadata set on to the downstream module.
The process() function is provided as an overrideable function within which classes derived from the simple module may specify their own processing code. The derived classes do not need to be responsible for passing the metadata set on to the downstream module.
The notify() function provides an interface for the processing code of derived classes to pass any additional, generated metadata sets on to the downstream module. This allows classes derived from the simple module to generate multiple metadata sets for the downstream module without needing to be aware of the mechanism by which the module chaining has been implemented.
The implementation of the simple module should provide default implementations of the init(), rcv(), chain(), initialise(), process(), and notify() functions as described below:
The chain() function should record the module passed in as a parameter as this module's downstream module. If the module already has a downstream module, then it should be replaced by this new value. The module should be recorded in such a way that its init() and rcv() functions may be invoked.
The init() function should pass the received metadata set to the initialise() function of this module and then invoke the init() function of the downstream module with the metadata set. The metadata set should be passed to the initialise() function by reference, so that modifications made to the metadata set are reflected in the metadata set passed to the downstream module's init() function.
The rcv() function should pass the received metadata set to the process() function of this module and should then invoke the rcv() function of the downstream module with the metadata set. The metadata set should be passed to the initialise() function by reference, so that modifications made to the metadata set are reflected in the metadata set passed to the downstream module's rcv() function.
The initialise() function should be implemented as a null-op.
The process() function should be implemented as a null-op
The notify() function should pass the metadata set received as a parameter to the rcv() function of the downstream module.
Some metadata properties may be assigned multiple values. For example a list of keywords for a document. While MDF does not restrict a module from defining a single property with a value which is a collection, it may also be desirable to be able to serialise the multiple values as a set of property/value pairs in a metadata set. By convention such multiple property/value pairs should have a property string of the form propertyName_N where propertyName is a string key for the property and N is an integer value beginning with 0 for the first member of the collection and incrementing by one for each collection member serialised.
For example the property/value pair:
KEYWORDS: {mdf, modules, metadata} (where {} denotes an implementation specific collection)
can be serialised as:
KEYWORD_0: mdf
KEYWORD_1: modules
KEYWORD_2: metadata
By convention, if a non-fatal error is encountered during initialisation or running of a module, the module should add an error message to the metadata set being processed. The conventional key for this error message is the fully qualified name of the MDF module (in Java, the class name is used) with the string ".ERROR" appended. The value of this entry should be a string detailing the error which occurred.
The Java implementation provides this functionality in the class com.techquila.mdf.framework.BasicMDFModuleAdapter. A class derived from this class may register and error message by passing the metadata set to be modified and the message to be added to the function setError().
| Up: MDF Technical Specification | |
| Previous: MDF Modules | Next: MDF Modules in the Java Implementation |