SetFieldValue
Use the SetFieldValue function to set a public field variable in a Java class to some value.
If it is a static field, then you specify the Java class ClassName. If it is a non-static value, then you provide the instance at TargetObject.
Adding Java archive (JAR) files to the shared library directory
- Copy the Java classes to the $IMPACT_HOME/dsalib directory.
- Restart the Impact Server to load the JAR files.
Syntax
SetFieldValue( ClassName,
TargetObject , FieldName, FieldValue );Parameters
Parameter |
Description |
|---|---|
|
Name of the Java class. When you use a non-static method call, this parameter would be set to null. |
|
Name of the instantiated Java object. When you use a static method, this parameter would be set to null. |
|
Name of the public field variable in the Java class that you are setting the value for. |
|
The value that you are setting the field to. |
Returns
N/A
Examples
Reversing the example for GetFieldValue. Using IPL, if you want to set the non-static firstname field
in a hypothetical Java class DeveloperAccount:
dev_acct = NewJavaObject("com.ibm.DeveloperAccount", {65224});
SetFieldValue(null, dev_acct, "firstname", "Sam");Reversing the example for GetFieldValue. Using JavaScript, if you want to set the
non-static firstname field in a hypothetical Java
class DeveloperAccount:
dev_acct = NewJavaObject("com.ibm.DeveloperAccount", [65224]);
SetFieldValue(null, dev_acct, "firstname", "Sam");Assuming
there is a static counter variable disconnects in
a hypothetical Java class com.ibm.tivoli.EventStats,
which you want to increment through an Impact policy:
counter = GetFieldValue("com.ibm.tivoli.EventStats", "disconnects");
counter += 1;
SetFieldValue("com.ibm.tivoli.EventStats", null, "disconnects", counter);