|
Java™ Platform Standard Ed. 7 DRAFT ea-b76 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface EventClientDelegateMBean
This interface specifies necessary methods on the MBean server
side for a JMX remote client to manage its notification listeners as
if they are local.
Users do not usually work directly with this MBean; instead, the EventClient class is designed to be used directly by the user.
A default implementation of this interface can be added to an MBean Server in one of several ways.
The most usual is to insert an MBeanServerForwarder between
the Connector Server
and the MBean Server, that will intercept accesses to the Event Client
Delegate MBean and treat them as the real MBean would. This forwarder is
inserted by default with the standard RMI Connector Server, and can also
be created explicitly using EventClientDelegate.newForwarder.
A variant on the above is to replace the MBean Server that is
used locally with a forwarder as described above. Since
MBeanServerForwarder extends MBeanServer, you can use
a forwarder anywhere you would have used the original MBean Server. The
code to do this replacement typically looks something like this:
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); // or whatever mbs = EventClientDelegate.newForwarder(mbs, null); // now use mbs just as you did before, but it will have an EventClientDelegate
The final way is to create an instance of EventClientDelegate
and register it in the MBean Server under the standard name:
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); // or whatever EventClientDelegate ecd = EventClientDelegate.getEventClientDelegate(mbs); mbs.registerMBean(ecd, EventClientDelegateMBean.OBJECT_NAME);
| Modifier and Type | Field and Description |
|---|---|
static int |
EVENT_CLIENT_LISTENER_ID
A unique listener identifier specified for an EventClient. |
static ObjectName |
OBJECT_NAME
The standard ObjectName used to register the default
EventClientDelegateMBean. |
static String |
OBJECT_NAME_STRING
The string representation of OBJECT_NAME. |
| 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. |
Integer[] |
getListenerIds(String clientID)
Returns the identifiers of listeners added or subscribed to with the specified client identifier. |
long |
lease(String clientId,
long timeout)
An EventClient calls this method to keep its clientId
alive in this MBean. |
void |
removeClient(String clientID)
Removes an added client. |
void |
removeListenerOrSubscriber(String clientId,
Integer listenerId)
Removes a listener, to stop receiving notifications. |
| Field Detail |
|---|
static final String OBJECT_NAME_STRING
OBJECT_NAME.
static final ObjectName OBJECT_NAME
ObjectName used to register the default
EventClientDelegateMBean. The name is
"javax.management.event:type=EventClientDelegate".
static final int EVENT_CLIENT_LISTENER_ID
| Method Detail |
|---|
String addClient(String className,
Object[] params,
String[] sig)
throws IOException,
MBeanException
EventClientDelegateMBean with
a user-specified
EventForwarder to forward notifications to the client. The
EventForwarder is created by calling
MBeanServer.instantiate(String, Object[],
String[]).
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
invokedIOException - Reserved for a remote call to throw on the client
side.MBeanException - An exception thrown when creating the user
specified EventForwarder.
String addClient(String className,
ObjectName classLoader,
Object[] params,
String[] sig)
throws IOException,
MBeanException
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.
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
invokedIOException - Reserved for a remote call to throw on the client
side.MBeanException - An exception thrown when creating the user
specified EventForwarder.
void removeClient(String clientID)
throws EventClientNotFoundException,
IOException
EventClientNotFoundException - If the clientId is
not found.IOException - Reserved for a remote call to throw on the client
side.
Integer[] getListenerIds(String clientID)
throws EventClientNotFoundException,
IOException
If no listener is currently registered with the client, an empty array is returned.
clientID - The client identifier with which the listeners are
added or subscribed to.EventClientNotFoundException - If the clientId is
not found.IOException - Reserved for a remote call to throw on the client
side.
Integer addListener(String clientId,
ObjectName name,
NotificationFilter filter)
throws InstanceNotFoundException,
EventClientNotFoundException,
IOException
This method is called by an EventClient to implement the
method EventClient.addNotificationListener(ObjectName,
NotificationListener, NotificationFilter, Object).
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.clientId - The client identifier with which the listener is added.EventClientNotFoundException - Thrown if the clientId is
not found.InstanceNotFoundException - Thrown if the MBean is not found.IOException - Reserved for a remote call to throw on the client
side.
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).
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.IllegalArgumentException - If the name or
listener is null.EventClientNotFoundException - If the client ID is not found.IOException - Reserved for a remote client to throw if
an I/O error occurs.EventConsumer.subscribe(ObjectName, NotificationListener,
NotificationFilter,Object),
removeListenerOrSubscriber(String, Integer)
void removeListenerOrSubscriber(String clientId,
Integer listenerId)
throws InstanceNotFoundException,
ListenerNotFoundException,
EventClientNotFoundException,
IOException
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).
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.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.
NotificationResult fetchNotifications(String clientId,
long startSequenceNumber,
int maxNotifs,
long timeout)
throws EventClientNotFoundException,
IOException
clientId - The client's identifier.startSequenceNumber - The first sequence number to
consider.timeout - The maximum waiting time.maxNotifs - The maximum number of notifications to return.EventClientNotFoundException - Thrown if the clientId is
not found.IllegalArgumentException - if the client was added with an EventForwarder that is not a FetchingEventForwarder.IOException - Reserved for a remote call to throw on the client
side.
long lease(String clientId,
long timeout)
throws IOException,
EventClientNotFoundException
EventClient calls this method to keep its clientId
alive in this MBean. The client will be removed if the lease times out.
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.EventClientNotFoundException - if the clientId is
not found.IOException - reserved for a remote call to throw on the client
side.IllegalArgumentException - if clientId is null or
timeout is negative.
|
Java™ Platform Standard Ed. 7 DRAFT ea-b76 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms.