Top Description Fields Methods
javax.management.remote

public Interface JMXConnector

extends Closeable
Imports
java.io.Closeable, .IOException, java.util.Map, javax.management.ListenerNotFoundException, .MBeanServerConnection, .NotificationFilter, .NotificationListener, javax.security.auth.Subject

The client end of a JMX API connector. An object of this type can be used to establish a connection to a connector server.

A newly-created object of this type is unconnected. Its connect method must be called before it can be used. However, objects created by JMXConnectorFactory.connect are already connected.

Since
1.5

Field Summary

Modifier and TypeField and Description
public static final String
CREDENTIALS

Name of the attribute that specifies the credentials to send to the connector server during connection.

Method Summary

Modifier and TypeMethod and Description
public void
addConnectionNotificationListener(NotificationListener
a listener to receive connection status notifications.
listener
,
NotificationFilter
a filter to select which notifications are to be delivered to the listener, or null if all notifications are to be delivered.
filter
,
Object
an object to be given to the listener along with each notification. Can be null.
handback
)

Adds a listener to be informed of changes in connection status.

public void
close()

Redeclares java.io.Closeable.close.

Closes the client connection to its server.

public void
connect()

Establishes the connection to the connector server.

public void
connect(Map<String, ?>
the properties of the connection. Properties in this map override properties in the map specified when the JMXConnector was created, if any. This parameter can be null, which is equivalent to an empty map.
env
)

Establishes the connection to the connector server.

public String

Returns:

the unique ID of this connection. This is the same as the ID that the connector server includes in its JMXConnectionNotifications. The package description describes the conventions for connection IDs.
getConnectionId
()

Gets this connection's ID from the connector server.

public MBeanServerConnection

Returns:

an object that implements the MBeanServerConnection interface by forwarding its methods to the remote MBean server.
getMBeanServerConnection
()

Returns an MBeanServerConnection object representing a remote MBean server.

public default MBeanServerConnection

Returns:

an object that implements the MBeanServerConnection interface by forwarding its methods to the remote MBean server.
getMBeanServerConnection
(Subject
must be null.
delegationSubject
)
Deprecated for removal since 21. This method supported the legacy Subject Delegation feature, which has been removed. There is no replacement.

When delegationSubject is null, calling his method is equivalent to calling getMBeanServerConnection().

public void
removeConnectionNotificationListener(NotificationListener
a listener to receive connection status notifications.
listener
)

Removes a listener from the list to be informed of changes in status.

public void
removeConnectionNotificationListener(NotificationListener
a listener to receive connection status notifications.
l
,
NotificationFilter
a filter to select which notifications are to be delivered to the listener. Can be null.
f
,
Object
an object to be given to the listener along with each notification. Can be null.
handback
)

Removes a listener from the list to be informed of changes in status.

Field Detail

CREDENTIALSback to summary
public static final String CREDENTIALS

Name of the attribute that specifies the credentials to send to the connector server during connection. The value associated with this attribute, if any, is a serializable object of an appropriate type for the server's JMXAuthenticator.

Method Detail

addConnectionNotificationListenerback to summary
public void addConnectionNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)

Adds a listener to be informed of changes in connection status. The listener will receive notifications of type JMXConnectionNotification. An implementation can send other types of notifications too.

Any number of listeners can be added with this method. The same listener can be added more than once with the same or different values for the filter and handback. There is no special treatment of a duplicate entry. For example, if a listener is registered twice with no filter, then its handleNotification method will be called twice for each notification.

Parameters
listener:NotificationListener

a listener to receive connection status notifications.

filter:NotificationFilter

a filter to select which notifications are to be delivered to the listener, or null if all notifications are to be delivered.

handback:Object

an object to be given to the listener along with each notification. Can be null.

Exceptions
NullPointerException:
if listener is null.
See Also
removeConnectionNotificationListener, javax.management.NotificationBroadcaster#addNotificationListener
closeback to summary
public void close() throws IOException

Redeclares java.io.Closeable.close.

Closes the client connection to its server. Any ongoing or new request using the MBeanServerConnection returned by getMBeanServerConnection() will get an IOException.

If close has already been called successfully on this object, calling it again has no effect. If close has never been called, or if it was called but produced an exception, an attempt will be made to close the connection. This attempt can succeed, in which case close will return normally, or it can generate an exception.

Closing a connection is a potentially slow operation. For example, if the server has crashed, the close operation might have to wait for a network protocol timeout. Callers that do not want to block in a close operation should do it in a separate thread.

Exceptions
IOException:
if the connection cannot be closed cleanly. If this exception is thrown, it is not known whether the server end of the connection has been cleanly closed.
connectback to summary
public void connect() throws IOException

Establishes the connection to the connector server. This method is equivalent to connect(null).

Exceptions
IOException:
if the connection could not be made because of a communication problem.
SecurityException:
if the connection could not be made for security reasons.
connectback to summary
public void connect(Map<String, ?> env) throws IOException

Establishes the connection to the connector server.

If connect has already been called successfully on this object, calling it again has no effect. If, however, close was called after connect, the new connect will throw an IOException.

Otherwise, either connect has never been called on this object, or it has been called but produced an exception. Then calling connect will attempt to establish a connection to the connector server.

Parameters
env:Map<String, ?>

the properties of the connection. Properties in this map override properties in the map specified when the JMXConnector was created, if any. This parameter can be null, which is equivalent to an empty map.

Exceptions
IOException:
if the connection could not be made because of a communication problem.
SecurityException:
if the connection could not be made for security reasons.
getConnectionIdback to summary
public String getConnectionId() throws IOException

Gets this connection's ID from the connector server. For a given connector server, every connection will have a unique id which does not change during the lifetime of the connection.

Returns:String

the unique ID of this connection. This is the same as the ID that the connector server includes in its JMXConnectionNotifications. The package description describes the conventions for connection IDs.

Exceptions
IOException:
if the connection ID cannot be obtained, for instance because the connection is closed or broken.
getMBeanServerConnectionback to summary
public MBeanServerConnection getMBeanServerConnection() throws IOException

Returns an MBeanServerConnection object representing a remote MBean server. For a given JMXConnector, two successful calls to this method will usually return the same MBeanServerConnection object, though this is not required.

For each method in the returned MBeanServerConnection, calling the method causes the corresponding method to be called in the remote MBean server. The value returned by the MBean server method is the value returned to the client. If the MBean server method produces an Exception, the same Exception is seen by the client. If the MBean server method, or the attempt to call it, produces an Error, the Error is wrapped in a JMXServerErrorException, which is seen by the client.

Returns:MBeanServerConnection

an object that implements the MBeanServerConnection interface by forwarding its methods to the remote MBean server.

Exceptions
IOException:
if a valid MBeanServerConnection cannot be created, for instance because the connection to the remote MBean server has not yet been established (with the connect method), or it has been closed, or it has broken.
getMBeanServerConnectionback to summary
public default MBeanServerConnection getMBeanServerConnection(Subject delegationSubject) throws IOException

Deprecated

for removal since 21.

This method supported the legacy Subject Delegation feature, which has been removed. There is no replacement.

When delegationSubject is null, calling his method is equivalent to calling getMBeanServerConnection().

Implementation Specification

The default implementation of this method throws UnsupportedOperationException if delegationSubject is non-null. Otherwise it calls getMBeanServerConnection().

Parameters
delegationSubject:Subject

must be null.

Returns:MBeanServerConnection

an object that implements the MBeanServerConnection interface by forwarding its methods to the remote MBean server.

Annotations
@Deprecated
since:21
forRemoval:true
Exceptions
IOException:
if a valid MBeanServerConnection cannot be created, for instance because the connection to the remote MBean server has not yet been established (with the connect method), or it has been closed, or it has broken.
UnsupportedOperationException:
if delegationSubject is non-null.
removeConnectionNotificationListenerback to summary
public void removeConnectionNotificationListener(NotificationListener listener) throws ListenerNotFoundException

Removes a listener from the list to be informed of changes in status. The listener must previously have been added. If there is more than one matching listener, all are removed.

Parameters
listener:NotificationListener

a listener to receive connection status notifications.

Exceptions
ListenerNotFoundException:
if the listener is not registered with this JMXConnector.
NullPointerException:
if listener is null.
See Also
removeConnectionNotificationListener(NotificationListener, NotificationFilter, Object), addConnectionNotificationListener, javax.management.NotificationEmitter#removeNotificationListener
removeConnectionNotificationListenerback to summary
public void removeConnectionNotificationListener(NotificationListener l, NotificationFilter f, Object handback) throws ListenerNotFoundException

Removes a listener from the list to be informed of changes in status. The listener must previously have been added with the same three parameters. If there is more than one matching listener, only one is removed.

Parameters
l:NotificationListener

a listener to receive connection status notifications.

f:NotificationFilter

a filter to select which notifications are to be delivered to the listener. Can be null.

handback:Object

an object to be given to the listener along with each notification. Can be null.

Exceptions
ListenerNotFoundException:
if the listener is not registered with this JMXConnector, or is not registered with the given filter and handback.
See Also
removeConnectionNotificationListener(NotificationListener), addConnectionNotificationListener, javax.management.NotificationEmitter#removeNotificationListener