javax.management
Class ObjectName

java.lang.Object
  |
  +--javax.management.ObjectName
All Implemented Interfaces:
QueryExp, java.io.Serializable

public class ObjectName
extends java.lang.Object
implements QueryExp, java.io.Serializable

Represents the object name of an MBean, or a pattern that can match the names of several MBeans. Instances of this class are immutable.

An instance of this class can be used to represent:

An object name consists of two parts, the domain and the key properties.

The domain is a string of characters not including the character colon (:).

If the domain includes at least one occurrence of the wildcard characters asterisk (*) or question mark (?), then the object name is a pattern. The asterisk matches any sequence of zero or more characters, while the question mark matches any single character.

If the domain is empty, it will be replaced in certain contexts by the default domain of the MBean server in which the ObjectName is used.

The key properties are an unordered set of keys and associated values.

Each key is a nonempty string of characters which may not contain any of the characters comma (,), equals (=), colon, asterisk, or question mark. The same key may not occur twice in a given ObjectName.

Each value associated with a key is a string of characters that is either unquoted or quoted.

An unquoted value is a possibly empty string of characters which may not contain any of the characters comma, equals, colon, quote, asterisk, or question mark.

A quoted value consists of a quote ("), followed by a possibly empty string of characters, followed by another quote. Within the string of characters, the backslash (\) has a special meaning. It must be followed by one of the following characters:

A quote, question mark, or star may not appear inside a quoted value except immediately after an odd number of consecutive backslashes.

The quotes surrounding a quoted value, and any backslashes within that value, are considered to be part of the value.

An ObjectName may be a property pattern. In this case it may have zero or more keys and associated values. It matches a nonpattern ObjectName whose domain matches and that contains the same keys and associated values, as well as possibly other keys and values.

An ObjectName is a pattern if its domain contains a wildcard or if the ObjectName is a property pattern.

If an ObjectName is not a pattern, it must contain at least one key with its associated value.

An ObjectName can be written as a String with the following elements in order:

A key property list written as a String is a comma-separated list of elements. Each element is either an asterisk or a key property. A key property consists of a key, an equals (=), and the associated value.

At most one element of a key property list may be an asterisk. If the key property list contains an asterisk element, the ObjectName is a property pattern.

Spaces have no special significance in a String representing an ObjectName. For example, the String:

 domain: key1 = value1 , key2 = value2
 
represents an ObjectName with two keys. The name of each key contains six characters, of which the first and last are spaces. The value associated with the key " key1 " also begins and ends with a space.

In addition to the restrictions on characters spelt out above, no part of an ObjectName may contain a newline character ('\n'), whether the domain, a key, or a value, whether quoted or unquoted. The newline character can be represented in a quoted value with the sequence \n.

The rules on special characters and quoting apply regardless of which constructor is used to make an ObjectName.

To avoid collisions between MBeans supplied by different vendors, a useful convention is to begin the domain name with the reverse DNS name of the organization that specifies the MBeans, followed by a period and a string whose interpretation is determined by that organization. For example, MBeans specified by Sun Microsystems Inc., DNS name sun.com, would have domains such as com.sun.MyDomain. This is essentially the same convention as for Java-language package names.

Author:
Young Yang
See Also:
Serialized Form

Constructor Summary
ObjectName(java.lang.String name)
           
ObjectName(java.lang.String domain, java.util.Hashtable table)
           
ObjectName(java.lang.String domain, java.lang.String key, java.lang.String value)
           
 
Method Summary
 boolean apply(ObjectName name)
          Applies the QueryExp on an MBean.
 boolean equals(java.lang.Object obj)
           
 java.lang.String getCanonicalKeyPropertyListString()
           
 java.lang.String getCanonicalName()
           
 java.lang.String getDomain()
           
 java.lang.String getKeyProperty(java.lang.String property)
           
 java.util.Hashtable getKeyPropertyList()
           
 java.lang.String getKeyPropertyListString()
           
 int hashCode()
           
 boolean isPattern()
           
 boolean isPropertyPattern()
           
static void main(java.lang.String[] args)
           
 void setMBeanServer(MBeanServer server)
          Sets the MBean server on which the query is to be performed.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ObjectName

public ObjectName(java.lang.String name)
           throws MalformedObjectNameException

ObjectName

public ObjectName(java.lang.String domain,
                  java.lang.String key,
                  java.lang.String value)
           throws MalformedObjectNameException

ObjectName

public ObjectName(java.lang.String domain,
                  java.util.Hashtable table)
           throws MalformedObjectNameException
Method Detail

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

isPattern

public boolean isPattern()

getCanonicalName

public java.lang.String getCanonicalName()

getDomain

public java.lang.String getDomain()

getKeyProperty

public java.lang.String getKeyProperty(java.lang.String property)

getKeyPropertyList

public java.util.Hashtable getKeyPropertyList()

getKeyPropertyListString

public java.lang.String getKeyPropertyListString()

getCanonicalKeyPropertyListString

public java.lang.String getCanonicalKeyPropertyListString()

isPropertyPattern

public boolean isPropertyPattern()

apply

public boolean apply(ObjectName name)
              throws BadStringOperationException,
                     BadBinaryOpValueExpException,
                     BadAttributeValueExpException,
                     InvalidApplicationException
Description copied from interface: QueryExp
Applies the QueryExp on an MBean.
Specified by:
apply in interface QueryExp
Following copied from interface: javax.management.QueryExp
Parameters:
name - The name of the MBean on which the QueryExp will be applied.
Returns:
True if the query was successfully applied to the MBean, false otherwise
Throws:
BadStringOperationException -  
BadBinaryOpValueExpException -  
BadAttributeValueExpException -  
InvalidApplicationException -  

setMBeanServer

public void setMBeanServer(MBeanServer server)
Description copied from interface: QueryExp
Sets the MBean server on which the query is to be performed.
Specified by:
setMBeanServer in interface QueryExp
Following copied from interface: javax.management.QueryExp
Parameters:
s - The MBean server on which the query is to be performed.

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception