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

Before you can use this policy function, you must make the Java classes available to Netcool/Impact during run time. To make the Java classes available, complete the following steps:
  1. Copy the Java classes to the $IMPACT_HOME/dsalib directory.
  2. Restart the Impact Server to load the JAR files.
You must repeat this procedure for each Impact Server. This procedure repetition is necessary because the Java class files in the $IMPACT_HOME/dsalib directory are not replicated between servers.

Syntax

SetFieldValue( ClassName, TargetObject , FieldName, FieldValue );

Parameters

Table 1. SetFieldValue function parameters

Parameter

Description

ClassName

Name of the Java class. When you use a non-static method call, this parameter would be set to null.

TargetObject

Name of the instantiated Java object. When you use a static method, this parameter would be set to null.

FieldName

Name of the public field variable in the Java class that you are setting the value for.

FieldValue

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);