javax.management.remote
Class JMXServiceURL

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by javax.management.remote.JMXServiceURL
All Implemented Interfaces:
Serializable sample code for java.io.Serializable definition code for java.io.Serializable

public class JMXServiceURL
extends Object sample code for java.lang.Object definition code for java.lang.Object
implements Serializable sample code for java.io.Serializable definition code for java.io.Serializable

The address of a JMX API connector server. Instances of this class are immutable.

The address is an Abstract Service URL for SLP, as defined in RFC 2609 and amended by RFC 3111. It must look like this:

service:jmx:protocol:sap

Here, protocol is the transport protocol to be used to connect to the connector server. It is a string of one or more ASCII characters, each of which is a letter, a digit, or one of the characters + or -. The first character must be a letter. Uppercase letters are converted into lowercase ones.

sap is the address at which the connector server is found. This address uses a subset of the syntax defined by RFC 2609 for IP-based protocols. It is a subset because the user@host syntax is not supported.

The other syntaxes defined by RFC 2609 are not currently supported by this class.

The supported syntax is:

//[host[:port]][url-path]

Square brackets [] indicate optional parts of the address. Not all protocols will recognize all optional parts.

The host is a host name, an IPv4 numeric host address, or an IPv6 numeric address enclosed in square brackets.

The port is a decimal port number. 0 means a default or anonymous port, depending on the protocol.

The host and port can be omitted. The port cannot be supplied without a host.

The url-path, if any, begins with a slash (/) or a semicolon (;) and continues to the end of the address. It can contain attributes using the semicolon syntax specified in RFC 2609. Those attributes are not parsed by this class and incorrect attribute syntax is not detected.

Although it is legal according to RFC 2609 to have a url-path that begins with a semicolon, not all implementations of SLP allow it, so it is recommended to avoid that syntax.

Case is not significant in the initial service:jmx:protocol string or in the host part of the address. Depending on the protocol, case can be significant in the url-path.

Since:
1.5
See Also:
RFC 2609, "Service Templates and Service: Schemes", RFC 3111, "Service Location Protocol Modifications for IPv6", Serialized Form

Constructor Summary
JMXServiceURL sample code for javax.management.remote.JMXServiceURL.JMXServiceURL(java.lang.String) definition code for javax.management.remote.JMXServiceURL.JMXServiceURL(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  serviceURL)
          Constructs a JMXServiceURL by parsing a Service URL string.
JMXServiceURL sample code for javax.management.remote.JMXServiceURL.JMXServiceURL(java.lang.String, java.lang.String, int) definition code for javax.management.remote.JMXServiceURL.JMXServiceURL(java.lang.String, java.lang.String, int) (String sample code for java.lang.String definition code for java.lang.String  protocol, String sample code for java.lang.String definition code for java.lang.String  host, int port)
          Constructs a JMXServiceURL with the given protocol, host, and port.
JMXServiceURL sample code for javax.management.remote.JMXServiceURL.JMXServiceURL(java.lang.String, java.lang.String, int, java.lang.String) definition code for javax.management.remote.JMXServiceURL.JMXServiceURL(java.lang.String, java.lang.String, int, java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  protocol, String sample code for java.lang.String definition code for java.lang.String  host, int port, String sample code for java.lang.String definition code for java.lang.String  urlPath)
          Constructs a JMXServiceURL with the given parts.
 
Method Summary
 boolean equals sample code for javax.management.remote.JMXServiceURL.equals(java.lang.Object) definition code for javax.management.remote.JMXServiceURL.equals(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  obj)
          Indicates whether some other object is equal to this one.
 String sample code for java.lang.String definition code for java.lang.String getHost sample code for javax.management.remote.JMXServiceURL.getHost() definition code for javax.management.remote.JMXServiceURL.getHost() ()
          The host part of the Service URL.
 int getPort sample code for javax.management.remote.JMXServiceURL.getPort() definition code for javax.management.remote.JMXServiceURL.getPort() ()
          The port of the Service URL.
 String sample code for java.lang.String definition code for java.lang.String getProtocol sample code for javax.management.remote.JMXServiceURL.getProtocol() definition code for javax.management.remote.JMXServiceURL.getProtocol() ()
          The protocol part of the Service URL.
 String sample code for java.lang.String definition code for java.lang.String getURLPath sample code for javax.management.remote.JMXServiceURL.getURLPath() definition code for javax.management.remote.JMXServiceURL.getURLPath() ()
          The URL Path part of the Service URL.
 int hashCode sample code for javax.management.remote.JMXServiceURL.hashCode() definition code for javax.management.remote.JMXServiceURL.hashCode() ()
          Returns a hash code value for the object.
 String sample code for java.lang.String definition code for java.lang.String toString sample code for javax.management.remote.JMXServiceURL.toString() definition code for javax.management.remote.JMXServiceURL.toString() ()
          The string representation of this Service URL.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

JMXServiceURL sample code for javax.management.remote.JMXServiceURL(java.lang.String) definition code for javax.management.remote.JMXServiceURL(java.lang.String)

public JMXServiceURL(String sample code for java.lang.String definition code for java.lang.String  serviceURL)
              throws MalformedURLException sample code for java.net.MalformedURLException definition code for java.net.MalformedURLException 

Constructs a JMXServiceURL by parsing a Service URL string.

Parameters:
serviceURL - the URL string to be parsed.
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if serviceURL is null.
MalformedURLException sample code for java.net.MalformedURLException definition code for java.net.MalformedURLException - if serviceURL does not conform to the syntax for an Abstract Service URL or if it is not a valid name for a JMX Remote API service. A JMXServiceURL must begin with the string "service:jmx:" (case-insensitive). It must not contain any characters that are not printable ASCII characters.

JMXServiceURL sample code for javax.management.remote.JMXServiceURL(java.lang.String, java.lang.String, int) definition code for javax.management.remote.JMXServiceURL(java.lang.String, java.lang.String, int)

public JMXServiceURL(String sample code for java.lang.String definition code for java.lang.String  protocol,
                     String sample code for java.lang.String definition code for java.lang.String  host,
                     int port)
              throws MalformedURLException sample code for java.net.MalformedURLException definition code for java.net.MalformedURLException 

Constructs a JMXServiceURL with the given protocol, host, and port. This constructor is equivalent to JMXServiceURL(protocol, host, port, null) sample code for javax.management.remote.JMXServiceURL.JMXServiceURL(java.lang.String, java.lang.String, int, java.lang.String) definition code for javax.management.remote.JMXServiceURL.JMXServiceURL(java.lang.String, java.lang.String, int, java.lang.String) .

Parameters:
protocol - the protocol part of the URL. If null, defaults to jmxmp.
host - the host part of the URL. If null, defaults to the local host name, as determined by InetAddress.getLocalHost().getHostName(). If it is a numeric IPv6 address, it can optionally be enclosed in square brackets [].
port - the port part of the URL.
Throws:
MalformedURLException sample code for java.net.MalformedURLException definition code for java.net.MalformedURLException - if one of the parts is syntactically incorrect, or if host is null and it is not possible to find the local host name, or if port is negative.

JMXServiceURL sample code for javax.management.remote.JMXServiceURL(java.lang.String, java.lang.String, int, java.lang.String) definition code for javax.management.remote.JMXServiceURL(java.lang.String, java.lang.String, int, java.lang.String)

public JMXServiceURL(String sample code for java.lang.String definition code for java.lang.String  protocol,
                     String sample code for java.lang.String definition code for java.lang.String  host,
                     int port,
                     String sample code for java.lang.String definition code for java.lang.String  urlPath)
              throws MalformedURLException sample code for java.net.MalformedURLException definition code for java.net.MalformedURLException 

Constructs a JMXServiceURL with the given parts.

Parameters:
protocol - the protocol part of the URL. If null, defaults to jmxmp.
host - the host part of the URL. If null, defaults to the local host name, as determined by InetAddress.getLocalHost().getHostName(). If it is a numeric IPv6 address, it can optionally be enclosed in square brackets [].
port - the port part of the URL.
urlPath - the URL path part of the URL. If null, defaults to the empty string.
Throws:
MalformedURLException sample code for java.net.MalformedURLException definition code for java.net.MalformedURLException - if one of the parts is syntactically incorrect, or if host is null and it is not possible to find the local host name, or if port is negative.
Method Detail

getProtocol sample code for javax.management.remote.JMXServiceURL.getProtocol() definition code for javax.management.remote.JMXServiceURL.getProtocol()

public String sample code for java.lang.String definition code for java.lang.String  getProtocol()

The protocol part of the Service URL.

Returns:
the protocol part of the Service URL. This is never null.

getHost sample code for javax.management.remote.JMXServiceURL.getHost() definition code for javax.management.remote.JMXServiceURL.getHost()

public String sample code for java.lang.String definition code for java.lang.String  getHost()

The host part of the Service URL. If the Service URL was constructed with the constructor that takes a URL string parameter, the result is the substring specifying the host in that URL. If the Service URL was constructed with a constructor that takes a separate host parameter, the result is the string that was specified. If that string was null, the result is InetAddress.getLocalHost().getHostName().

In either case, if the host was specified using the [...] syntax for numeric IPv6 addresses, the square brackets are not included in the return value here.

Returns:
the host part of the Service URL. This is never null.

getPort sample code for javax.management.remote.JMXServiceURL.getPort() definition code for javax.management.remote.JMXServiceURL.getPort()

public int getPort()

The port of the Service URL. If no port was specified, the returned value is 0.

Returns:
the port of the Service URL, or 0 if none.

getURLPath sample code for javax.management.remote.JMXServiceURL.getURLPath() definition code for javax.management.remote.JMXServiceURL.getURLPath()

public String sample code for java.lang.String definition code for java.lang.String  getURLPath()

The URL Path part of the Service URL. This is an empty string, or a string beginning with a slash (/), or a string beginning with a semicolon (;).

Returns:
the URL Path part of the Service URL. This is never null.

toString sample code for javax.management.remote.JMXServiceURL.toString() definition code for javax.management.remote.JMXServiceURL.toString()

public String sample code for java.lang.String definition code for java.lang.String  toString()

The string representation of this Service URL. If the value returned by this method is supplied to the JMXServiceURL constructor, the resultant object is equal to this one.

The host part of the returned string is the value returned by getHost() sample code for javax.management.remote.JMXServiceURL.getHost() definition code for javax.management.remote.JMXServiceURL.getHost() . If that value specifies a numeric IPv6 address, it is surrounded by square brackets [].

The port part of the returned string is the value returned by getPort() sample code for javax.management.remote.JMXServiceURL.getPort() definition code for javax.management.remote.JMXServiceURL.getPort() in its shortest decimal form. If the value is zero, it is omitted.

Overrides:
toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() in class Object sample code for java.lang.Object definition code for java.lang.Object
Returns:
the string representation of this Service URL.

equals sample code for javax.management.remote.JMXServiceURL.equals(java.lang.Object) definition code for javax.management.remote.JMXServiceURL.equals(java.lang.Object)

public boolean equals(Object sample code for java.lang.Object definition code for java.lang.Object  obj)

Indicates whether some other object is equal to this one. This method returns true if and only if obj is an instance of JMXServiceURL whose getProtocol() sample code for javax.management.remote.JMXServiceURL.getProtocol() definition code for javax.management.remote.JMXServiceURL.getProtocol() , getHost() sample code for javax.management.remote.JMXServiceURL.getHost() definition code for javax.management.remote.JMXServiceURL.getHost() , getPort() sample code for javax.management.remote.JMXServiceURL.getPort() definition code for javax.management.remote.JMXServiceURL.getPort() , and getURLPath() sample code for javax.management.remote.JMXServiceURL.getURLPath() definition code for javax.management.remote.JMXServiceURL.getURLPath() methods return the same values as for this object. The values for getProtocol() sample code for javax.management.remote.JMXServiceURL.getProtocol() definition code for javax.management.remote.JMXServiceURL.getProtocol() and getHost() sample code for javax.management.remote.JMXServiceURL.getHost() definition code for javax.management.remote.JMXServiceURL.getHost() can differ in case without affecting equality.

Overrides:
equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) in class Object sample code for java.lang.Object definition code for java.lang.Object
Parameters:
obj - the reference object with which to compare.
Returns:
true if this object is the same as the obj argument; false otherwise.
See Also:
Object.hashCode() sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , Hashtable sample code for java.util.Hashtable definition code for java.util.Hashtable

hashCode sample code for javax.management.remote.JMXServiceURL.hashCode() definition code for javax.management.remote.JMXServiceURL.hashCode()

public int hashCode()
Description copied from class: Object sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode()
Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.

The general contract of hashCode is:

As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)

Overrides:
hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() in class Object sample code for java.lang.Object definition code for java.lang.Object
Returns:
a hash code value for this object.
See Also:
Object.equals(java.lang.Object) sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , Hashtable sample code for java.util.Hashtable definition code for java.util.Hashtable