What are Service Attributes?

Service attributes serve the same role as normal element attributes. They allow you to attach specific data to particular DSM elements and access those data by names.

However, unlike normal DSM attributes, service attributes are not provided by the DSM driver and not connected to the external data source.

Rather, service attributes are maintained by the generator in the form of a special hash-map.


That hash-map is actually very simple. Each service attribute is represented by a two-part key: { attrName; element.id }, where 'attrName' is the attribute name; 'element.id' is the unique identifier of the DSM element, to which the attribute is attached. Such a key is mapped to the attribute value.

Service attributes have the following properties:

  1. Since they are not part of the DSM (the XML-like representation of the external data source, which rarely allows changing element attributes), service attributes are always available for any DSM Type.
  2. The value of a service attribute can be any object including null.
  3. Service attributes are not mixed in any way with normal element attributes (for instance, they won't be included in the scope of an Attribute Iterator). The only way to obtain the value of a service attribute is via getServiceAttr() function.
The main purpose of service attributes is to use them as a data cache. That is to store some frequently needed information about particular elements, which although may be found in the DSM, practically is difficult to obtain.

The following functions are available to work with service attributes:

setServiceAttr()

Associates a service attribute with the specified name and value to the specified element.
getServiceAttr()
Returns the value of a service attribute with the specified name attached to the specified element.
hasServiceAttr()
Tests if there is a service attribute with the specified name attached to the specified element.
removeServiceAttr()
Deletes a service attribute with the specified name attached to the specified element.