The ServiceAttributes class provides a framework for representation of
service state, which is an important component of service metadata. Each
member variable whose name does not begin with underscore ("_") is treated as
an "attribute". NOTE: any private member names MUST be preceded by
underscore.
Each instrument service contains an instance of
ServiceAttributes (or subclass). As the service runs, the instrument service
sets the attribute values to reflect the service state. When generating a
metadata packet, the InstrumentService framework automatically generates a
representation of service state based on the ServiceAttribute values.

Moreover some attributes are "configurable", in the sense that the
attribute's initial value can be specified at service runtime, in a "service
properties" file. ServiceAttributes supports runtime configuration by
providing methods that convert from attribute values to Java property
strings, and vice versa. Each configurable attribute will have a property,
the property name being the name of the attribute's member variable. E.g. an
attribute declared as

long isiID;

will be represented as a property named "isiID" and a property value string
that can be converted to a "long" value. An attribute is configurable only if
the requiredIsConfigurable() or isConfigurable() method returns 'true'.

When a service is started, the InstrumentService framework reads the service
property file and invokes ServiceAttributes.fromProperties(). During this
process, ServiceAttributes will verify that the property values are
consistent with the attribute types, and will detect property names that do
not correspond to any attribute name. Moreover, several override-able
ServiceAttributes callback methods are invoked:

isConfigurable(); returns true if specified property can be specified as
a property

setAttributeCallback(); allows attribute value to be checked as its
property is parsed (Note that the framework autmoatically verifies
appropriate value type before setAttributeCallback() is invoked).)

missingAttributeCallback(); called when an input property is not found
for an attribute

checkValues(); called after all properties have been parsed

The ServiceAttributes class can be extended by adding additional attribute
members, and overriding the various callback methods. Attribute members must
be declared non-static, and of one of the following types:

primitive

String

any object that implements org.mbari.siam.distrbuted.Mnemonic (e.g.
PowerPolicy, ScheduleSpecifier). Note that this object *MUST* have a public
no-argument constructor.

fromProperties(java.util.Properties properties,
boolean unknownPropertyCheck)
Set values in an object instance of a class from the ServiceAttributes
hierarchy, according to input property string values.

toPropertyStrings

toProperties

public java.util.Properties toProperties()

Convert attributes to Java properties, for an object instance in the
ServiceAttributes hierarchy. The resulting properties are named after
members of the ServiceAttributes class (or subclass). E.g.
InstrumentServiceAttributes.toProperties() results in properties named
mnemonicName, deviceID, timeSynch, etc.

toConfigurableProperties

public java.util.Properties toConfigurableProperties()

Convert all configurable attributes to Java properties, for an object
instance in the ServiceAttributes hierarchy. The resulting properties are
named after members of the ServiceAttributes class (or subclass). E.g.
InstrumentServiceAttributes.toProperties() results in properties named
mnemonicName, deviceID, timeSynch, etc.

fromProperties

Set values in an object instance of a class from the ServiceAttributes
hierarchy, according to input property string values. Input properties
have names that map to object instance variables. E.g.
InstrumentServiceAttributes.fromProperties() parses properties named
mnemonicName, deviceID, timeSynch, etc.

Parameters:

properties - Input properties to be parsed

unknownPropertyCheck - set to true if method should check for unknown property names

setAttributeCallback

Called when specified attribute has been found. Throw
InvalidPropertyException if specified attribute has invalid value.
Note that the ServiceAttributes base class automatically validates
the value type before setAttributeCallback() is invoked; so this
method needs only to validate the value.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.