javax.management.remote.generic
Class GenericConnector

java.lang.Object
  extended byjavax.management.remote.generic.GenericConnector
All Implemented Interfaces:
JMXConnector
Direct Known Subclasses:
JMXMPConnector

public class GenericConnector
extends Object
implements JMXConnector

A client connection to a remote JMX API server. This class can use a MessageConnection object to specify the transport for communicating with the server.

User code does not usually instantiate this class. Instead, a JMXConnectorProvider should be added to the JMXConnectorFactory so that users can implicitly instantiate the GenericConnector (or a subclass of it) through the JMXServiceURL provided when connecting.

The specific connector protocol to be used by an instance of this class is specified by attributes in the Map passed to the constructor or the connect method. The attribute MESSAGE_CONNECTION is the standard way to define the transport. An implementation can recognize other attributes to define the transport differently.


Field Summary
static String MESSAGE_CONNECTION
          Name of the attribute that specifies how this connector sends messages to its connector server.
static String OBJECT_WRAPPING
          Name of the attribute that specifies the object wrapping for parameters whose deserialization requires special treatment.
 
Fields inherited from interface javax.management.remote.JMXConnector
CREDENTIALS
 
Constructor Summary
GenericConnector()
          Default no-arg constructor.
GenericConnector(Map env)
          Constructor specifying connection attributes.
 
Method Summary
 void addConnectionNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
          Adds a listener to be informed of changes in connection status.
 void close()
          Closes the client connection to its server.
 void connect()
          Establishes the connection to the connector server.
 void connect(Map env)
          Establishes the connection to the connector server.
 String getConnectionId()
          Gets this connection's ID from the connector server.
 MBeanServerConnection getMBeanServerConnection()
          Returns an MBeanServerConnection object representing a remote MBean server.
 MBeanServerConnection getMBeanServerConnection(Subject delegationSubject)
          Returns an MBeanServerConnection object representing a remote MBean server on which operations are performed on behalf of the supplied delegation subject.
 void removeConnectionNotificationListener(NotificationListener listener)
          Removes a listener from the list to be informed of changes in status.
 void removeConnectionNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
          Removes a listener from the list to be informed of changes in status.
protected  void sendNotification(Notification n)
          Send a notification to the connection listeners.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OBJECT_WRAPPING

public static final String OBJECT_WRAPPING

Name of the attribute that specifies the object wrapping for parameters whose deserialization requires special treatment. The value associated with this attribute, if any, must be an object that implements the interface ObjectWrapping.

See Also:
Constant Field Values

MESSAGE_CONNECTION

public static final String MESSAGE_CONNECTION

Name of the attribute that specifies how this connector sends messages to its connector server. The value associated with this attribute, if any, must be an object that implements the interface MessageConnection.

See Also:
Constant Field Values
Constructor Detail

GenericConnector

public GenericConnector()

Default no-arg constructor.


GenericConnector

public GenericConnector(Map env)

Constructor specifying connection attributes.

Parameters:
env - the attributes of the connection.
Method Detail

connect

public void connect()
             throws IOException
Description copied from interface: JMXConnector

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

Specified by:
connect in interface JMXConnector
Throws:
IOException - if the connection could not be made because of a communication problem.

connect

public void connect(Map env)
             throws IOException
Description copied from interface: JMXConnector

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, JMXConnector.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.

Specified by:
connect in interface JMXConnector
Parameters:
env - 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.
Throws:
IOException - if the connection could not be made because of a communication problem.

getConnectionId

public String getConnectionId()
                       throws IOException
Description copied from interface: JMXConnector

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.

Specified by:
getConnectionId in interface JMXConnector
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.
Throws:
IOException - if the connection ID cannot be obtained, for instance because the connection is closed or broken.

getMBeanServerConnection

public MBeanServerConnection getMBeanServerConnection()
                                               throws IOException
Description copied from interface: JMXConnector

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.

Calling this method is equivalent to calling getMBeanServerConnection(null) meaning that no delegation subject is specified and that all the operations called on the MBeanServerConnection must use the authenticated subject, if any.

Specified by:
getMBeanServerConnection in interface JMXConnector
Returns:
an object that implements the MBeanServerConnection interface by forwarding its methods to the remote MBean server.
Throws:
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.

getMBeanServerConnection

public MBeanServerConnection getMBeanServerConnection(Subject delegationSubject)
                                               throws IOException
Description copied from interface: JMXConnector

Returns an MBeanServerConnection object representing a remote MBean server on which operations are performed on behalf of the supplied delegation subject. For a given JMXConnector and Subject, 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 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 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.

Specified by:
getMBeanServerConnection in interface JMXConnector
Parameters:
delegationSubject - the Subject on 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 MBeanServerConnection interface by forwarding its methods to the remote MBean server on behalf of a given delegation subject.
Throws:
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.

close

public void close()
           throws IOException
Description copied from interface: JMXConnector

Closes the client connection to its server. Any ongoing or new request using the MBeanServerConnection returned by JMXConnector.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.

Specified by:
close in 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.

addConnectionNotificationListener

public void addConnectionNotificationListener(NotificationListener listener,
                                              NotificationFilter filter,
                                              Object handback)
Description copied from interface: JMXConnector

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.

Specified by:
addConnectionNotificationListener in 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:
JMXConnector.removeConnectionNotificationListener(javax.management.NotificationListener), NotificationBroadcaster.addNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object)

removeConnectionNotificationListener

public void removeConnectionNotificationListener(NotificationListener listener)
                                          throws ListenerNotFoundException
Description copied from interface: JMXConnector

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.

Specified by:
removeConnectionNotificationListener in interface JMXConnector
Parameters:
listener - a listener to receive connection status notifications.
Throws:
ListenerNotFoundException - if the listener is not registered with this JMXConnector.
See Also:
JMXConnector.removeConnectionNotificationListener(NotificationListener, NotificationFilter, Object), JMXConnector.addConnectionNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object), NotificationEmitter.removeNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object)

removeConnectionNotificationListener

public void removeConnectionNotificationListener(NotificationListener listener,
                                                 NotificationFilter filter,
                                                 Object handback)
                                          throws ListenerNotFoundException
Description copied from interface: JMXConnector

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.

Specified by:
removeConnectionNotificationListener in 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:
JMXConnector.removeConnectionNotificationListener(NotificationListener), JMXConnector.addConnectionNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object), NotificationEmitter.removeNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object)

sendNotification

protected void sendNotification(Notification n)

Send a notification to the connection listeners. The notification will be sent to every listener added with addConnectionNotificationListener that was not subsequently removed by a removeConnectionNotificationListener, provided the corresponding NotificationFilter matches.

Parameters:
n - the notification to send. This will usually be a JMXConnectionNotification, but an implementation can send other notifications as well.

JMX Remote API Specification 1.0 Final Release
Generated from RI build jmxremote-1_0_1_03-b57.1 2005.02.08_17:20:23_MET

Copyright 2004 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.