javax.management.remote
Class JMXConnectorFactory

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by javax.management.remote.JMXConnectorFactory

public class JMXConnectorFactory
extends Object sample code for java.lang.Object definition code for java.lang.Object

Factory to create JMX API connector clients. There are no instances of this class.

Connections are usually made using the connect sample code for javax.management.remote.JMXConnectorFactory.connect(javax.management.remote.JMXServiceURL) definition code for javax.management.remote.JMXConnectorFactory.connect(javax.management.remote.JMXServiceURL) method of this class. More advanced applications can separate the creation of the connector client, using newJMXConnector sample code for javax.management.remote.JMXConnectorFactory.newJMXConnector(javax.management.remote.JMXServiceURL, java.util.Map) definition code for javax.management.remote.JMXConnectorFactory.newJMXConnector(javax.management.remote.JMXServiceURL, java.util.Map) and the establishment of the connection itself, using JMXConnector.connect(Map) sample code for javax.management.remote.JMXConnector.connect(java.util.Map) definition code for javax.management.remote.JMXConnector.connect(java.util.Map) .

Each client is created by an instance of JMXConnectorProvider sample code for javax.management.remote.JMXConnectorProvider definition code for javax.management.remote.JMXConnectorProvider . This instance is found as follows. Suppose the given JMXServiceURL sample code for javax.management.remote.JMXServiceURL definition code for javax.management.remote.JMXServiceURL looks like "service:jmx:protocol:remainder". Then the factory will attempt to find the appropriate JMXConnectorProvider sample code for javax.management.remote.JMXConnectorProvider definition code for javax.management.remote.JMXConnectorProvider for protocol. Each occurrence of the character + or - in protocol is replaced by . or _, respectively.

A provider package list is searched for as follows:

  1. If the environment parameter to newJMXConnector sample code for javax.management.remote.JMXConnectorFactory.newJMXConnector(javax.management.remote.JMXServiceURL, java.util.Map) definition code for javax.management.remote.JMXConnectorFactory.newJMXConnector(javax.management.remote.JMXServiceURL, java.util.Map) contains the key jmx.remote.protocol.provider.pkgs then the associated value is the provider package list.
  2. Otherwise, if the system property jmx.remote.protocol.provider.pkgs exists, then its value is the provider package list.
  3. Otherwise, there is no provider package list.

The provider package list is a string that is interpreted as a list of non-empty Java package names separated by vertical bars (|). If the string is empty, then so is the provider package list. If the provider package list is not a String, or if it contains an element that is an empty string, a JMXProviderException sample code for javax.management.remote.JMXProviderException definition code for javax.management.remote.JMXProviderException is thrown.

If the provider package list exists and is not empty, then for each element pkg of the list, the factory will attempt to load the class

pkg.protocol.ClientProvider

If the environment parameter to newJMXConnector sample code for javax.management.remote.JMXConnectorFactory.newJMXConnector(javax.management.remote.JMXServiceURL, java.util.Map) definition code for javax.management.remote.JMXConnectorFactory.newJMXConnector(javax.management.remote.JMXServiceURL, java.util.Map) contains the key jmx.remote.protocol.provider.class.loader then the associated value is the class loader to use to load the provider. If the associated value is not an instance of ClassLoader sample code for java.lang.ClassLoader definition code for java.lang.ClassLoader , an IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException is thrown.

If the jmx.remote.protocol.provider.class.loader key is not present in the environment parameter, the calling thread's context class loader is used.

If the attempt to load this class produces a ClassNotFoundException sample code for java.lang.ClassNotFoundException definition code for java.lang.ClassNotFoundException , the search for a handler continues with the next element of the list.

Otherwise, a problem with the provider found is signalled by a JMXProviderException sample code for javax.management.remote.JMXProviderException definition code for javax.management.remote.JMXProviderException whose cause sample code for javax.management.remote.JMXProviderException.getCause() definition code for javax.management.remote.JMXProviderException.getCause() indicates the underlying exception, as follows:

If no provider is found by the above steps, including the default case where there is no provider package list, then the implementation will use its own provider for protocol, or it will throw a MalformedURLException if there is none. An implementation may choose to find providers by other means. For example, it may support the JAR conventions for service providers, where the service interface is JMXConnectorProvider.

Every implementation must support the RMI connector protocols, specified with the string rmi or iiop.

Once a provider is found, the result of the newJMXConnector method is the result of calling newJMXConnector sample code for javax.management.remote.JMXConnectorProvider.newJMXConnector(javax.management.remote.JMXServiceURL, java.util.Map) definition code for javax.management.remote.JMXConnectorProvider.newJMXConnector(javax.management.remote.JMXServiceURL, java.util.Map) on the provider.

The Map parameter passed to the JMXConnectorProvider is a new read-only Map that contains all the entries that were in the environment parameter to JMXConnectorFactory.newJMXConnector sample code for javax.management.remote.JMXConnectorFactory.newJMXConnector(javax.management.remote.JMXServiceURL, java.util.Map) definition code for javax.management.remote.JMXConnectorFactory.newJMXConnector(javax.management.remote.JMXServiceURL, java.util.Map) , if there was one. Additionally, if the jmx.remote.protocol.provider.class.loader key is not present in the environment parameter, it is added to the new read-only Map. The associated value is the calling thread's context class loader.

Since:
1.5

Field Summary
static String sample code for java.lang.String definition code for java.lang.String DEFAULT_CLASS_LOADER sample code for javax.management.remote.JMXConnectorFactory.DEFAULT_CLASS_LOADER definition code for javax.management.remote.JMXConnectorFactory.DEFAULT_CLASS_LOADER
          Name of the attribute that specifies the default class loader.
static String sample code for java.lang.String definition code for java.lang.String PROTOCOL_PROVIDER_CLASS_LOADER sample code for javax.management.remote.JMXConnectorFactory.PROTOCOL_PROVIDER_CLASS_LOADER definition code for javax.management.remote.JMXConnectorFactory.PROTOCOL_PROVIDER_CLASS_LOADER
          Name of the attribute that specifies the class loader for loading protocol providers.
static String sample code for java.lang.String definition code for java.lang.String PROTOCOL_PROVIDER_PACKAGES sample code for javax.management.remote.JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES definition code for javax.management.remote.JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES
          Name of the attribute that specifies the provider packages that are consulted when looking for the handler for a protocol.
 
Method Summary
static JMXConnector sample code for javax.management.remote.JMXConnector definition code for javax.management.remote.JMXConnector connect sample code for javax.management.remote.JMXConnectorFactory.connect(javax.management.remote.JMXServiceURL) definition code for javax.management.remote.JMXConnectorFactory.connect(javax.management.remote.JMXServiceURL) (JMXServiceURL sample code for javax.management.remote.JMXServiceURL definition code for javax.management.remote.JMXServiceURL  serviceURL)
          Creates a connection to the connector server at the given address.
static JMXConnector sample code for javax.management.remote.JMXConnector definition code for javax.management.remote.JMXConnector connect sample code for javax.management.remote.JMXConnectorFactory.connect(javax.management.remote.JMXServiceURL, java.util.Map) definition code for javax.management.remote.JMXConnectorFactory.connect(javax.management.remote.JMXServiceURL, java.util.Map) (JMXServiceURL sample code for javax.management.remote.JMXServiceURL definition code for javax.management.remote.JMXServiceURL  serviceURL, Map sample code for java.util.Map definition code for java.util.Map <String sample code for java.lang.String definition code for java.lang.String ,?> environment)
          Creates a connection to the connector server at the given address.
static JMXConnector sample code for javax.management.remote.JMXConnector definition code for javax.management.remote.JMXConnector newJMXConnector sample code for javax.management.remote.JMXConnectorFactory.newJMXConnector(javax.management.remote.JMXServiceURL, java.util.Map) definition code for javax.management.remote.JMXConnectorFactory.newJMXConnector(javax.management.remote.JMXServiceURL, java.util.Map) (JMXServiceURL sample code for javax.management.remote.JMXServiceURL definition code for javax.management.remote.JMXServiceURL  serviceURL, Map sample code for java.util.Map definition code for java.util.Map <String sample code for java.lang.String definition code for java.lang.String ,?> environment)
          Creates a connector client for the connector server at the given address.
 
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() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , 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() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , 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() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , 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)
 

Field Detail

DEFAULT_CLASS_LOADER sample code for javax.management.remote.JMXConnectorFactory.DEFAULT_CLASS_LOADER

public static final String sample code for java.lang.String definition code for java.lang.String  DEFAULT_CLASS_LOADER

Name of the attribute that specifies the default class loader. This class loader is used to deserialize return values and exceptions from remote MBeanServerConnection calls. The value associated with this attribute is an instance of ClassLoader sample code for java.lang.ClassLoader definition code for java.lang.ClassLoader .

See Also:
Constant Field Values

PROTOCOL_PROVIDER_PACKAGES sample code for javax.management.remote.JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES

public static final String sample code for java.lang.String definition code for java.lang.String  PROTOCOL_PROVIDER_PACKAGES

Name of the attribute that specifies the provider packages that are consulted when looking for the handler for a protocol. The value associated with this attribute is a string with package names separated by vertical bars (|).

See Also:
Constant Field Values

PROTOCOL_PROVIDER_CLASS_LOADER sample code for javax.management.remote.JMXConnectorFactory.PROTOCOL_PROVIDER_CLASS_LOADER

public static final String sample code for java.lang.String definition code for java.lang.String  PROTOCOL_PROVIDER_CLASS_LOADER

Name of the attribute that specifies the class loader for loading protocol providers. The value associated with this attribute is an instance of ClassLoader sample code for java.lang.ClassLoader definition code for java.lang.ClassLoader .

See Also:
Constant Field Values
Method Detail

connect sample code for javax.management.remote.JMXConnectorFactory.connect(javax.management.remote.JMXServiceURL) definition code for javax.management.remote.JMXConnectorFactory.connect(javax.management.remote.JMXServiceURL)

public static JMXConnector sample code for javax.management.remote.JMXConnector definition code for javax.management.remote.JMXConnector  connect(JMXServiceURL sample code for javax.management.remote.JMXServiceURL definition code for javax.management.remote.JMXServiceURL  serviceURL)
                            throws IOException sample code for java.io.IOException definition code for java.io.IOException 

Creates a connection to the connector server at the given address.

This method is equivalent to connect(serviceURL, null) sample code for javax.management.remote.JMXConnectorFactory.connect(javax.management.remote.JMXServiceURL, java.util.Map) definition code for javax.management.remote.JMXConnectorFactory.connect(javax.management.remote.JMXServiceURL, java.util.Map) .

Parameters:
serviceURL - the address of the connector server to connect to.
Returns:
a JMXConnector whose connect sample code for javax.management.remote.JMXConnector.connect() definition code for javax.management.remote.JMXConnector.connect() method has been called.
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if serviceURL is null.
IOException sample code for java.io.IOException definition code for java.io.IOException - if the connector client or the connection cannot be made because of a communication problem.
SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException - if the connection cannot be made for security reasons.

connect sample code for javax.management.remote.JMXConnectorFactory.connect(javax.management.remote.JMXServiceURL, java.util.Map<java.lang.String, ?>) definition code for javax.management.remote.JMXConnectorFactory.connect(javax.management.remote.JMXServiceURL, java.util.Map<java.lang.String, ?>)

public static JMXConnector sample code for javax.management.remote.JMXConnector definition code for javax.management.remote.JMXConnector  connect(JMXServiceURL sample code for javax.management.remote.JMXServiceURL definition code for javax.management.remote.JMXServiceURL  serviceURL,
                                   Map sample code for java.util.Map definition code for java.util.Map <String sample code for java.lang.String definition code for java.lang.String ,?> environment)
                            throws IOException sample code for java.io.IOException definition code for java.io.IOException 

Creates a connection to the connector server at the given address.

This method is equivalent to:

 JMXConnector conn = JMXConnectorFactory.newJMXConnector(serviceURL,
                                                         environment);
 conn.connect(environment);
 

Parameters:
serviceURL - the address of the connector server to connect to.
environment - a set of attributes to determine how the connection is made. This parameter can be null. Keys in this map must be Strings. The appropriate type of each associated value depends on the attribute. The contents of environment are not changed by this call.
Returns:
a JMXConnector representing the newly-made connection. Each successful call to this method produces a different object.
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if serviceURL is null.
IOException sample code for java.io.IOException definition code for java.io.IOException - if the connector client or the connection cannot be made because of a communication problem.
SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException - if the connection cannot be made for security reasons.

newJMXConnector sample code for javax.management.remote.JMXConnectorFactory.newJMXConnector(javax.management.remote.JMXServiceURL, java.util.Map<java.lang.String, ?>) definition code for javax.management.remote.JMXConnectorFactory.newJMXConnector(javax.management.remote.JMXServiceURL, java.util.Map<java.lang.String, ?>)

public static JMXConnector sample code for javax.management.remote.JMXConnector definition code for javax.management.remote.JMXConnector  newJMXConnector(JMXServiceURL sample code for javax.management.remote.JMXServiceURL definition code for javax.management.remote.JMXServiceURL  serviceURL,
                                           Map sample code for java.util.Map definition code for java.util.Map <String sample code for java.lang.String definition code for java.lang.String ,?> environment)
                                    throws IOException sample code for java.io.IOException definition code for java.io.IOException 

Creates a connector client for the connector server at the given address. The resultant client is not connected until its connect sample code for javax.management.remote.JMXConnector.connect(java.util.Map) definition code for javax.management.remote.JMXConnector.connect(java.util.Map) method is called.

Parameters:
serviceURL - the address of the connector server to connect to.
environment - a set of attributes to determine how the connection is made. This parameter can be null. Keys in this map must be Strings. The appropriate type of each associated value depends on the attribute. The contents of environment are not changed by this call.
Returns:
a JMXConnector representing the new connector client. Each successful call to this method produces a different object.
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if serviceURL is null.
IOException sample code for java.io.IOException definition code for java.io.IOException - if the connector client cannot be made because of a communication problem.
MalformedURLException sample code for java.net.MalformedURLException definition code for java.net.MalformedURLException - if there is no provider for the protocol in serviceURL.
JMXProviderException sample code for javax.management.remote.JMXProviderException definition code for javax.management.remote.JMXProviderException - if there is a provider for the protocol in serviceURL but it cannot be used for some reason.