javax.management

Class Notification

Implemented Interfaces:
Serializable
Known Direct Subclasses:
AttributeChangeNotification, MBeanServerNotification

public class Notification
extends EventObject

A notification message that may be emitted by a bean. Notifications have both a message and a type, so individual notifications can be grouped by type. They also incorporate sequencing, so that the recipient can order the delivered messages correctly (there is no guarantee that they will be delivered in order).

Notifications also include a reference to the source of the notification. The source bean is represented either by an ObjectName or by a direct reference to the bean. The former is preferable, and notifications emitted via a MBeanServer will automatically have the source transformed into an ObjectName.

Since:
1.5
See Also:
Serialized Form

Field Summary

protected Object
source
The source of the notification.

Fields inherited from class java.util.EventObject

source

Constructor Summary

Notification(String type, Object source, long sequenceNumber)
Creates a new Notification object with the specified type, source and sequence number.
Notification(String type, Object source, long sequenceNumber, String message)
Creates a new Notification object with the specified type, source, sequence number and message.
Notification(String type, Object source, long sequenceNumber, long timeStamp)
Creates a new Notification object with the specified type, source, sequence number and timestamp.
Notification(String type, Object source, long sequenceNumber, long timeStamp, String message)
Creates a new Notification object with the specified type, source, sequence number, timestamp and message.

Method Summary

String
getMessage()
Returns the message contained in this notification.
long
getSequenceNumber()
Returns the sequence number of this notification.
long
getTimeStamp()
Returns the date and time at which this notification was emitted.
String
getType()
Returns the type of this notification.
Object
getUserData()
Returns the additional user data associated with the notification.
void
setSequenceNumber(long sequenceNumber)
Sets the sequence number to the value specified.
void
setSource(Object source)
Sets the source of this notification to the value specified.
void
setTimeStamp(long timeStamp)
Sets the date and time at which this notification was emitted.
void
setUserData(Object userData)
Sets the additional user data associated with the notification to the specified value.
String
toString()
A textual representation of the notification.

Methods inherited from class java.util.EventObject

getSource, toString

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

source

protected Object source
The source of the notification. This is redeclared in order to replace the source variable in EventObject with a non-transient version.

Constructor Details

Notification

public Notification(String type,
                    Object source,
                    long sequenceNumber)
Creates a new Notification object with the specified type, source and sequence number. The timestamp is created using the current date and time.
Parameters:
type - the type of the notification.
source - the source of the notification.
sequenceNumber - the sequence number of the notifcation.

Notification

public Notification(String type,
                    Object source,
                    long sequenceNumber,
                    String message)
Creates a new Notification object with the specified type, source, sequence number and message. The timestamp is created using the current date and time.
Parameters:
type - the type of the notification.
source - the source of the notification.
sequenceNumber - the sequence number of the notifcation.
message - the message contained in the notification.

Notification

public Notification(String type,
                    Object source,
                    long sequenceNumber,
                    long timeStamp)
Creates a new Notification object with the specified type, source, sequence number and timestamp.
Parameters:
type - the type of the notification.
source - the source of the notification.
sequenceNumber - the sequence number of the notifcation.
timeStamp - the time the notification was emitted.

Notification

public Notification(String type,
                    Object source,
                    long sequenceNumber,
                    long timeStamp,
                    String message)
Creates a new Notification object with the specified type, source, sequence number, timestamp and message.
Parameters:
type - the type of the notification.
source - the source of the notification.
sequenceNumber - the sequence number of the notifcation.
timeStamp - the time the notification was emitted.
message - the message contained in the notification.

Method Details

getMessage

public String getMessage()
Returns the message contained in this notification. The message is in String form, and is thus intended for display to the end-user. Data transferred as part of the notification which shouldn't be displayed is included in the userData field.
Returns:
the notification message.

getSequenceNumber

public long getSequenceNumber()
Returns the sequence number of this notification. This can be used to determine the order in which notifications were emitted by the broadcasting bean.
Returns:
the sequence number.

getTimeStamp

public long getTimeStamp()
Returns the date and time at which this notification was emitted.
Returns:
the notification timestamp.

getType

public String getType()
Returns the type of this notification. Types take the same form as Java package and property names.
Returns:
the type of the notification.

getUserData

public Object getUserData()
Returns the additional user data associated with the notification. This is used to attach additional non-textual information to the notification.
Returns:
the user data associated with the notification.

setSequenceNumber

public void setSequenceNumber(long sequenceNumber)
Sets the sequence number to the value specified.
Parameters:
sequenceNumber - the new sequence number.

setSource

public void setSource(Object source)
Sets the source of this notification to the value specified.
Parameters:
source - the new source of the notification.
See Also:
java.util.EventSource.getSource()

setTimeStamp

public void setTimeStamp(long timeStamp)
Sets the date and time at which this notification was emitted.
Parameters:
timeStamp - the new time stamp of the notification.

setUserData

public void setUserData(Object userData)
Sets the additional user data associated with the notification to the specified value. This is used to attach additional non-textual information to the notification.
Parameters:
userData - the new user data associated with the notification.
See Also:
getUserData()

toString

public String toString()
A textual representation of the notification.
Overrides:
toString in interface EventObject
Returns:
the notification in String form.

Notification.java -- A notification emitted by a bean. Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.