J2EE1.4 SDK

com.sun.appserv.management.base
Interface NotificationService

All Superinterfaces:
AMX, AMXMBeanLogging, java.util.EventListener, NotificationBroadcaster, NotificationEmitter, NotificationListener

public interface NotificationService
extends AMX, NotificationListener

Provides enhanced abilities for working with Notifications. Listens to other MBeans (as configured) and collects the Notifications which can later be retrieved by calling takeNotifications(). The listening is quite powerful; both "listen to" and "don't listen to" ObjectNames or ObjectName patterns may be specified, and are dynamically maintained.

All received Notifications are resent to all listeners on this MBean. This makes it possible to listen to a single MBean for all "interesting" Notifications across many different MBeans, even if these MBeans are dynamically registered and unregistered.

Buffering is also available, via a named buffer facility. Creation of a buffer together with an optional filter allows a caller to buffer Notifications of interest which can later be retrieved as a batch. This facility may be of particular use for clients which disconnect and reconnect.

When a buffer overflows, a notification of type BUFFER_OVERFLOW_NOTIFICATION_TYPE is emitted


Field Summary
static java.lang.String BUFFER_OVERFLOW_NOTIFICATION_TYPE
          When the buffer overflows this Notification is issued.
static java.lang.String J2EE_TYPE
          The j2eeType as returned by AMX.getJ2EEType().
static java.lang.String NEXT_SEQUENCE_NUMBER_KEY
          Key within the Map returned by getNotifications() that yields the Long for the next sequence number.
static java.lang.String NOTIFICATIONS_KEY
          Key within the Map returned by getNotifications() that yields the Notifications[].
static java.lang.String OVERFLOWED_NOTIFICATION_KEY
          Key for accessing the overwritten Notification with the Notification of type BUFFER_OVERFLOW_NOTIFICATION_TYPE.
 
Fields inherited from interface com.sun.appserv.management.base.AMX
FULL_TYPE_DELIM, GROUP_CONFIGURATION, GROUP_JSR77, GROUP_MONITORING, GROUP_OTHER, GROUP_UTILITY, J2EE_TYPE_KEY, NAME_KEY, NO_NAME, NULL_NAME
 
Fields inherited from interface com.sun.appserv.management.base.AMXMBeanLogging
LOG_RECORD_KEY, LOG_RECORD_NOTIFICATION_TYPE
 
Method Summary
 java.lang.Object createBuffer(int bufferSize, NotificationFilter filter)
          Create a new buffer of the specified size.
 void dontListenTo(ObjectName objectName)
          Stop listening for Notifications on the specified .
 java.util.Map getBufferNotifications(java.lang.Object bufferID, long sequenceNumberIn)
          Get all outstanding Notifications which have a sequence number that is equal to or greater than the specified one.
 NotificationFilter getFilter(ObjectName objectName)
          Get the filter being used for a particular .
 java.util.Set getListeneeSet()
          Get the MBeans to which this service listens.
 java.lang.Object getUserData()
          The user data supplied when the instance was created.
 void listenTo(ObjectName pattern, NotificationFilter filter)
          Listen for Notifications from an using the specified filter, which may be null, in which case all Notifications are heard.
 void removeBuffer(java.lang.Object id)
          Remove the specified buffer.
 
Methods inherited from interface com.sun.appserv.management.base.AMX
getContainer, getDomainRoot, getFullType, getGroup, getJ2EEType, getName
 
Methods inherited from interface com.sun.appserv.management.base.AMXMBeanLogging
getMBeanEmitLogNotifications, getMBeanLoggerName, getMBeanLogLevel, setMBeanEmitLogNotifications, setMBeanLogLevel
 
Methods inherited from interface javax.management.NotificationEmitter
removeNotificationListener
 
Methods inherited from interface javax.management.NotificationBroadcaster
addNotificationListener, getNotificationInfo, removeNotificationListener
 
Methods inherited from interface javax.management.NotificationListener
handleNotification
 

Field Detail

J2EE_TYPE

public static final java.lang.String J2EE_TYPE
The j2eeType as returned by AMX.getJ2EEType().

See Also:
Constant Field Values

BUFFER_OVERFLOW_NOTIFICATION_TYPE

public static final java.lang.String BUFFER_OVERFLOW_NOTIFICATION_TYPE
When the buffer overflows this Notification is issued. The user data of the Notification contains the Notification that was discarded.

See Also:
Constant Field Values

OVERFLOWED_NOTIFICATION_KEY

public static final java.lang.String OVERFLOWED_NOTIFICATION_KEY
Key for accessing the overwritten Notification with the Notification of type BUFFER_OVERFLOW_NOTIFICATION_TYPE.

See Also:
Constant Field Values

NEXT_SEQUENCE_NUMBER_KEY

public static final java.lang.String NEXT_SEQUENCE_NUMBER_KEY
Key within the Map returned by getNotifications() that yields the Long for the next sequence number.

See Also:
Constant Field Values

NOTIFICATIONS_KEY

public static final java.lang.String NOTIFICATIONS_KEY
Key within the Map returned by getNotifications() that yields the Notifications[].

See Also:
Constant Field Values
Method Detail

getUserData

public java.lang.Object getUserData()
The user data supplied when the instance was created.


listenTo

public void listenTo(ObjectName pattern,
                     NotificationFilter filter)
              throws InstanceNotFoundException
Listen for Notifications from an using the specified filter, which may be null, in which case all Notifications are heard. The ObjectName may also be a pattern, in which case all s matching the pattern are listened to.

Note that Notifications may also be manually forced into the service by calling handlingNotification().

Parameters:
pattern - name of to listen to
filter -
Throws:
InstanceNotFoundException

dontListenTo

public void dontListenTo(ObjectName objectName)
                  throws InstanceNotFoundException
Stop listening for Notifications on the specified . It may also be a pattern, in which case listening is stopped on all s matching the pattern.

Parameters:
objectName - name of which should no longer be listened to.
Throws:
InstanceNotFoundException

getFilter

public NotificationFilter getFilter(ObjectName objectName)
Get the filter being used for a particular .

Parameters:
objectName -
Returns:
NotificationFilter

createBuffer

public java.lang.Object createBuffer(int bufferSize,
                                     NotificationFilter filter)
Create a new buffer of the specified size.

Parameters:
bufferSize - maximum number of Notifications to be buffered
filter - filter for Notifications to be buffered
Returns:
id of the newly-created buffer

removeBuffer

public void removeBuffer(java.lang.Object id)
Remove the specified buffer.


getBufferNotifications

public java.util.Map getBufferNotifications(java.lang.Object bufferID,
                                            long sequenceNumberIn)
Get all outstanding Notifications which have a sequence number that is equal to or greater than the specified one. A sequence number of 0 means all Notifications. The sequence number in this case is the overarching one maintained by this buffer, and has nothing to do with the sequence number within any particular Notification.

Notifications are never removed from the buffer; be sure to use the returned sequence number as a means of fetching new Notifications.

The Map is keyed by the following:

  • NEXT_SEQUENCE_NUMBER_KEY returns the Long for the next sequence number for subsequent calls to getNotifications()
  • NOTIFICATIONS_KEY keys the Notification[]
  • Returns:
    result[ 0 ] = next sequence number, result[ 1 ] = Notification[]

    getListeneeSet

    public java.util.Set getListeneeSet()
    Get the MBeans to which this service listens.


    J2EE1.4 SDK

    Submit a bug or feature

    Copyright 2003 Sun Microsystems, Inc. All rights reserved.