Please note that this documentation is not final and is subject to change.

Java™ Platform
Standard Ed. 7

DRAFT ea-b76

javax.management.event
Class EventClientDelegate

java.lang.Object
  extended by javax.management.event.EventClientDelegate
All Implemented Interfaces:
EventClientDelegateMBean

public class EventClientDelegate
extends Object
implements EventClientDelegateMBean

This is the default implementation of the MBean EventClientDelegateMBean.


Field Summary
Modifier and Type Field and Description
 
Fields inherited from interface javax.management.event.EventClientDelegateMBean
EVENT_CLIENT_LISTENER_ID, OBJECT_NAME, OBJECT_NAME_STRING
 
Method Summary
Modifier and Type Method and Description
 String addClient(String className, Object[] params, String[] sig)
          Adds a new client to the EventClientDelegateMBean with a user-specified EventForwarder to forward notifications to the client.
 String addClient(String className, ObjectName classLoader, Object[] params, String[] sig)
          Adds a new client to the EventClientDelegateMBean with a user-specified EventForwarder to forward notifications to the client.
 Integer addListener(String clientId, ObjectName name, NotificationFilter filter)
          Adds a listener to receive notifications from an MBean and returns a non-negative integer as the identifier of the listener.
 Integer addSubscriber(String clientId, ObjectName name, NotificationFilter filter)
          Subscribes a listener to receive notifications from an MBean or a set of MBeans represented by an ObjectName pattern.
 NotificationResult fetchNotifications(String clientId, long startSequenceNumber, int maxNotifs, long timeout)
          Called by a client to fetch notifications that are to be sent to its listeners.
static EventClientDelegate getEventClientDelegate(MBeanServer server)
          Returns an EventClientDelegate instance for the given MBeanServer.
 Integer[] getListenerIds(String clientId)
          Returns the identifiers of listeners added or subscribed to with the specified client identifier.
static EventClientDelegateMBean getProxy(MBeanServerConnection conn)
          Returns a proxy of the default EventClientDelegateMBean.
 long lease(String clientId, long timeout)
          An EventClient calls this method to keep its clientId alive in this MBean.
static MBeanServerForwarder newForwarder(MBeanServer nextMBS, MBeanServer loopMBS)
          Create a new MBeanServerForwarder that simulates the existence of an EventClientDelegateMBean with the default name.
 void removeClient(String clientId)
          Removes an added client.
 void removeListenerOrSubscriber(String clientId, Integer listenerId)
          Removes a listener, to stop receiving notifications.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getEventClientDelegate

public static EventClientDelegate getEventClientDelegate(MBeanServer server)
Returns an EventClientDelegate instance for the given MBeanServer. Calling this method more than once with the same server argument may return the same object or a different object each time. See EventClientDelegateMBean for an example use of this method.

Parameters:
server - An MBean server instance to work with.
Returns:
An EventClientDelegate instance.
Throws:
NullPointerException - If server is null.

newForwarder

public static MBeanServerForwarder newForwarder(MBeanServer nextMBS,
                                                MBeanServer loopMBS)

Create a new MBeanServerForwarder that simulates the existence of an EventClientDelegateMBean with the default name. This forwarder intercepts MBean requests that are targeted for that MBean and handles them itself. All other requests are forwarded to the next element in the forwarder chain.

Parameters:
nextMBS - the next MBeanServer in the chain of forwarders, which might be another MBeanServerForwarder or a plain MBeanServer. This is the object to which MBeanServer requests that do not concern the EventClientDelegateMBean are sent. It will be the value of getMBeanServer() on the returned object, and can be changed with setMBeanServer. It can be null but must be set to a non-null value before any MBeanServer requests arrive.
loopMBS - the MBeanServer to which requests from the EventClientDelegateMBean should be sent. For example, when you invoke the addListener operation on the EventClientDelegateMBean, it will result in a call to addNotificationListener on this object. If this parameter is null, then these requests will be sent to the newly-created MBeanServerForwarder. Usually the parameter will either be null or will be the result of getSystemMBeanServerForwarder() for the connector server in which this forwarder will be installed.
Returns:
a new MBeanServerForwarder that simulates the existence of an EventClientDelegateMBean.
See Also:
JMXConnectorServer.installStandardForwarders(java.util.Map)

getProxy

public static EventClientDelegateMBean getProxy(MBeanServerConnection conn)
Returns a proxy of the default EventClientDelegateMBean.

Parameters:
conn - An MBeanServerConnection to work with.

addClient

public String addClient(String className,
                        Object[] params,
                        String[] sig)
                 throws MBeanException
Description copied from interface: EventClientDelegateMBean
Adds a new client to the EventClientDelegateMBean with a user-specified EventForwarder to forward notifications to the client. The EventForwarder is created by calling MBeanServer.instantiate(String, Object[], String[]).

Specified by:
addClient in interface EventClientDelegateMBean
Parameters:
className - The class name used to create an EventForwarder.
params - An array containing the parameters of the constructor to be invoked.
sig - An array containing the signature of the constructor to be invoked
Returns:
A client identifier.
Throws:
MBeanException - An exception thrown when creating the user specified EventForwarder.

addClient

public String addClient(String className,
                        ObjectName classLoader,
                        Object[] params,
                        String[] sig)
                 throws MBeanException
Description copied from interface: EventClientDelegateMBean
Adds a new client to the EventClientDelegateMBean with a user-specified EventForwarder to forward notifications to the client. The EventForwarder is created by calling MBeanServer.instantiate(String, ObjectName, Object[], String[]). A user-specified class loader is used to create this EventForwarder.

Specified by:
addClient in interface EventClientDelegateMBean
Parameters:
className - The class name used to create an EventForwarder.
classLoader - An ObjectName registered as a ClassLoader MBean.
params - An array containing the parameters of the constructor to be invoked.
sig - An array containing the signature of the constructor to be invoked
Returns:
A client identifier.
Throws:
MBeanException - An exception thrown when creating the user specified EventForwarder.

getListenerIds

public Integer[] getListenerIds(String clientId)
                         throws IOException,
                                EventClientNotFoundException
Description copied from interface: EventClientDelegateMBean
Returns the identifiers of listeners added or subscribed to with the specified client identifier.

If no listener is currently registered with the client, an empty array is returned.

Specified by:
getListenerIds in interface EventClientDelegateMBean
Parameters:
clientId - The client identifier with which the listeners are added or subscribed to.
Returns:
An array of listener identifiers.
Throws:
IOException - Reserved for a remote call to throw on the client side.
EventClientNotFoundException - If the clientId is not found.

addListener

public Integer addListener(String clientId,
                           ObjectName name,
                           NotificationFilter filter)
                    throws EventClientNotFoundException,
                           InstanceNotFoundException
Adds a listener to receive notifications from an MBean and returns a non-negative integer as the identifier of the listener.

This method is called by an EventClient to implement the method EventClient.addNotificationListener(ObjectName, NotificationListener, NotificationFilter, Object).

The execution of this method includes a call to MBeanServer.addNotificationListener(ObjectName, NotificationListener, NotificationFilter, Object).

Specified by:
addListener in interface EventClientDelegateMBean
Parameters:
clientId - The client identifier with which the listener is added.
name - The name of the MBean onto which the listener should be added.
filter - The filter object. If filter is null, no filtering will be performed before handling notifications.
Returns:
A listener identifier.
Throws:
EventClientNotFoundException - Thrown if the clientId is not found.
InstanceNotFoundException - Thrown if the MBean is not found.

removeListenerOrSubscriber

public void removeListenerOrSubscriber(String clientId,
                                       Integer listenerId)
                                throws InstanceNotFoundException,
                                       ListenerNotFoundException,
                                       EventClientNotFoundException,
                                       IOException
Removes a listener, to stop receiving notifications.

This method is called by an EventClient to execute its methods EventClient.removeNotificationListener(ObjectName, NotificationListener, NotificationFilter, Object), EventClient.removeNotificationListener(ObjectName, NotificationListener), and EventClient.unsubscribe(javax.management.ObjectName, javax.management.NotificationListener).

The execution of this method can include call to MBeanServer.removeNotificationListener(ObjectName, NotificationListener, NotificationFilter, Object).

Specified by:
removeListenerOrSubscriber in interface EventClientDelegateMBean
Parameters:
clientId - The client identifier with which the listener was added.
listenerId - The listener identifier to be removed. This must be an identifier returned by a previous addListener or addSubscriber call.
Throws:
InstanceNotFoundException - if the MBean on which the listener was added no longer exists.
ListenerNotFoundException - if there is no listener with the given listenerId.
EventClientNotFoundException - if the clientId is not found.
IOException - Reserved for a remote call to throw on the client side.

addSubscriber

public Integer addSubscriber(String clientId,
                             ObjectName name,
                             NotificationFilter filter)
                      throws EventClientNotFoundException,
                             IOException

Subscribes a listener to receive notifications from an MBean or a set of MBeans represented by an ObjectName pattern. (It is not an error if no MBeans match the pattern at the time this method is called.)

Returns a non-negative integer as the identifier of the listener.

This method is called by an EventClient to execute its method EventClient.subscribe(ObjectName, NotificationListener, NotificationFilter, Object).

The execution of this method includes a call to MBeanServer.addNotificationListener(ObjectName, NotificationListener, NotificationFilter, Object) for every MBean matching name. If name is an ObjectName pattern, then the execution of this method will include a call to MBeanServer.queryNames(javax.management.ObjectName, javax.management.QueryExp).

Specified by:
addSubscriber in interface EventClientDelegateMBean
Parameters:
clientId - The remote client's identifier.
name - The name of an MBean or an ObjectName pattern representing a set of MBeans to which the listener should listen.
filter - The filter object. If filter is null, no filtering will be performed before notifications are handled.
Returns:
A listener identifier.
Throws:
EventClientNotFoundException - If the client ID is not found.
IOException - Reserved for a remote client to throw if an I/O error occurs.
See Also:
EventConsumer.subscribe(ObjectName, NotificationListener, NotificationFilter,Object), EventClientDelegateMBean.removeListenerOrSubscriber(String, Integer)

fetchNotifications

public NotificationResult fetchNotifications(String clientId,
                                             long startSequenceNumber,
                                             int maxNotifs,
                                             long timeout)
                                      throws EventClientNotFoundException
Description copied from interface: EventClientDelegateMBean
Called by a client to fetch notifications that are to be sent to its listeners.

Specified by:
fetchNotifications in interface EventClientDelegateMBean
Parameters:
clientId - The client's identifier.
startSequenceNumber - The first sequence number to consider.
maxNotifs - The maximum number of notifications to return.
timeout - The maximum waiting time.
Throws:
EventClientNotFoundException - Thrown if the clientId is not found.

removeClient

public void removeClient(String clientId)
                  throws EventClientNotFoundException
Description copied from interface: EventClientDelegateMBean
Removes an added client. Calling this method will remove all listeners added with the client.

Specified by:
removeClient in interface EventClientDelegateMBean
Throws:
EventClientNotFoundException - If the clientId is not found.

lease

public long lease(String clientId,
                  long timeout)
           throws IOException,
                  EventClientNotFoundException
Description copied from interface: EventClientDelegateMBean
An EventClient calls this method to keep its clientId alive in this MBean. The client will be removed if the lease times out.

Specified by:
lease in interface EventClientDelegateMBean
Parameters:
clientId - The client's identifier.
timeout - The time in milliseconds by which the lease is to be extended. The value zero has no special meaning, so it will cause the lease to time out immediately.
Returns:
The new lifetime of the lease in milliseconds. This may be different from the requested time.
Throws:
IOException - reserved for a remote call to throw on the client side.
EventClientNotFoundException - if the clientId is not found.

Java™ Platform
Standard Ed. 7

DRAFT ea-b76

Submit a bug or feature

Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms.