Attributes are conceptual variables that are exposed for management through getter and setter methods in the MBean interface:
A getter is any public method whose name begins with get and which does not return void; it enables a manager to read the value of the attribute, whose type is that of the returned object.
A public method whose name begins with is and which returns a boolean or Boolean is also a getter, though a boolean attribute can have only one getter (it must be one form or the other).
A setter is any public method whose name begins with set and which takes a single parameter; it enables a manager to write a new value in the attribute, whose type is that of the parameter.
Attribute types can be arrays of objects, but individual array elements cannot be accessed individually through the getters and setters. Use operations to access the array elements, as described in the next section. The following code example demonstrates an attribute with an array type:
public String getMessages(); public void setMessages(String msgArray);
The name of the attribute is the literal part of the method name following get, is, or set. This name is case sensitive in all Java Dynamic Management Kit (Java DMK) objects that manipulate attribute names. Using these patterns, we can determine the attributes exposed in Example 1–1:
State is a readable and writable attribute of type String
NbChanges is a read-only attribute of type Integer
The specification of the design patterns for attributes implies the following rules:
Attributes can be read-only, write-only, or readable and writable.
Attribute names cannot be overloaded. For any given attribute name there can be at most one setter and one getter, and if both are defined, they must use the same type.