Top Description Fields Constructors Methods
javax.management.remote

public Class JMXServiceURL

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
com.sun.jmx.remote.util.ClassLogger, .EnvHelp, java.io.IOException, .InvalidObjectException, .ObjectInputStream, .Serializable, java.net.Inet4Address, .Inet6Address, .InetAddress, .MalformedURLException, .NetworkInterface, .SocketException, .UnknownHostException, java.util.BitSet, .Enumeration, .Locale, .StringTokenizer

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"

Field Summary

Modifier and TypeField and Description
private static final BitSet
private static final BitSet
private String
host

The value returned by getHost().

private static final BitSet
private static final String
private static final ClassLogger
private static final BitSet
private int
port

The value returned by getPort().

private String
protocol

The value returned by getProtocol().

private static final BitSet
private static final Exception
private static final long
private transient String
toString

Cached result of toString().

private String
urlPath

The value returned by getURLPath().

Constructor Summary

AccessConstructor and Description
public
JMXServiceURL(String
the URL string to be parsed.
serviceURL
)

Constructs a JMXServiceURL by parsing a Service URL string.

public
JMXServiceURL(String
the protocol part of the URL. If null, defaults to jmxmp.
protocol
,
String
the host part of the URL. If host is null and if local host name can be resolved to an IP, then host defaults to local host name as determined by InetAddress.getLocalHost().getHostName(). If host is null and if local host name cannot be resolved to an IP, then host defaults to numeric IP address of one of the active network interfaces. If host is a numeric IPv6 address, it can optionally be enclosed in square brackets [].
host
,
int
the port part of the URL.
port
)

Constructs a JMXServiceURL with the given protocol, host, and port.

public
JMXServiceURL(String
the protocol part of the URL. If null, defaults to jmxmp.
protocol
,
String
the host part of the URL. If host is null and if local host name can be resolved to an IP, then host defaults to local host name as determined by InetAddress.getLocalHost().getHostName(). If host is null and if local host name cannot be resolved to an IP, then host defaults to numeric IP address of one of the active network interfaces. If host is a numeric IPv6 address, it can optionally be enclosed in square brackets [].
host
,
int
the port part of the URL.
port
,
String
the URL path part of the URL. If null, defaults to the empty string.
urlPath
)

Constructs a JMXServiceURL with the given parts.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if this object is the same as the obj argument; false otherwise.
equals
(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is equal to this one.

private String
public String

Returns:

the host part of the Service URL. This is never null.
getHost
()

The host part of the Service URL.

public int

Returns:

the port of the Service URL, or 0 if none.
getPort
()

The port of the Service URL.

public String

Returns:

the protocol part of the Service URL. This is never null.
getProtocol
()

The protocol part of the Service URL.

public String

Returns:

the URL Path part of the Service URL. This is never null.
getURLPath
()

The URL Path part of the Service URL.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.
private static int
indexOf(String s, char c, int fromIndex)

private static int
indexOfFirstNotInSet(String s, BitSet set, int fromIndex)

private static boolean
private void
public String

Returns:

the string representation of this Service URL.
toString
()

Overrides java.lang.Object.toString.

The string representation of this Service URL.

private void
validate(String proto, String h, int p, String url)

private void
private static void
validateHost(String h, int port)

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

alphaBitSetback to summary
private static final BitSet alphaBitSet
alphaNumericBitSetback to summary
private static final BitSet alphaNumericBitSet
hostback to summary
private String host

The value returned by getHost().

hostNameBitSetback to summary
private static final BitSet hostNameBitSet
INVALID_INSTANCE_MSGback to summary
private static final String INVALID_INSTANCE_MSG
loggerback to summary
private static final ClassLogger logger
numericBitSetback to summary
private static final BitSet numericBitSet
portback to summary
private int port

The value returned by getPort().

protocolback to summary
private String protocol

The value returned by getProtocol().

protocolBitSetback to summary
private static final BitSet protocolBitSet
randomExceptionback to summary
private static final Exception randomException
serialVersionUIDback to summary
private static final long serialVersionUID
toStringback to summary
private transient String toString

Cached result of toString().

urlPathback to summary
private String urlPath

The value returned by getURLPath().

Constructor Detail

JMXServiceURLback to summary
public JMXServiceURL(String serviceURL) throws MalformedURLException

Constructs a JMXServiceURL by parsing a Service URL string.

Parameters
serviceURL:String

the URL string to be parsed.

Exceptions
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.
NullPointerException:
if serviceURL is null.
JMXServiceURLback to summary
public JMXServiceURL(String protocol, String host, int port) throws MalformedURLException

Constructs a JMXServiceURL with the given protocol, host, and port. This constructor is equivalent to JMXServiceURL(protocol, host, port, null).

Parameters
protocol:String

the protocol part of the URL. If null, defaults to jmxmp.

host:String

the host part of the URL. If host is null and if local host name can be resolved to an IP, then host defaults to local host name as determined by InetAddress.getLocalHost().getHostName(). If host is null and if local host name cannot be resolved to an IP, then host defaults to numeric IP address of one of the active network interfaces. If host is a numeric IPv6 address, it can optionally be enclosed in square brackets [].

port:int

the port part of the URL.

Exceptions
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.
JMXServiceURLback to summary
public JMXServiceURL(String protocol, String host, int port, String urlPath) throws MalformedURLException

Constructs a JMXServiceURL with the given parts.

Parameters
protocol:String

the protocol part of the URL. If null, defaults to jmxmp.

host:String

the host part of the URL. If host is null and if local host name can be resolved to an IP, then host defaults to local host name as determined by InetAddress.getLocalHost().getHostName(). If host is null and if local host name cannot be resolved to an IP, then host defaults to numeric IP address of one of the active network interfaces. If host is a numeric IPv6 address, it can optionally be enclosed in square brackets [].

port:int

the port part of the URL.

urlPath:String

the URL path part of the URL. If null, defaults to the empty string.

Exceptions
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

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

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(), getHost(), getPort(), and getURLPath() methods return the same values as for this object. The values for getProtocol() and getHost() can differ in case without affecting equality.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

getActiveNetworkInterfaceIPback to summary
private String getActiveNetworkInterfaceIP() throws SocketException
getHostback to summary
public 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() if local host name can be resolved to an IP. Else numeric IP address of an active network interface will be used.

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:String

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

getPortback to summary
public int getPort()

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

Returns:int

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

getProtocolback to summary
public String getProtocol()

The protocol part of the Service URL.

Returns:String

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

getURLPathback to summary
public 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:String

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

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

indexOfback to summary
private static int indexOf(String s, char c, int fromIndex)
indexOfFirstNotInSetback to summary
private static int indexOfFirstNotInSet(String s, BitSet set, int fromIndex)
isNumericIPv6Addressback to summary
private static boolean isNumericIPv6Address(String s)
readObjectback to summary
private void readObject(ObjectInputStream inputStream) throws IOException, ClassNotFoundException
toStringback to summary
public String toString()

Overrides java.lang.Object.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(). 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() in its shortest decimal form. If the value is zero, it is omitted.

Returns:String

the string representation of this Service URL.

validateback to summary
private void validate(String proto, String h, int p, String url) throws MalformedURLException
validateback to summary
private void validate() throws MalformedURLException
validateHostback to summary
private static void validateHost(String h, int port) throws MalformedURLException