Business Objects and Data Sources > Data Sources > Adding Dynamic Business Objects

To create a dynamic business object, all you have to do is create an instance of IlpDefaultObject for an IlpClass, generally an IlpDefaultClass.

Here is an example:

How to Create a Dynamic Business Object
IlpDefaultObject bo = new IlpDefaultObject(alarmClass, "Alarm1");
bo.setAttributeValue(severityAttribute, new Integer(2));
bo.setAttributeValue(ackAttribute, Boolean.FALSE);

Note that here the identifier of the object is a string, but it does not have to be. This identifier could be of any class, provided that instances of that class can be read from and converted to string using the type converter.

The interface IlpObject also contains convenience methods to retrieve and set attribute values based on the attribute name. These convenience methods can be easily implemented as follows:

public Object getAttributeValue (String attribute) {
  IlpAttribute attr = getAttributeGroup().getAttribute(attribute);
  if (attr != null)
    return getAttributeValue(attr);
  return IlpAttributeValueHolder.VALUE_NOT_SET;
}
 
public void setAttributeValue (String attributeName, Object value) {
  IlpAttribute attr = getAttributeGroup().getAttribute(attribute);
  if (attr != null)
    setAttributeValue(attr, value);
}