use of org.apache.qpid.qmf2.common.SchemaClassId in project qpid by apache.
the class QpidQueueStats method createQueueSubscription.
/**
* Create a Subscription to query for all queue objects
*/
private void createQueueSubscription() {
try {
// This QmfQuery simply does an ID query for objects with the className "queue"
QmfQuery query = new QmfQuery(QmfQueryTarget.OBJECT, new SchemaClassId("queue"));
SubscribeParams params = _console.createSubscription(_broker, query, "queueStatsHandle");
_subscriptionId = params.getSubscriptionId();
// Subtract 10 as we want to refresh before it times out
_subscriptionDuration = params.getLifetime() - 10;
_startTime = System.currentTimeMillis();
} catch (QmfException qmfe) {
}
}
use of org.apache.qpid.qmf2.common.SchemaClassId in project qpid by apache.
the class SchemaTest method onEvent.
public void onEvent(WorkItem wi) {
if (wi instanceof AgentAddedWorkItem) {
AgentAddedWorkItem item = (AgentAddedWorkItem) wi;
Agent agent = item.getAgent();
System.out.println("\nAgent " + agent.getName() + " added ");
// Retrieve the List of SchemaClassIds from the Agent, these will be used to retrieve the Schema.
List<SchemaClassId> schemaClassIds = _console.getClasses(agent);
if (schemaClassIds.size() > 0) {
// For each retrieved Class retrieve and display the Schema.
for (SchemaClassId schemaClassId : schemaClassIds) {
List<SchemaClass> schema = _console.getSchema(schemaClassId, agent);
if (schema.size() == 1) {
schema.get(0).listValues();
}
}
} else {
System.out.println("No schema information is available for this Agent");
}
}
}
use of org.apache.qpid.qmf2.common.SchemaClassId in project qpid by apache.
the class Test4 method registerObjectClass.
public void registerObjectClass(SchemaObjectClass schema) {
SchemaClassId classId = schema.getClassId();
_schemaCache.put(classId, schema);
}
use of org.apache.qpid.qmf2.common.SchemaClassId in project qpid by apache.
the class Test4 method addObject.
public void addObject(QmfAgentData object) throws QmfException {
SchemaClassId classId = object.getSchemaClassId();
SchemaClass schema = _schemaCache.get(classId);
// Try to create an objectName using the set of property names that have been specified as idNames in the schema
StringBuilder buf = new StringBuilder();
if (schema != null && schema instanceof SchemaObjectClass) {
String[] idNames = ((SchemaObjectClass) schema).getIdNames();
for (String name : idNames) {
buf.append(object.getStringValue(name));
}
}
String objectName = buf.toString();
// If the schema hasn't given any help we use a UUID
if (objectName.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 it's ObjectId and add that to the object
ObjectId addr = new ObjectId("test", /*name*/
objectName, 0);
object.setObjectId(addr);
if (_objectIndex.get(addr) != null) {
throw new QmfException("Duplicate QmfAgentData Address");
}
_objectIndex.put(addr, object);
}
use of org.apache.qpid.qmf2.common.SchemaClassId in project qpid by apache.
the class Agent method getSchema.
/**
* Return the SchemaClass associated with this Agent.
* @return the list of SchemaClass associated with this Agent.
* <p>
* I <i>believe</i> that there should only be one entry in the list returned when looking up a specific chema by classId.
*/
public List<SchemaClass> getSchema(final SchemaClassId classId) {
SchemaClass schema = _schemaCache.get(classId);
if (schema == SchemaClass.EMPTY_SCHEMA) {
return Collections.emptyList();
}
List<SchemaClass> results = new ArrayList<SchemaClass>();
results.add(schema);
return results;
}
Aggregations