FileDocCategorySizeDatePackage
Notification.javaAPI DocJava SE 5 API12455Fri Aug 26 14:57:32 BST 2005javax.management

Notification

public class Notification extends EventObject

The Notification class represents a notification emitted by an MBean. It contains a reference to the source MBean: if the notification has been forwarded through the MBean server, and the original source of the notification was a reference to the emitting MBean object, then the MBean server replaces it by the MBean's ObjectName. If the listener has registered directly with the MBean, this is either the object name or a direct reference to the MBean.

It is strongly recommended that notification senders use the object name rather than a reference to the MBean object as the source.

since
1.5

Fields Summary
private static final long
oldSerialVersionUID
private static final long
newSerialVersionUID
private static final ObjectStreamField[]
oldSerialPersistentFields
private static final ObjectStreamField[]
newSerialPersistentFields
private static final long
serialVersionUID
private static final ObjectStreamField[]
serialPersistentFields
private static boolean
compat
private String
type
private long
sequenceNumber
private long
timeStamp
private Object
userData
private String
message
protected Object
source

This field hides the {@link EventObject#source} field in the parent class to make it non-transient and therefore part of the serialized form.

Constructors Summary
public Notification(String type, Object source, long sequenceNumber)
Creates a Notification object. The notification timeStamp is set to the current date.

param
type The notification type.
param
source The notification source.
param
sequenceNumber The notification sequence number within the source object.

    
    
                                                 
           
        super (source) ;
	this.source = source;
        this.type = type;
        this.sequenceNumber = sequenceNumber ;
        this.timeStamp = (new java.util.Date()).getTime() ;
    
public Notification(String type, Object source, long sequenceNumber, String message)
Creates a Notification object. The notification timeStamp is set to the current date.

param
type The notification type.
param
source The notification source.
param
sequenceNumber The notification sequence number within the source object.
param
message The detailed message.

        super (source) ;
	this.source = source;
        this.type = type;
        this.sequenceNumber = sequenceNumber ;
        this.timeStamp = (new java.util.Date()).getTime() ;
        this.message = message ;
    
public Notification(String type, Object source, long sequenceNumber, long timeStamp)
Creates a Notification object.

param
type The notification type.
param
source The notification source.
param
sequenceNumber The notification sequence number within the source object.
param
timeStamp The notification emission date.

        super (source) ;
	this.source = source;
        this.type = type ;
        this.sequenceNumber = sequenceNumber ;
        this.timeStamp = timeStamp ;
    
public Notification(String type, Object source, long sequenceNumber, long timeStamp, String message)
Creates a Notification object.

param
type The notification type.
param
source The notification source.
param
sequenceNumber The notification sequence number within the source object.
param
timeStamp The notification emission date.
param
message The detailed message.

        super (source) ;
	this.source = source;
        this.type = type ;
        this.sequenceNumber = sequenceNumber ;
        this.timeStamp = timeStamp ;
        this.message = message ;
    
Methods Summary
public java.lang.StringgetMessage()
Get the notification message.

return
The message string of this notification object. It contains in a string, which could be the explanation of the notification for displaying to a user

        return message ;
    
public longgetSequenceNumber()
Get the notification sequence number.

return
The notification sequence number within the source object. It's a serial number identifying a particular instance of notification in the context of the notification source. The notification model does not assume that notifications will be received in the same order that they are sent. The sequence number helps listeners to sort received notifications.
see
#setSequenceNumber

        return sequenceNumber ;
    
public longgetTimeStamp()
Get the notification timestamp.

return
The notification timestamp.
see
#setTimeStamp

        return timeStamp ;
    
public java.lang.StringgetType()
Get the notification type.

return
The notification type. It's a string expressed in a dot notation similar to Java properties. An example of a notification type is network.alarm.router .

        return type ;
    
public java.lang.ObjectgetUserData()
Get the user data.

return
The user data object. It is used for whatever data the notification source wishes to communicate to its consumers.
see
#setUserData

        return userData ;
    
private voidreadObject(java.io.ObjectInputStream in)
Deserializes a {@link Notification} from an {@link ObjectInputStream}.

 
      // New serial form ignores extra field "sourceObjectName"
      in.defaultReadObject();
      super.source = source;
    
public voidsetSequenceNumber(long sequenceNumber)
Set the notification sequence number.

param
sequenceNumber The notification sequence number within the source object. It is a serial number identifying a particular instance of notification in the context of the notification source.
see
#getSequenceNumber

        this.sequenceNumber = sequenceNumber;
    
public voidsetSource(java.lang.Object source)
Sets the source.

param
source the new source for this object.
see
EventObject#getSource

	super.source = source;
	this.source = source;
    
public voidsetTimeStamp(long timeStamp)
Set the notification timestamp.

param
timeStamp The notification timestamp. It indicates when the notification was generated.
see
#getTimeStamp

        this.timeStamp = timeStamp;
    
public voidsetUserData(java.lang.Object userData)
Set the user data.

param
userData The user data object. It is used for whatever data the notification source wishes to communicate to its consumers.
see
#getUserData


        this.userData = userData ;
    
public java.lang.StringtoString()
Returns a String representation of this notification.

return
A String representation of this notification.

	return super.toString()+"[type="+type+"][message="+message+"]";
    
private voidwriteObject(java.io.ObjectOutputStream out)
Serializes a {@link Notification} to an {@link ObjectOutputStream}.

	if (compat) {
	    // Serializes this instance in the old serial form
	    //
	    ObjectOutputStream.PutField fields = out.putFields();
	    fields.put("type", type);
	    fields.put("sequenceNumber", sequenceNumber);
	    fields.put("timeStamp", timeStamp);
	    fields.put("userData", userData);
	    fields.put("message", message);
	    fields.put("source", source);
	    out.writeFields();
	} else {
	    // Serializes this instance in the new serial form
	    //
	    out.defaultWriteObject();
	}