Configuration Parameters
Parameters must be identified and initialized when writing a task. For tasks to run, configuration information is needed.
Example
Assume a custom task is being written to create a file and write an XML document to disk. The
task requires configuration information from the user. The information needed is shown in Table 1.
| Parameter | Description | Default Value | Required |
|---|---|---|---|
| Directory to write file | Directory where the file is written | None | Yes - there is not a default value and one must be specified during configuration |
| File extension | File extension to use for the file | .xml | No - a default value is associated with the parameter |
The parameters need to be initialized, so Services Framework can show the configuration parameters in the user interface and pass the task the configured values during run time.
The initConfigParameters() method exists in the Base Task class for initializing
configuration parameters. It is recommended to follow these steps to initialize the parameters.
- Provide inline help for the configuration parameters
- Add each configuration parameter for the task to run
Provide Inline Help
Inline help for configuration parameters describes what the parameters are and how they are used.
The inline help appears in the Services Framework user interface during configuration. An
example of inline help is shown here:
Please enter values for configuring your custom task.
All required parameters must contain a value before saving.To add inline help, use the addconfigParameterInlineHelp() method. For example:
addConfigParameterInlineHelp(new StringBuffer()
.append("Please enter values for configuring your custom task. ")
.append("All required parameters must contain a value before saving.")
.toString());Adding Configuration Parameters
Initialization of the configuration parameters makes them available to the Services Framework. Before adding the parameters, each must be assigned a unique key. The key is used by the custom task to retrieve its configuration parameters during execution.
Unique keys are assigned to the previous example (Example), as shown here:
private static final String CONFIG_PARM_KEY_DIRECTORY = "DIRECTORY";
private static final String CONFIG_PARM_KEY_EXTENSION = "EXTENSION";After assigning the keys, the configuration parameters can be added to the Services Framework. To add configuration parameters, use the addConfigParameter() method.
An example of adding parameters is shown here:
addConfigParameter(CONFIG_PARM_KEY_DIRECTORY, "Directory to write file",
"Directory where the xml file will be written to.",
null, null, true);
addConfigParameter(CONFIG_PARM_KEY_EXTENSION, "File extension to use",
"Extension to use when creating the file.",
null, ".xml", false);Refer to the Javadoc information for additional information about methods and signatures.