21.2. Writing the Installer Definition File

21.2.1. Create the installer subdirectory

By convention, all of the files associated with a sensor's HackyInstaller code is placed in a subdirectory called "installer". The first step in creating a new sensor installer is to create this directory. For example, if we are creating an installer for a sensor named FooSensor, then the installer subdirectory might be located in your local workspace as follows:

C:\svn\hackySensor_FooSensor\src\org\hackystat\sensor\foosensor\installer\

21.2.2. Common Attributes

A file named <moduleName>.<installerName>.installer.def.xml defines a sensor installer plugin for use by HackyInstaller. This extension point requires a file pattern of "*.installer.def.xml" in order to be recognized by the build system.

Example 21.1, “hackySensor_Eclipse.eclipse.installer.def.xml” illustrates an example Installer definition file for the Eclipse sensor.

Example 21.1. hackySensor_Eclipse.eclipse.installer.def.xml

<sensor>
  <name value="Eclipse" /> 1
  <os windows="true" mac="true" linux-unix="true" /> 2
  <package value="org.hackystat.sensor.eclipse.installer" /> 3
  <class value="EclipseSensorInstaller" />
  <description value="The Eclipse sensor collects Activity, UnitTest and Buffer Transition sensor data." /> 4
  <!-- Paths needed by this sensor -->
  <path id="ECLIPSE_HOME" description="Eclipse home directory" example="C:\eclipse (Windows), /Applications/eclipse (Unix)" > 5
    <!-- Checks for the files/directories specified that ensure the path specifed above is valid. -->
    <check value="/.eclipseproduct" />
  </path>
  <!-- Sensor specfic properties for sensor.properties -->
  <property name="ENABLE_ECLIPSE_SENSOR" 6
               value="false" 7
               readonly="false"
               validationclass="" 8
               fieldLength="" 9
               description="Enable Eclipse sensor." /> 10
  <property name="ENABLE_ECLIPSE_MONITOR_SENSOR" value="true" readonly="false" validationclass="" description="Enable status line monitoring." />
  <property name="ENABLE_ECLIPSE_UPDATE_SENSOR" value="false" readonly="false" validationclass="" description="Enable checking for new Eclipse sensor versions." />
  <property name="ENABLE_ECLIPSE_BUFFTRANS_SENSOR" value="false" readonly="false" validationclass="" description="Enable Buffer Transition data collection." />

</sensor>

Please note the following regarding Example 21.1, “hackySensor_Eclipse.eclipse.installer.def.xml”:

1

The name of the sensor that will be added to HackyInstaller. This name is the text that will appear in the table of sensors in HackyInstaller.

2

The operating system(s) that this sensor is compatiable with. If an attribute value is set to false, the sensor cannot be configured under the specified operating system. Note: the configuration can be forced by the option 'Ignore Operating System' under 'File > Edit Common Settings...' in the main HackyInstaller interface.

3

The package that the hackySensor_*.*.installer.def.xml and <SensorName>SensorInstaller.java files can be found. The class value is the name of <SensorName>SensorInstaller.java file.

4

The informative text that appears in 'Sensor Information' section of the sensor's configuration window. HackyInstaller supports multi-line descriptions, which are marked with the '^' character. For example, if you would like to have a list of items in the description, every newline would begin with a '^'.

5

The path that HackyInstaller requires to know if a sensor is installed. The path is set under the 'Sensor specific directories' section of the sensor's configuration window. The description and example attributes are used to help the user select a path. Note: HackyInstaller can support one or more path elements.

The check elements (nested inside path elements) are used to specify files that should exist in order for the path to be "valid". The file or directory to be checked for should be placed in the value attribute of the check element. Note: value should be the file or directory to be checked for in relation to the specified path. There can be 0 or more checks specified for a given path.

6

The name of the property that will be written to the sensor.properties file in the user.home/.hackystat/ directory.

7

The default value of the property. If the default value of the property is set to 'true' or 'false' then the property option in the 'Sensor settings' section of the configuration window will be a checkbox. If the default value is the empty string ("") or any other value, then the property option will be a fillable form.

The 'readonly' attribute sets a property to be read-only. 'true' sets the property to be read-only and 'false allows the property to be changed.

8

The name of the validation class that checks the value of the property before it is saved.

9

The default length of the editable text field. The values that this attribute accepts are integer values(i.e 1, 2, 3...), which is used to determine the length of the field. This option should be used when the text string is longer than the default field size provided by HackyInstaller. In the case of multiple properties with field lengths, the properties are sorted by ascending field length for cosmetic purposes.

10

The text that appears besides the property and describes what the property does.

21.2.3. The Information Attribute

Note: an optional 'information' element can be added to the installer definition file. An example of the optional element should look like: Example 21.2, “An example information element”. The additional information will appear in a popup window after a sensor is installed. Figure 21.1, “ The additional information window ” illustrates the window displayed to the user.

Example 21.2. An example information element

<information value="This sensor requires a usermaps.xml file in the USER_HOME/.hackystat directory.  Please verify that this file exists./>
		

Figure 21.1.  The additional information window

 The additional information
        window