19.0 Using Query Expressions

 


19.1 Query Expressions : An Overview

19.2 Classes and Interfaces Defined for Developing Query Expressions

19.3 Example


 

19.1 Query Expressions : An Overview

 

The MBeans registered with the MBean server can be retrieved using queryMBeans method.  Using Object name you can filter the MBeans according to its type. Using Query expression you can further filter the MBeans according to its attribute values.

 

A Query expression is the user-defined criteria for filtering MBeans based on the attribute values. If query method does not find any MBean with the given condition and/or if MBeans do not satisfy the given query expression, the returned set will not contain any element. Querying and filtering are actually performed by the MBean server itself, not by a separate MBean.

For example, a filter could select all the MBeans whose object name contains "MyMBeans" while a Query Expression in tandem with the filter would get all the MBeans whose ObjectName contains "MyMBeans" and attribute named color is equal to "red". The result of a query operation is a list of MBean object names, which can then be used in other management requests.

 

19.2 Classes and Interfaces Defined for Developing Query Expressions

In practice, users do not instantiate the ValueExp and QueryExp implementation classes directly. Instead, they rely on the methods of the Query class to return the values and expressions, composing them together to form the final query expression. The methods of the MBeanServer interface that perform queries are:

19.3 An Example

 

Let us assume an agent is generated for AGENT-SAMPLE-MIB with default settings given in JMX Compiler. The object name of agentSystem would be AdventNetJMXAgent:type=AgentSystemInstrumentExt.

 

To filter the MBeans which has an attribute "AgentAvailMemory" where the attribute value is equal to 1000 :

This set will contain the MBean of agentSystem.

In case of more condition statements, composition of calls can be constructed by arbitrary nesting of constraints, as follows :
QueryExp exp = Query.and(Query.gt(Query.attr("age"),Query.value(5)), Query.match(Query.attr("name"), Query.value("Smith")));



Copyright © 1996-2004, AdventNet Inc. All Rights Reserved.