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 FetchingEventRelay

java.lang.Object
  extended by javax.management.event.FetchingEventRelay
All Implemented Interfaces:
EventRelay

public class FetchingEventRelay
extends Object
implements EventRelay

This class is an implementation of the EventRelay interface. It calls fetchNotifications(String, long, int, long) to get notifications and then forwards them to an EventReceiver object.

A fetchExecutor parameter can be specified when creating a FetchingEventRelay. That is then the Executor that will be used to perform the fetchNotifications operation. Only one job at a time will be submitted to this Executor. The behavior is unspecified if Executor.execute(java.lang.Runnable) throws an exception, including RejectedExecutionException.

Since:
JMX 2.0

Field Summary
Modifier and Type Field and Description
static int DEFAULT_BUFFER_SIZE
          The default buffer size: 1000.
static int DEFAULT_MAX_NOTIFICATIONS
          The default maximum notifications to fetch every time: 1000.
static long DEFAULT_WAITING_TIMEOUT
          The default waiting timeout: 60000L in millseconds when fetching notifications from an EventClientDelegateMBean.
 
Constructor Summary
Constructor and Description
FetchingEventRelay(EventClientDelegateMBean delegate)
          Constructs a default FetchingEventRelay object by using the default configuration: DEFAULT_BUFFER_SIZE, DEFAULT_WAITING_TIMEOUT DEFAULT_MAX_NOTIFICATIONS.
FetchingEventRelay(EventClientDelegateMBean delegate, Executor fetchExecutor)
          Constructs a FetchingEventRelay object by using the default configuration: DEFAULT_BUFFER_SIZE, DEFAULT_WAITING_TIMEOUT DEFAULT_MAX_NOTIFICATIONS, with a user-specific executor to do the fetching.
FetchingEventRelay(EventClientDelegateMBean delegate, int bufferSize, long timeout, int maxNotifs, Executor fetchExecutor)
          Constructs a FetchingEventRelay object with user-specific configuration and executor to fetch notifications via the EventClientDelegateMBean.
FetchingEventRelay(EventClientDelegateMBean delegate, int bufferSize, long timeout, int maxNotifs, Executor fetchExecutor, String forwarderName, Object[] params, String[] sig)
          Constructs a FetchingEventRelay object with user-specific configuration and executor to fetch notifications via the EventClientDelegateMBean.
 
Method Summary
Modifier and Type Method and Description
 String getClientId()
          Returns an identifier that is used by this EventRelay to identify the client when communicating with the EventClientDelegateMBean.
 void setEventReceiver(EventReceiver eventReceiver)
          This method is called by EventClient to register a callback to receive notifications from an EventClientDelegateMBean object.
 void stop()
          Stops receiving and forwarding notifications and performs any necessary cleanup.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_BUFFER_SIZE

public static final int DEFAULT_BUFFER_SIZE
The default buffer size: 1000.

See Also:
Constant Field Values

DEFAULT_WAITING_TIMEOUT

public static final long DEFAULT_WAITING_TIMEOUT
The default waiting timeout: 60000L in millseconds when fetching notifications from an EventClientDelegateMBean.

See Also:
Constant Field Values

DEFAULT_MAX_NOTIFICATIONS

public static final int DEFAULT_MAX_NOTIFICATIONS
The default maximum notifications to fetch every time: 1000.

See Also:
Constant Field Values
Constructor Detail

FetchingEventRelay

public FetchingEventRelay(EventClientDelegateMBean delegate)
                   throws IOException,
                          MBeanException
Constructs a default FetchingEventRelay object by using the default configuration: DEFAULT_BUFFER_SIZE, DEFAULT_WAITING_TIMEOUT DEFAULT_MAX_NOTIFICATIONS. A single thread is created to do fetching.

Parameters:
delegate - The EventClientDelegateMBean to work with.
Throws:
IOException - If failed to work with the delegate.
MBeanException - if unable to add a client to the remote EventClientDelegateMBean (see EventClientDelegateMBean.addClient).
IllegalArgumentException - If delegate is null.

FetchingEventRelay

public FetchingEventRelay(EventClientDelegateMBean delegate,
                          Executor fetchExecutor)
                   throws IOException,
                          MBeanException
Constructs a FetchingEventRelay object by using the default configuration: DEFAULT_BUFFER_SIZE, DEFAULT_WAITING_TIMEOUT DEFAULT_MAX_NOTIFICATIONS, with a user-specific executor to do the fetching.

Parameters:
delegate - The EventClientDelegateMBean to work with.
fetchExecutor - Used to do the fetching. A new thread is created if null.
Throws:
IOException - If failed to work with the delegate.
MBeanException - if unable to add a client to the remote EventClientDelegateMBean (see EventClientDelegateMBean.addClient).
IllegalArgumentException - If delegate is null.

FetchingEventRelay

public FetchingEventRelay(EventClientDelegateMBean delegate,
                          int bufferSize,
                          long timeout,
                          int maxNotifs,
                          Executor fetchExecutor)
                   throws IOException,
                          MBeanException
Constructs a FetchingEventRelay object with user-specific configuration and executor to fetch notifications via the EventClientDelegateMBean.

Parameters:
delegate - The EventClientDelegateMBean to work with.
bufferSize - The buffer size for saving notifications in EventClientDelegateMBean before they are fetched.
timeout - The waiting time in millseconds when fetching notifications from an EventClientDelegateMBean.
maxNotifs - The maximum notifications to fetch every time.
fetchExecutor - Used to do the fetching. A new thread is created if null.
Throws:
IOException - if failed to communicate with the delegate.
MBeanException - if unable to add a client to the remote EventClientDelegateMBean (see EventClientDelegateMBean.addClient).
IllegalArgumentException - If delegate is null.

FetchingEventRelay

public FetchingEventRelay(EventClientDelegateMBean delegate,
                          int bufferSize,
                          long timeout,
                          int maxNotifs,
                          Executor fetchExecutor,
                          String forwarderName,
                          Object[] params,
                          String[] sig)
                   throws IOException,
                          MBeanException
Constructs a FetchingEventRelay object with user-specific configuration and executor to fetch notifications via the EventClientDelegateMBean.

Parameters:
delegate - The EventClientDelegateMBean to work with.
bufferSize - The buffer size for saving notifications in EventClientDelegateMBean before they are fetched.
timeout - The waiting time in millseconds when fetching notifications from an EventClientDelegateMBean.
maxNotifs - The maximum notifications to fetch every time.
fetchExecutor - Used to do the fetching.
forwarderName - the class name of a user specific EventForwarder to create in server to forward notifications to this object. The class should be a subclass of the class FetchingEventForwarder.
params - the parameters passed to create forwarderName
sig - the signature of the params
Throws:
IOException - if failed to communicate with the delegate.
MBeanException - if unable to add a client to the remote EventClientDelegateMBean (see EventClientDelegateMBean.addClient).
IllegalArgumentException - if bufferSize or maxNotifs is less than 1
NullPointerException - if delegate is null.
Method Detail

setEventReceiver

public void setEventReceiver(EventReceiver eventReceiver)
Description copied from interface: EventRelay
This method is called by EventClient to register a callback to receive notifications from an EventClientDelegateMBean object. A null value is allowed, which means that the EventClient suspends reception of notifications, so that the EventRelay can decide to stop receiving notifications from its EventForwarder.

Specified by:
setEventReceiver in interface EventRelay
Parameters:
eventReceiver - An EventClient callback to receive events.

getClientId

public String getClientId()
Description copied from interface: EventRelay
Returns an identifier that is used by this EventRelay to identify the client when communicating with the EventClientDelegateMBean.

This identifier is obtained by calling EventClientDelegateMBean.addClient.

It is the EventRelay that calls EventClientDelegateMBean to obtain the client identifier because it is the EventRelay that decides how to get notifications from the EventClientDelegateMBean, by creating the appropriate EventForwarder.

Specified by:
getClientId in interface EventRelay
Returns:
A client identifier.

stop

public void stop()
Description copied from interface: EventRelay
Stops receiving and forwarding notifications and performs any necessary cleanup. After calling this method, the EventClient will never call any other methods of this object.

Specified by:
stop in interface EventRelay
See Also:
EventClient.close()

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.