- All Implemented Interfaces:
- Closeable,- Serializable,- AutoCloseable,- JMXAddressable,- JMXConnector
A connection to a remote RMI connector.  Usually, such
 connections are made using JMXConnectorFactory.
 However, specialized applications can use this class directly, for
 example with an RMIServer stub obtained without going
 through JNDI.
- Since:
- 1.5
- See Also:
- 
Field SummaryFields declared in interface javax.management.remote.JMXConnectorCREDENTIALS
- 
Constructor SummaryConstructorsConstructorDescriptionRMIConnector(JMXServiceURL url, Map<String, ?> environment) Constructs anRMIConnectorthat will connect the RMI connector server with the given address.RMIConnector(RMIServer rmiServer, Map<String, ?> environment) Constructs anRMIConnectorusing the given RMI stub.
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddConnectionNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) Adds a listener to be informed of changes in connection status.voidclose()Closes the client connection to its server.voidconnect()Establishes the connection to the connector server.voidEstablishes the connection to the connector server.The address of this connector.Gets this connection's ID from the connector server.Returns anMBeanServerConnectionobject representing a remote MBean server.getMBeanServerConnection(Subject delegationSubject) Returns anMBeanServerConnectionobject representing a remote MBean server on which operations are performed on behalf of the supplied delegation subject.voidRemoves a listener from the list to be informed of changes in status.voidremoveConnectionNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) Removes a listener from the list to be informed of changes in status.toString()Returns a string representation of this object.
- 
Constructor Details- 
RMIConnectorConstructs an RMIConnectorthat will connect the RMI connector server with the given address.The address can refer directly to the connector server, using the following syntax: service:jmx:rmi://[host[:port]]/stub/encoded-stub (Here, the square brackets []are not part of the address but indicate that the host and port are optional.)The address can instead indicate where to find an RMI stub through JNDI, using the following syntax: service:jmx:rmi://[host[:port]]/jndi/jndi-name An implementation may also recognize additional address syntaxes, for example: service:jmx:myprotocolname://[host[:port]]/stub/encoded-stub - Parameters:
- url- the address of the RMI connector server.
- environment- additional attributes specifying how to make the connection. For JNDI-based addresses, these attributes can usefully include JNDI attributes recognized by- InitialContext. This parameter can be null, which is equivalent to an empty Map.
- Throws:
- IllegalArgumentException- if- urlis null.
 
- 
RMIConnectorConstructs an RMIConnectorusing the given RMI stub.- Parameters:
- rmiServer- an RMI stub representing the RMI connector server.
- environment- additional attributes specifying how to make the connection. This parameter can be null, which is equivalent to an empty Map.
- Throws:
- IllegalArgumentException- if- rmiServeris null.
 
 
- 
- 
Method Details- 
toStringReturns a string representation of this object. In general, the toStringmethod returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read.
- 
getAddressThe address of this connector. - Specified by:
- getAddressin interface- JMXAddressable
- Returns:
- the address of this connector, or null if it does not have one.
- Since:
- 1.6
 
- 
connectDescription copied from interface:JMXConnectorEstablishes the connection to the connector server. This method is equivalent to connect(null).- Specified by:
- connectin interface- JMXConnector
- Throws:
- IOException- if the connection could not be made because of a communication problem
 
- 
connectDescription copied from interface:JMXConnectorEstablishes the connection to the connector server. If connecthas already been called successfully on this object, calling it again has no effect. If, however,JMXConnector.close()was called afterconnect, the newconnectwill throw anIOException.Otherwise, either connecthas never been called on this object, or it has been called but produced an exception. Then callingconnectwill attempt to establish a connection to the connector server.- Specified by:
- connectin interface- JMXConnector
- Parameters:
- environment- the properties of the connection. Properties in this map override properties in the map specified when the- JMXConnectorwas created, if any. This parameter can be null, which is equivalent to an empty map.
- Throws:
- IOException- if the connection could not be made because of a communication problem
 
- 
getConnectionIdDescription copied from interface:JMXConnectorGets 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. - Specified by:
- getConnectionIdin interface- JMXConnector
- Returns:
- the unique ID of this connection.  This is the same as
 the ID that the connector server includes in its JMXConnectionNotifications. Thepackage descriptiondescribes the conventions for connection IDs.
- Throws:
- IOException- if the connection ID cannot be obtained, for instance because the connection is closed or broken.
 
- 
getMBeanServerConnectionDescription copied from interface:JMXConnectorReturns an MBeanServerConnectionobject representing a remote MBean server. For a givenJMXConnector, two successful calls to this method will usually return the sameMBeanServerConnectionobject, 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 anException, the sameExceptionis seen by the client. If the MBean server method, or the attempt to call it, produces anError, theErroris wrapped in aJMXServerErrorException, which is seen by the client.Calling this method is equivalent to calling getMBeanServerConnection(null)meaning that no delegation subject is specified and that all the operations called on theMBeanServerConnectionmust use the authenticated subject, if any.- Specified by:
- getMBeanServerConnectionin interface- JMXConnector
- Returns:
- an object that implements the
 MBeanServerConnectioninterface by forwarding its methods to the remote MBean server.
- Throws:
- IOException- if a valid- MBeanServerConnectioncannot be created, for instance because the connection to the remote MBean server has not yet been established (with the- connectmethod), or it has been closed, or it has broken.
 
- 
getMBeanServerConnectionDescription copied from interface:JMXConnectorReturns an MBeanServerConnectionobject representing a remote MBean server on which operations are performed on behalf of the supplied delegation subject. For a givenJMXConnectorandSubject, two successful calls to this method will usually return the sameMBeanServerConnectionobject, 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 on behalf of the given delegation subject instead of the authenticated subject. The value returned by the MBean server method is the value returned to the client. If the MBean server method produces anException, the sameExceptionis seen by the client. If the MBean server method, or the attempt to call it, produces anError, theErroris wrapped in aJMXServerErrorException, which is seen by the client.- Specified by:
- getMBeanServerConnectionin interface- JMXConnector
- Parameters:
- delegationSubject- the- Subjecton behalf of which requests will be performed. Can be null, in which case requests will be performed on behalf of the authenticated Subject, if any.
- Returns:
- an object that implements the MBeanServerConnectioninterface by forwarding its methods to the remote MBean server on behalf of a given delegation subject.
- Throws:
- IOException- if a valid- MBeanServerConnectioncannot be created, for instance because the connection to the remote MBean server has not yet been established (with the- connectmethod), or it has been closed, or it has broken.
 
- 
addConnectionNotificationListenerpublic void addConnectionNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) Description copied from interface:JMXConnectorAdds 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 handleNotificationmethod will be called twice for each notification.- Specified by:
- addConnectionNotificationListenerin interface- JMXConnector
- Parameters:
- listener- a listener to receive connection status notifications.
- filter- a filter to select which notifications are to be delivered to the listener, or null if all notifications are to be delivered.
- handback- an object to be given to the listener along with each notification. Can be null.
- See Also:
 
- 
removeConnectionNotificationListenerpublic void removeConnectionNotificationListener(NotificationListener listener) throws ListenerNotFoundException Description copied from interface:JMXConnectorRemoves 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. - Specified by:
- removeConnectionNotificationListenerin interface- JMXConnector
- Parameters:
- listener- a listener to receive connection status notifications.
- Throws:
- ListenerNotFoundException- if the listener is not registered with this- JMXConnector.
- See Also:
 
- 
removeConnectionNotificationListenerpublic void removeConnectionNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundException Description copied from interface:JMXConnectorRemoves 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. - Specified by:
- removeConnectionNotificationListenerin interface- JMXConnector
- Parameters:
- listener- a listener to receive connection status notifications.
- filter- a filter to select which notifications are to be delivered to the listener. Can be null.
- handback- an object to be given to the listener along with each notification. Can be null.
- Throws:
- ListenerNotFoundException- if the listener is not registered with this- JMXConnector, or is not registered with the given filter and handback.
- See Also:
 
- 
closeDescription copied from interface:JMXConnectorCloses the client connection to its server. Any ongoing or new request using the MBeanServerConnection returned by JMXConnector.getMBeanServerConnection()will get anIOException.If closehas already been called successfully on this object, calling it again has no effect. Ifclosehas 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 caseclosewill 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. - Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Specified by:
- closein interface- JMXConnector
- Throws:
- 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.
 
 
-