Chapter 7. Howto

Add a new component
  1. Adding an existing component If you want to just use a new compnent, then see the User's Guide. This section talks about implementing a new Jamama component class.

  2. Decide what interface(s) your new component will implement It must implement Configurable. Decide if it will also implement any (or any combination of) the following Configurable subinterfaces.

    • Server

    • ThirdPartyConfiguror

    • Router

    • Repository

  3. Add a new <xsd:complexType> block under the 'instances' element underneath all of the other instances. It is usually easiest to find another <xsd:complexType> under 'instances', copy and paste it and edit the copy.

  4. Validate the schema (if you have a schema validator) Run a schema validator against the .xsd file, or (better) make a Jamama xml config file that would instantiate one of your new objects, sure the schemaLocation points to your modified .xsd file. and validate the XML with an XML validator that validates schemas.

    Put references for goot W3C Schema validators.

    Fix the schema until it validates successfully.

  5. Comple the jaxb source Run ant compile-jaxb Fix the schema until xjc is satisfied with it and can generate all the Java code.

  6. Implement a class that implements the interfaces you decide upon. Work from the API located at JAMAMA_HOME/doc/api. If it's not there, then built it like ant api. You will need to cast the Object argument that you get in your configure() method into the new class that you will find in the API under the com.admc.jamama.dtd package. The methods for that class will show exactly how to set your startup state in configure(). Perform the inverse operations in your getConfig() method and return the same configuration type object (the JVM will cast it down to an Object).

    If there is an suitable adapter available, subclass the adapter and save yourself some work.

  7. Update the Jamama class. Add one element to the private field Jamama.supportedClassArray. The element consists of the JAXB class and the Configurable class that you are adding. The former can be found in the Jaxb API and will be of the form com.admc.jamama.dtd.ConfigType.InstancesType.X.

    If you added your new element underneath the existing instance elements, then I think that the method name of cfg.getInstances().X() should not have changed. Until I sure of this, do check getter java.util.List method in the API for com.admc.cjamama.dtd.cnfigType.InstancesType. (If it has changed, then you willhave to change where that getter method is used in Jamama.java).

  8. Get everything to build and run successfully.