com.sun.jdmk.remote.cascading
Class BasicMBeanServerConnectionFactory

java.lang.Object
  extended by com.sun.jdmk.remote.cascading.BasicMBeanServerConnectionFactory
All Implemented Interfaces:
MBeanServerConnectionFactory

public class BasicMBeanServerConnectionFactory
extends Object
implements MBeanServerConnectionFactory

A basic MBeanServerConnectionFactory that wraps a JMXConnector. This implementation does not support transparent reconnection.

Since:
Java DMK 5.1

Constructor Summary
BasicMBeanServerConnectionFactory(JMXConnector connector, Subject delegationSubject)
          Creates a new BasicMBeanServerConnectionFactory for the given connector with the given delegationSubject.
 
Method Summary
 void addConnectionNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
          Adds a listener to be informed of changes in connection status.
 String getConnectionId()
          Gets the current connection's ID from the connector server.
 Subject getDelegationSubject()
          The delegation subject used by the underlying MBeanServerConnection.
 JMXConnector getJMXConnector()
          Returns the underlying JMXConnector used by this object.
 MBeanServerConnection getMBeanServerConnection()
          Returns an MBeanServerConnection object representing a remote MBean server.
static MBeanServerConnectionFactory newInstance(JMXConnector c)
          Creates a new instance of the BasicMBeanServerConnectionFactory.
static MBeanServerConnectionFactory newInstance(JMXConnector c, Subject subject)
          Creates a new instance of the BasicMBeanServerConnectionFactory.
static MBeanServerConnectionFactory newInstance(JMXServiceURL url)
          Creates a new instance of the BasicMBeanServerConnectionFactory.
static MBeanServerConnectionFactory newInstance(JMXServiceURL url, Map map)
          Creates a new instance of the BasicMBeanServerConnectionFactory.
static MBeanServerConnectionFactory newInstance(JMXServiceURL url, Map map, Subject subject)
          Creates a new instance of the BasicMBeanServerConnectionFactory.
 void removeConnectionNotificationListener(NotificationListener listener)
          Removes a listener from the list to be informed of changes in status.
 void removeConnectionNotificationListener(NotificationListener l, NotificationFilter f, Object handback)
          Removes a listener from the list to be informed of changes in status.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicMBeanServerConnectionFactory

public BasicMBeanServerConnectionFactory(JMXConnector connector,
                                         Subject delegationSubject)
Creates a new BasicMBeanServerConnectionFactory for the given connector with the given delegationSubject. The given connector must be connected before the factory can be used.

Parameters:
connector - A JMConnector from which to obtain the MBeanServerConnection.
delegationSubject - A delegation subject used to obtain the underlying MBeanServerConnection.
See Also:
JMXConnector.getMBeanServerConnection(Subject)
Method Detail

getJMXConnector

public JMXConnector getJMXConnector()
Returns the underlying JMXConnector used by this object. This is the connector that was passed to this object's constructor.

Returns:
the underlying JMXConnector.

getDelegationSubject

public final Subject getDelegationSubject()
The delegation subject used by the underlying MBeanServerConnection. This is the Subject that was passed to this object's constructor.

See Also:
JMXConnector.getMBeanServerConnection(Subject)

getMBeanServerConnection

public MBeanServerConnection getMBeanServerConnection()
                                               throws IOException

Returns an MBeanServerConnection object representing a remote MBean server.

This implementation always return the same MBeanServerConnection object. The first time getMBeanServerConnection() is called, this method will obtain a new MBeanServerConnection by calling getJMXConnector().getMBeanServerConnection(getDelegationSubject());

This same MBeanServerConnection will then be returned by subsequent calls. This behaviour can be changed by subclasses.

Specified by:
getMBeanServerConnection in interface MBeanServerConnectionFactory
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.
See Also:
JMXConnector.getMBeanServerConnection(), JMXConnector.getMBeanServerConnection(Subject)

addConnectionNotificationListener

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

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 MBeanServerConnectionFactory
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:
MBeanServerConnectionFactory.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: MBeanServerConnectionFactory

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 MBeanServerConnectionFactory
Parameters:
listener - a listener to receive connection status notifications.
Throws:
ListenerNotFoundException - if the listener is not registered with this JMXConnector.
See Also:
MBeanServerConnectionFactory.removeConnectionNotificationListener(NotificationListener, NotificationFilter, Object), MBeanServerConnectionFactory.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 l,
                                                 NotificationFilter f,
                                                 Object handback)
                                          throws ListenerNotFoundException
Description copied from interface: MBeanServerConnectionFactory

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 MBeanServerConnectionFactory
Parameters:
l - a listener to receive connection status notifications.
f - 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:
MBeanServerConnectionFactory.removeConnectionNotificationListener(NotificationListener), MBeanServerConnectionFactory.addConnectionNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object), NotificationEmitter.removeNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object)

getConnectionId

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

Gets the current 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.

If this MBeanServerConnectionFactory provides access to a remote MBeanServer, then the connection ID will be the ID of the underlying JMXConnector's connection currently in use. The javax.management.remote package description describes the conventions for such connection IDs. Otherwise, the format of the connection ID is undefined.

Specified by:
getConnectionId in interface MBeanServerConnectionFactory
Returns:
the unique ID of the current connection. This is the same as the ID that the connector server includes in its JMXConnectionNotifications.
Throws:
IOException - if the connection ID cannot be obtained, for instance because the connection is closed or broken.

newInstance

public static MBeanServerConnectionFactory newInstance(JMXServiceURL url)
                                                throws IOException
Creates a new instance of the BasicMBeanServerConnectionFactory. This is equivalent to newInstance(url,null,null).

Parameters:
url - A JMX Service URL from which to create a JMXConnector.
Throws:
IOException - if a connected connector cannot be obtained from the JMXConnectorFactory.

newInstance

public static MBeanServerConnectionFactory newInstance(JMXServiceURL url,
                                                       Map map)
                                                throws IOException
Creates a new instance of the BasicMBeanServerConnectionFactory. This is equivalent to newInstance(url,map,null).

Parameters:
url - A JMX Service URL from which to create a JMXConnector.
map - An attributes map passed to the JMXConnectorFactory.connect(JMXServiceURL,Map) method.
Throws:
IOException - if a connected connector cannot be obtained from the JMXConnectorFactory.

newInstance

public static MBeanServerConnectionFactory newInstance(JMXServiceURL url,
                                                       Map map,
                                                       Subject subject)
                                                throws IOException
Creates a new instance of the BasicMBeanServerConnectionFactory. This is equivalent to newInstance(JMXConnectorFactory.connect(url,map),subject).

Parameters:
url - A JMX Service URL from which to create a JMXConnector.
map - An attributes map passed to the JMXConnectorFactory.connect(JMXServiceURL,Map) method.
subject - A subject for the underlying MBeanServerConnection.
Throws:
IOException - if a connected connector cannot be obtained from the JMXConnectorFactory.
See Also:
JMXConnector.getMBeanServerConnection(Subject)

newInstance

public static MBeanServerConnectionFactory newInstance(JMXConnector c)
Creates a new instance of the BasicMBeanServerConnectionFactory. This is equivalent to new BasicMBeanServerConnectionFactory(c,null).

Parameters:
c - A JMXConnector. The connector must be connected before the returned factory can be used.

newInstance

public static MBeanServerConnectionFactory newInstance(JMXConnector c,
                                                       Subject subject)
Creates a new instance of the BasicMBeanServerConnectionFactory. This is equivalent to new BasicMBeanServerConnectionFactory(c,subject).

Parameters:
c - A JMXConnector. The connector must be connected before the returned factory can be used.
subject - A subject for the underlying MBeanServerConnection.
See Also:
JMXConnector.getMBeanServerConnection(Subject)

Open Source build 02
opendmk-1.0-b02 2007.10.01_19:17:46_MEST

Copyright 1998-2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.