|
![]() |
The objective of this feature is to allow the use of variables inside XML descriptors. Variables can be defined: directly in the descriptor, using independent files, or inside the deploying application's code (with an API).
The variable tags are usefull inside a descriptor because they can factorize frequent parameters. For example, a variable like ${PROACTIVE_HOME} can be defined, set and used in an XML Descriptor.
Type |
Variable Declaration |
Value Setting |
Priority |
---|---|---|---|
constant |
Descriptor |
Descriptor |
Descriptor |
overridableInProgram |
Descriptor |
Descriptor or Program |
Program |
overridableInXML |
Descriptor |
Descriptor or Program |
Descriptor |
setInProgram |
Descriptor |
Program |
Program |
javaProperty |
Descriptor |
JavaProperty |
JavaProperty |
Variables can be defined in more than one place. When the value is set on multiple places, then the definition specified in the priority column will take precedence.
All variable declarations must be written in a variable section at the beginning of the descriptor file in the following way:
<variables> <property name="USER_HOME" value="/usr/home/team"/> <!-- constant is default--> <property name="PROACTIVE_HOME" value="ProActive/dist/ProActive" type="constant"/> <property name="OPTIONAL_NODES" value="2" type="overrridableInXML"/> <property name="USE_P2P" value="yes" type="overrridableInProgram"/> <property name="NEEDED_NODES" value="" type="setInProgram" /> <!-- example using jvm properties --> <property name="JAVA_HOME" value="java.home" type="javaProperty"/> <!-- loading external files with variables definitions --> <propertiesFile location="context.properties"/> <property file="context.xml"/> </variables> <!-- example usage --> ... <classpath> <absolutePath value="${USER_HOME}/${PROACTIVE_HOME}/ProActive.jar"/> <absolutePath value="${JAVA_HOME}/lib/asm.jar"/> </classpath> ...
XMLProperties.setVariableValue( "OPTIONAL_NODES", "4", "overridableInXML"); XMLProperties.setVariableValue( "USE_P2P", "no", "overridableInProgram"); XMLProperties.setVariableValue( "NEEDED_NODES", "50", "setInProgram");
Is built using XML property tags.
File : context.xml
|
This approach uses Sun microsystems properties file format. The format is plain text with one definition per line in the format variable = value, as shown in the following example:
File : context.properties
|
Note that colon (:) can be used instead of equal (=).
The API for adding a single variable value is show below. The name corresponds to the variable name, and the value to the variable content. The type is the String corresponding to one of the supported variable types.
static public XMLProperties.setVariableValue( String name, String value, String type);
The API for adding a multiple variables is shown below. The variable name/value pair is specified as the key/content of the HashMap. The type is the String corresponding to one of the supported variable types.
static public XMLProperties.setVariableValue( HashMap map, String type);
Copyright © April 2005 INRIA All Rights Reserved.