From: Adrian B. <ej...@us...> - 2002-03-29 10:42:43
|
User: ejort Date: 02/03/29 02:42:43 Modified: src/main/javax/management Tag: BranchMX_1_0 Notification.java Log: Allow the source to be serialized in notifications Revision Changes Path No revision No revision 1.1.2.1 +196 -34 jmx/src/main/javax/management/Notification.java Index: Notification.java =================================================================== RCS file: /cvsroot/jboss/jmx/src/main/javax/management/Notification.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -r1.1 -r1.1.2.1 --- Notification.java 3 Dec 2001 02:08:47 -0000 1.1 +++ Notification.java 29 Mar 2002 10:42:43 -0000 1.1.2.1 @@ -1,104 +1,266 @@ /* - * LGPL + * JBoss, the OpenSource J2EE webOS + * + * Distributable under LGPL license. + * See terms of license at gnu.org. */ package javax.management; -public class Notification extends java.util.EventObject { - +/** + * A Notification.<p> + * + * <p><b>Revisions:</b> + * <p><b>20020329 Adrian Brock:</b> + * <ul> + * <li>Make the source serializable + * </ul> + * + * @author <a href="mailto:Adrian.Brock@HappeningTimes.com">Adrian Brock</a>. + * @version $Revision: 1.1.2.1 $ + */ +public class Notification + extends java.util.EventObject +{ + // Constants --------------------------------------------------- + + // Attributes -------------------------------------------------- + + /** + * The notification type + */ private String type = null; + + /** + * The sequence number of the notification + */ private long sequenceNumber = 0; + + /** + * The message of the notification + */ private String message = null; + + /** + * The time of the notification + */ private long timeStamp = System.currentTimeMillis(); + + /** + * The user data of the notification + */ private Object userData = null; - - - public Notification(java.lang.String type, - java.lang.Object source, - long sequenceNumber) { + + /** + * The source of the notification + */ + private Object mySource = null; + + // Static ------------------------------------------------------ + + // Constructors ------------------------------------------------ + + /** + * Create a new notification + * + * @param type the type of the notification + * @param source the source of the notification + * @param sequenceNumber the sequence number of the notification + */ + public Notification(String type, + Object source, + long sequenceNumber) + { super(source); + mySource = source; this.type = type; this.sequenceNumber = sequenceNumber; this.timeStamp = System.currentTimeMillis(); } - - public Notification(java.lang.String type, - java.lang.Object source, + + /** + * Create a new notification + * + * @param type the type of the notification + * @param source the source of the notification + * @param sequenceNumber the sequence number of the notification + * @param message the message of the notification + */ + public Notification(String type, + Object source, long sequenceNumber, - java.lang.String message) { + String message) + { this(type, source, sequenceNumber); this.message = message; this.timeStamp = System.currentTimeMillis(); } - public Notification(java.lang.String type, - java.lang.Object source, + /** + * Create a new notification + * + * @param type the type of the notification + * @param source the source of the notification + * @param sequenceNumber the sequence number of the notification + * @param timeStamp the time of the notification + */ + public Notification(String type, + Object source, long sequenceNumber, - long timeStamp) { + long timeStamp) + { this(type, source, sequenceNumber); this.timeStamp = timeStamp; } - public Notification(java.lang.String type, - java.lang.Object source, + /** + * Create a new notification + * + * @param type the type of the notification + * @param source the source of the notification + * @param sequenceNumber the sequence number of the notification + * @param timeStamp the time of the notification + * @param message the message of the notification + */ + public Notification(String type, + Object source, long sequenceNumber, long timeStamp, - java.lang.String message) + String message) { this(type, source, sequenceNumber, timeStamp); this.message = message; } + + // Public ------------------------------------------------------ - public java.lang.Object getSource() { - return super.source; - } + /** + * Retrieve the source of the notification + * + * @return the source + */ + public Object getSource() { - public void setSource(Object source) throws IllegalArgumentException { - if (source instanceof String) { - try { + return mySource; + } + + /** + * Set the source of the notification<p> + * + * The source must be either a object name or a string that can be + * used to create a valid object name. + * + * @param source the new source + * @exception IllegalArgumentException when the object name is invalid + */ + public void setSource(Object source) + throws IllegalArgumentException + { + if (source instanceof String) + { + try + { super.source = new ObjectName((String)source); } - catch (MalformedObjectNameException e) { + catch (MalformedObjectNameException e) + { throw new IllegalArgumentException("malformed object name: " + source); } } - else if (source instanceof ObjectName) { + else if (source instanceof ObjectName) + { super.source = source; } else throw new IllegalArgumentException("Notification source must be an object name"); - + mySource = super.source; } - public long getSequenceNumber() { + /** + * Retrieve the sequence number of the notification + * + * @return the sequence number + */ + public long getSequenceNumber() + { return sequenceNumber; } - public void setSequenceNumber(long sequenceNumber) { + /** + * Set the sequence number of the notifiction + * + * @param sequenceNumber the new sequence number + */ + public void setSequenceNumber(long sequenceNumber) + { this.sequenceNumber = sequenceNumber; } - public java.lang.String getType() { + /** + * Retrieve the type of the notification + * + * @return the type + */ + public String getType() + { return type; } - public long getTimeStamp() { + /** + * Retrieve the time of the notification + * + * @return the time + */ + public long getTimeStamp() + { return timeStamp; } + /** + * Set the time of the notifiction + * + * @param timeStamp the new time + */ public void setTimeStamp(long timeStamp) { this.timeStamp = timeStamp; } - public java.lang.String getMessage() { + /** + * Retrieve the message of the notification + * + * @return the message + */ + public String getMessage() + { return message; } - public java.lang.Object getUserData() { + /** + * Retrieve the user data of the notification + * + * @return the user data + */ + public Object getUserData() + { return userData; } - public void setUserData(java.lang.Object userData) { + /** + * Set the user data of the notifiction + * + * @param userData the new user data + */ + public void setUserData(Object userData) + { this.userData = userData; } + // X implementation -------------------------------------------- + + // Y overrides ------------------------------------------------- + + // Protected --------------------------------------------------- + + // Private ----------------------------------------------------- + + // Inner classes ----------------------------------------------- } |