javax.management

Class Notification

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 {@link ObjectName} or by a direct reference to the bean. The former is preferable, and notifications emitted via a {@link MBeanServer} will automatically have the source transformed into an {@link ObjectName}.

Since: 1.5

Field Summary
protected Objectsource
The source of the notification.
Constructor Summary
Notification(String type, Object source, long sequenceNumber)
Creates a new {@link Notification} object with the specified type, source and sequence number.
Notification(String type, Object source, long sequenceNumber, long timeStamp)
Creates a new {@link 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 {@link Notification} object with the specified type, source, sequence number, timestamp and message.
Notification(String type, Object source, long sequenceNumber, String message)
Creates a new {@link Notification} object with the specified type, source, sequence number and message.
Method Summary
StringgetMessage()
Returns the message contained in this notification.
longgetSequenceNumber()
Returns the sequence number of this notification.
longgetTimeStamp()
Returns the date and time at which this notification was emitted.
StringgetType()
Returns the type of this notification.
ObjectgetUserData()
Returns the additional user data associated with the notification.
voidsetSequenceNumber(long sequenceNumber)
Sets the sequence number to the value specified.
voidsetSource(Object source)
Sets the source of this notification to the value specified.
voidsetTimeStamp(long timeStamp)
Sets the date and time at which this notification was emitted.
voidsetUserData(Object userData)
Sets the additional user data associated with the notification to the specified value.
StringtoString()
A textual representation of the notification.

Field Detail

source

protected Object source
The source of the notification. This is redeclared in order to replace the source variable in {@link java.util.EventObject} with a non-transient version.

Serial: the notification source.

Constructor Detail

Notification

public Notification(String type, Object source, long sequenceNumber)
Creates a new {@link 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, long timeStamp)
Creates a new {@link 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 {@link 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.

Notification

public Notification(String type, Object source, long sequenceNumber, String message)
Creates a new {@link 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.

Method Detail

getMessage

public String getMessage()
Returns the message contained in this notification. The message is in {@link java.lang.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.

See Also: getUserData setUserData

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.

See Also: Notification

getTimeStamp

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

Returns: the notification timestamp.

See Also: Notification

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.

See Also: setUserData

setSequenceNumber

public void setSequenceNumber(long sequenceNumber)
Sets the sequence number to the value specified.

Parameters: sequenceNumber the new sequence number.

See Also: getSequenceNumber

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.

See Also: getTimeStamp

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.

Returns: the notification in {@link java.lang.String} form.