Wednesday, March 19, 2008

Converting Settings for use with ProjectBuilder

I recently posted the procedure for converting modules to ProjectBuilder. This handles any Deployment and Package sub-types you may have in your Workbench project, but there is still the question of what to do about project specific Setting sub-types (Nodes are handled implicitly by depot-setup, of course).

As it turns out, there's no method of automatically converting Setting sub-types, just a set of rules and conventions we follow to manually add settings definitions to existing type.xml files:
  • By convention settings type definitions are added to the type.xml of the module that most logically "owns" them (i.e. usually the module that uses them).
  • Also by convention, we group related sets of settings as sub-types of an abstract "container" type (though this is certainly not required), so the first type to add might be something like:
    <type role="abstract" uniqueInstances="true" name="JBossSetting" order="Setting">
    <description>A JBoss Setting</description>

    <supertype>

    <typereference name="Setting"/>

    </supertype>

    <constraints>

    <dependency-constraint enforced="false" kind="parent">

    <allowedtypes>

    <typereference name="JBossServer"/>

    </allowedtypes>

    </dependency-constraint>

    </constraints>

    </type>

  • Note that the only type attributes allowed for settings are "settingType", "settingValueEncrypted", "settingValue", and "referrers". This dictates what you can include in the attributes and constraints section of the type definition.
  • Next, add each setting type to the type.xml. e.g:
    <type role="concrete" uniqueInstances="true" name="JBossJavaHome" order="Setting">
    <description>JAVA_HOME for JBoss</description>
    <supertype>
    <typereference name="JBossSetting"/>
    </supertype>
    <attributes>
    <attribute name="javaHome" type-property="settingValue"/>
    </attributes>
    <constraints>
    <dependency-constraint enforced="false" kind="parent">
    <allowedtypes>
    <typereference name="JBossServer"/>
    </allowedtypes>
    </dependency-constraint>
    </constraints>
    </type>

One thing to bear in mind is that constraint references to types that are defined in separate modules (most often the case with Setting sub-types) are resolved only when all the types are loaded into the project. Using ProjectBuilder's "load-library" command (or loading a seed from the Workbench administration page) is the most obvious way to achieve this without the order in which modules are added to the project being significant.

Anthony Shortland,
anthony@controltier.com

No comments: