In order to enable configuration of a class variable from a properties file, the class defines setX()
and getX()
methods for that variable, where X
specifies the variable/property to configure.
For example, to make the variable age
configurable from the property age
, the class defines setAge()
and getAge()
methods:
int age;
public void setAge (int age) { this.age = age; }
public int getAge () { return age; }
Exposing a variable as a property also exposes it to runtime inspection by the Nucleus administrator.
You might also wish to make a property read-only, meaning that it can be inspected at runtime but cannot be configured through a properties file. This technique is often used for properties that contain runtime statistics. To make a property read-only, simply omit the setX
function:
int age;
public int getAge () { return age; }