Factory to create JMX API connector clients. There are no instances of this class.
Connections are usually made using the connect method of this class. More
advanced applications can separate the creation of the connector
client, using newJMXConnector and the establishment of the connection itself, using
JMXConnector#connect(Map).
Each client is created by an instance of JMXConnectorProvider. This instance is found as follows. Suppose
the given JMXServiceURL looks like
"service:jmx:protocol:remainder".
Then the factory will attempt to find the appropriate 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:
environment parameter to newJMXConnector contains the
key jmx.remote.protocol.provider.pkgs then the
associated value is the provider package list.
jmx.remote.protocol.provider.pkgs exists, then its value
is the 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 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 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 java., an java. 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, 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 whose cause indicates the underlying
exception, as follows:
ClassNotFoundException, that is the
cause;
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 a
MalformedURLException if there is none. An
implementation may choose to find providers by other means. For
example, it may support service providers,
where the service interface is JMXConnectorProvider.
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
newJMXConnector method is the result of calling newJMXConnector
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., 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.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static interface | JMXConnectorFactory.
A factory function that can create a connector from a provider. |
| private static class | JMXConnectorFactory.
An instance of ProviderFinder is used to traverse a
|
| Modifier and Type | Field and Description |
|---|---|
| public static final String | DEFAULT_CLASS_LOADER
Name of the attribute that specifies the default class loader. |
| private static final ClassLogger | |
| public static final String | PROTOCOL_PROVIDER_CLASS_LOADER
Name of the attribute that specifies the class loader for loading protocol providers. |
| private static final String | |
| 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. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static JMXConnector | connect(JMXServiceURL
the address of the connector server to
connect to. serviceURL)Creates a connection to the connector server at the given address. |
| public static JMXConnector | Returns: aJMXConnector representing the newly-made
connection. Each successful call to this method produces a
different object.the address of the connector server to connect to. serviceURL, Map<String, ?> 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)environment are not changed by this call.Creates a connection to the connector server at the given address. |
| private static JMXConnector | Returns: an instance of JMXConnector if a provider was found from which one could be instantiated,null otherwise.The ClassLoader to use when looking up an implementation
of the service. If null, then only installed services will be
considered. loader, JMXServiceURL The JMXServiceURL of the connector for which a provider is
requested. url, Map<String, ?> map, Predicate<ServiceLoader.A filter used to exclude or return provider
implementations. Typically the filter will either exclude
system services (system default implementations) or only
retain those.
This can allow to first look for custom implementations (e.g.
deployed on the CLASSPATH with META-INF/services) and
then only default to system implementations. filterCreates a JMXConnector from the first JMXConnectorProvider service supporting the given url that can be loaded from the given loader. |
| pack-priv static <P, C> C | Returns: an instance ofC if a provider P was found from
which one could be instantiated, null otherwise.The service type for which an implementation
should be looked up from the providerClass, ClassLoader ServiceLoader. This will
be either JMXConnectorProvider.class or
JMXConnectorServerProvider.classThe ClassLoader to use when looking up an implementation
of the service. If null, then only installed services will be
considered. loader, JMXServiceURL The JMXServiceURL of the connector for which a provider is
requested. url, Predicate<ServiceLoader.A filter used to exclude or return provider
implementations. Typically the filter will either exclude
system services (system default implementations) or only
retain those.
This can allow to first look for custom implementations (e.g.
deployed on the CLASSPATH with META-INF/services) and
then only default to system implementations. filter,A functional factory that can attempt to create an
instance of connector factoryC from a provider P.
Typically, this is a simple wrapper over JMXConnectorProvider::newJMXConnector or JMXConnectorProviderServer::newJMXConnectorServer.Creates a connector from a provider loaded from the ServiceLoader. |
| pack-priv static <T> T | getProvider(JMXServiceURL serviceURL, final Map<String, Object> environment, String providerClassName, Class<T> targetInterface, final ClassLoader loader)
|
| pack-priv static <T> T | getProvider(String protocol, String pkgs, ClassLoader loader, String providerClassName, Class<T> targetInterface)
|
| pack-priv static boolean | Returns: true if this provider is a default system provider.the provider to test. providerChecks whether the given provider is our system provider for the RMI connector. |
| private static <K, V> Map | |
| private static <K> Map | |
| public static JMXConnector | Returns: aJMXConnector representing the new
connector client. Each successful call to this method produces
a different object.the address of the connector server to connect to. serviceURL, Map<String, ?> 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)environment are not changed by this call.Creates a connector client for the connector server at the given address. |
| private static String | |
| pack-priv static ClassLoader | |
| private static String | |
| private static ClassLoader |
| DEFAULT_CLASS_LOADER | back to summary |
|---|---|
| public static final 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 | |
| logger | back to summary |
|---|---|
| private static final ClassLogger logger | |
| PROTOCOL_PROVIDER_CLASS_LOADER | back to summary |
|---|---|
| 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 | |
| PROTOCOL_PROVIDER_DEFAULT_PACKAGE | back to summary |
|---|---|
| private static final String PROTOCOL_PROVIDER_DEFAULT_PACKAGE | |
| PROTOCOL_PROVIDER_PACKAGES | back to summary |
|---|---|
| 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 ( | |
| JMXConnectorFactory | back to summary |
|---|---|
| private JMXConnectorFactory() There are no instances of this class. | |
| connect | back to summary |
|---|---|
| public static JMXConnector connect(JMXServiceURL serviceURL) throws IOException Creates a connection to the connector server at the given address. This method is equivalent to
| |
| connect | back to summary |
|---|---|
| public static JMXConnector connect(JMXServiceURL serviceURL, Map<String, ?> environment) throws 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);
| |
| getConnectorAsService | back to summary |
|---|---|
| private static JMXConnector getConnectorAsService(ClassLoader loader, JMXServiceURL url, Map<String, ?> map, Predicate<ServiceLoader. Creates a JMXConnector from the first JMXConnectorProvider service supporting the given url that can be loaded from the given loader. Parses the list of JMXConnectorProvider services that can be loaded from the given loader, only retaining those that satisfy the given filter. Then for each provider, attempts to create a new JMXConnector. The first JMXConnector successfully created is returned. The filter predicate is usually used to either exclude system providers or only retain system providers (see isSystemProvider(...) above).
| |
| getConnectorAsService | back to summary |
|---|---|
| pack-priv static <P, C> C getConnectorAsService(Class<P> providerClass, ClassLoader loader, JMXServiceURL url, Predicate<ServiceLoader. Creates a connector from a provider loaded from the ServiceLoader.
The pair (P,C) will be either one of:
| |
| getProvider | back to summary |
|---|---|
| pack-priv static <T> T getProvider(JMXServiceURL serviceURL, final Map<String, Object> environment, String providerClassName, Class<T> targetInterface, final ClassLoader loader) throws IOException | |
| getProvider | back to summary |
|---|---|
| pack-priv static <T> T getProvider(String protocol, String pkgs, ClassLoader loader, String providerClassName, Class<T> targetInterface) throws IOException | |
| isSystemProvider | back to summary |
|---|---|
| pack-priv static boolean isSystemProvider(ServiceLoader. Checks whether the given provider is our system provider for the RMI connector. If providers for additional protocols are added in the future then the name of their modules may need to be added here. System providers will be loaded only if no other provider is found.
| |
| newHashMap | back to summary |
|---|---|
| private static <K, V> Map | |
| newHashMap | back to summary |
|---|---|
| private static <K> Map | |
| newJMXConnector | back to summary |
|---|---|
| public static JMXConnector newJMXConnector(JMXServiceURL serviceURL, Map<String, ?> environment) throws IOException Creates a connector client for the connector server at the
given address. The resultant client is not connected until its
| |
| protocol2package | back to summary |
|---|---|
| private static String protocol2package(String protocol) | |
| resolveClassLoader | back to summary |
|---|---|
| pack-priv static ClassLoader resolveClassLoader(Map<String, ?> environment) | |
| resolvePkgs | back to summary |
|---|---|
private static String resolvePkgs(Map<String, ?> env) throws JMXProviderException
| |
| wrap | back to summary |
|---|---|
| private static ClassLoader wrap(final ClassLoader parent) | |
| Modifier and Type | Method and Description |
|---|---|
| public C |
| apply | back to summary |
|---|---|
| public C apply(P provider) throws Exception | |
Stream<Provider<P>> and find the first implementation of P
that supports creating a connector C from the given JMXServiceURL.
The pair (P,C) will be either one of:
a. (JMXConnectorProvider, JMXConnector) or
b. (JMXConnectorServerProvider, JMXConnectorServer)
The first connector successfully created while traversing the stream is stored in the ProviderFinder instance. After that, the ProviderFinder::test method, if called, will always return false, skipping the remaining providers.
An instance of ProviderFinder is always expected to be used in conjunction with Stream::findFirst, so that the stream traversal is stopped as soon as a matching provider is found.
At the end of the stream traversal, the ProviderFinder::get method can be used to obtain the connector instance (an instance of C) that was created. If no connector could be created, and an exception was encountered while traversing the stream and attempting to create the connector, then that exception will be thrown by ProviderFinder::get, wrapped, if needed, inside an IOException.
If any JMXProviderException is encountered while traversing the stream and attempting to create the connector, that exception will be wrapped in an UncheckedIOException and thrown immediately within the stream, thus interrupting the traversal.
If no matching provider was found (no provider found or attempting factory.apply always returned null or threw a MalformedURLException, indicating the provider didn't support the protocol asked for by the JMXServiceURL), then ProviderFinder::get will simply return null.
| Modifier and Type | Field and Description |
|---|---|
| private C | |
| private IOException | |
| pack-priv final JMXConnectorFactory. | |
| pack-priv final JMXServiceURL |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv C | Returns: an instance ofC if a provider was found from
which C could be instantiated, null otherwise.Returns an instance of |
| public boolean | Returns: true for the first provider sp for which
C could be instantiated, false otherwise.a candidate provider for instantiating spC.Implements java. Returns |
| connection | back to summary |
|---|---|
| private C connection | |
| exception | back to summary |
|---|---|
| private IOException exception | |
| factory | back to summary |
|---|---|
| pack-priv final JMXConnectorFactory. | |
| url | back to summary |
|---|---|
| pack-priv final JMXServiceURL url | |
| ProviderFinder | back to summary |
|---|---|
| pack-priv ProviderFinder(JMXConnectorFactory. | |
| get | back to summary |
|---|---|
| pack-priv C get() throws IOException Returns an instance of
| |
| test | back to summary |
|---|---|
| public boolean test(ServiceLoader. Implements java. Returns
| |