public void addObject(final QmfAgentData object) throws QmfException
{
// There are some cases where a QmfAgentData Object might have already set its ObjectId, for example where
// it may need to have a "well known" ObjectId. This is the case with the Java Broker Management Agent
// where tools such as qpid-config might have made assumptions about its ObjectId rather than doing "discovery".
ObjectId addr = object.getObjectId();
if (addr == null)
{
SchemaClassId classId = object.getSchemaClassId();
SchemaClass schema = _schemaCache.get(classId);
// Try to create an objectName using the property names that have been specified as idNames in the schema
StringBuilder buf = new StringBuilder();
// Initialise idNames as an empty array as we want to check if a key has been used to construct the name.
String[] idNames = {};
if (schema != null && schema instanceof SchemaObjectClass)
{
idNames = ((SchemaObjectClass)schema).getIdNames();
for (String property : idNames)
{
buf.append(object.getStringValue(property));
}
}
String objectName = buf.toString();
// If the schema hasn't given any help we use a UUID. Note that we check the length of idNames too
// as a given named key property might legitimately be an empty string (e.g. the default direct
// exchange has name == "")
if (objectName.length() == 0 && idNames.length == 0) objectName = UUID.randomUUID().toString();
// Finish up the name by incorporating package and class names
objectName = classId.getPackageName() + ":" + classId.getClassName() + ":" + objectName;
// Now we've got a good name for the object we create its ObjectId and add that to the object
addr = new ObjectId(_name, objectName, _epoch);
object.setObjectId(addr);
}
QmfAgentData foundObject = _objectIndex.get(addr);