GetFieldValue

Use this function to get the value of static or non-static public fields in a Java class. For non-static fields, use the variable FieldName for a Java class or TargetObject for a Java object. For a static Java class field, use the variable ClassName.

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 is necessary because the Java class files in the $IMPACT_HOME/dsalib directory are not replicated between servers.

Syntax

GetFieldValue( ClassName, TargetObject, FieldName );

Parameters

Table 1. GetFieldValue function parameters

Parameter

Description

ClassName

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

TargetObject

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

FieldName

Name of the public field variable in the Java class to retrieve the value for.

Returns

Value of the field.

Example

Get the value of the static field named out of the Java class, java.lang.System:

fieldvalue = GetFieldValue("java.lang.System", null, "out");

Get the value of the non-static field firstname from a hypothetical Java class, com.ibm.DeveloperAccount. Since it is a non-static field, we are retrieving the field data off an instantiated object of the class. We assume that the constructor needs only a simple ID number to retrieve the account instance:

Example using IPL.

dev_acct = NewJavaObject("com.ibm.DeveloperAccount", {765224});
first_name = GetFieldValue(null, dev_acct, "firstname");

Example using JavaScript.

dev_acct = NewJavaObject("com.ibm.DeveloperAccount", [765224]);
first_name = GetFieldValue(null, dev_acct, "firstname");