- java.lang.Object
-
- javax.management.remote.JMXConnectorServerFactory
-
public class JMXConnectorServerFactory extends Object
Factory to create JMX API connector servers. There are no instances of this class.
Each connector server is created by an instance of
JMXConnectorServerProvider. This instance is found as follows. Suppose the givenJMXServiceURLlooks like"service:jmx:protocol:remainder". Then the factory will attempt to find the appropriateJMXConnectorServerProviderforprotocol. Each occurrence of the character+or-inprotocolis replaced by.or_, respectively.A provider package list is searched for as follows:
- If the
environmentparameter tonewJMXConnectorServercontains the keyjmx.remote.protocol.provider.pkgsthen the associated value is the provider package list. - Otherwise, if the system property
jmx.remote.protocol.provider.pkgsexists, then its value is the provider package list. - 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, aJMXProviderExceptionis thrown.If the provider package list exists and is not empty, then for each element
pkgof the list, the factory will attempt to load the classpkg.protocol.ServerProviderIf the
environmentparameter tonewJMXConnectorServercontains the keyjmx.remote.protocol.provider.class.loaderthen the associated value is the class loader to use to load the provider. If the associated value is not an instance ofClassLoader, anIllegalArgumentExceptionis thrown.If the
jmx.remote.protocol.provider.class.loaderkey is not present in theenvironmentparameter, the calling thread's context class loader is used.If the attempt to load this class produces a
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
JMXProviderExceptionwhosecauseindicates the underlying exception, as follows:- if the attempt to load the class produces an exception other
than
ClassNotFoundException, that is the cause; - if
Class.newInstance()for the class produces an exception, that is the cause.
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 aMalformedURLExceptionif there is none. An implementation may choose to find providers by other means. For example, it may support service providers, where the service interface isJMXConnectorServerProvider.Every implementation must support the RMI connector protocol with the default RMI transport, specified with string
rmi.Once a provider is found, the result of the
newJMXConnectorServermethod is the result of callingnewJMXConnectorServeron the provider.The
Mapparameter passed to theJMXConnectorServerProvideris a new read-onlyMapthat contains all the entries that were in theenvironmentparameter toJMXConnectorServerFactory.newJMXConnectorServer, if there was one. Additionally, if thejmx.remote.protocol.provider.class.loaderkey is not present in theenvironmentparameter, it is added to the new read-onlyMap. The associated value is the calling thread's context class loader.- Since:
- 1.5
- If the
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_CLASS_LOADERName of the attribute that specifies the default class loader.static StringDEFAULT_CLASS_LOADER_NAMEName of the attribute that specifies the default class loader MBean name.static StringPROTOCOL_PROVIDER_CLASS_LOADERName of the attribute that specifies the class loader for loading protocol providers.static StringPROTOCOL_PROVIDER_PACKAGESName of the attribute that specifies the provider packages that are consulted when looking for the handler for a protocol.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static JMXConnectorServernewJMXConnectorServer(JMXServiceURL serviceURL, Map<String,?> environment, MBeanServer mbeanServer)Creates a connector server at the given address.
-
-
-
Field Detail
-
DEFAULT_CLASS_LOADER
public static final String DEFAULT_CLASS_LOADER
Name of the attribute that specifies the default class loader. This class loader is used to deserialize objects in requests received from the client, possibly after consulting an MBean-specific class loader. The value associated with this attribute is an instance of
ClassLoader.- See Also:
- Constant Field Values
-
DEFAULT_CLASS_LOADER_NAME
public static final String DEFAULT_CLASS_LOADER_NAME
Name of the attribute that specifies the default class loader MBean name. This class loader is used to deserialize objects in requests received from the client, possibly after consulting an MBean-specific class loader. The value associated with this attribute is an instance of
ObjectName.- See Also:
- Constant Field Values
-
PROTOCOL_PROVIDER_PACKAGES
public static final 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
public static final 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.- See Also:
- Constant Field Values
-
-
Method Detail
-
newJMXConnectorServer
public static JMXConnectorServer newJMXConnectorServer(JMXServiceURL serviceURL, Map<String,?> environment, MBeanServer mbeanServer) throws IOException
Creates a connector server at the given address. The resultant server is not started until its
startmethod is called.- Parameters:
serviceURL- the address of the new connector server. The actual address of the new connector server, as returned by itsgetAddressmethod, will not necessarily be exactly the same. For example, it might include a port number if the original address did not.environment- a set of attributes to control the new connector server's behavior. 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 ofenvironmentare not changed by this call.mbeanServer- the MBean server that this connector server is attached to. Null if this connector server will be attached to an MBean server by being registered in it.- Returns:
- a
JMXConnectorServerrepresenting the new connector server. Each successful call to this method produces a different object. - Throws:
NullPointerException- ifserviceURLis null.IOException- if the connector server cannot be made because of a communication problem.MalformedURLException- if there is no provider for the protocol inserviceURL.JMXProviderException- if there is a provider for the protocol inserviceURLbut it cannot be used for some reason.
-
-