Class XmlLoader

java.lang.Object
net.sf.basedb.util.extensions.xml.XmlLoader

public class XmlLoader extends Object
Loads extension points and extensions from extension definition XML files. This class may load extensions from more than one file and register or unregister all loaded extensions and extension points with a registry.

For a description of the XML file format this class can load see the BASE manual.

Factory initialisation
This loader uses reflection to create and initialise factory instances. The XML file contains the class name of the factory to create. This class must declare a public no-argument constructor and must also implement one of the specific factory interfaces (for example ActionFactory or RendererFactory). If the tag <parameters> is present inside the factory declaration, the loader will use reflection to find a setter method for each sub-tag inside the <parameters> tag. Here is an example:

// XML contents
<parameters>
   <image>button.png</image>
   <title>Click button</title>
</parameters>

// Factory initialization
factory.setImage("button.png");
factory.setTitle("Click button");
The setter methods must be public and accept a single String parameter.

The loader also looks for the setParameter(String, String) method signature. If the method exists it will be called for each parameter found with the tagname as the first parameter and the value as the second parameter. Continuing the above example:

factory.setParameter("image", "button.png");
factory.setParameter("title", "Click button");

Tags that doesn't have a corresponding setter method are simply ignored. The XML file format allows any tags as parameters, but only the first level will be parsed.

The parameter values may be subject to conversion by one or more ValueConverter:s. Converters are added to the loader by addValueConverter(ValueConverter) and are usually implemented to react on method annotations. For example, the web client uses this for path and variable substitution.

Version:
2.7
Author:
nicklas
Last modified
$Date:2008-03-20 12:15:25 +0100 (Thu, 20 Mar 2008) $