001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.monitor.alarm;
023:
024: import javax.management.ObjectName;
025:
026: /**
027: * AlarmTableNotification
028: *
029: * userData field, holds a reference to the source Notification
030: *
031: * @author <a href="mailto:dimitris@jboss.org">Dimitris Andreadis</a>
032: * @version $Revision: 57210 $
033: */
034: public class AlarmTableNotification extends AlarmNotification {
035: // Constants -----------------------------------------------------
036:
037: /** The type of AlarmTableNotification */
038: public static final String ALARM_TABLE_UPDATE = "jboss.alarm.table.update";
039:
040: // Private Data --------------------------------------------------
041:
042: /** @since 4.0.4 */
043: private static final long serialVersionUID = -2307598716282112101L;
044:
045: /** A unique id for the alarm */
046: private String alarmId;
047:
048: // AckStuff
049: /** the acked/unacked status of the alarm */
050: private boolean ackState;
051:
052: /** the time the ack/unack happened */
053: private long ackTime;
054:
055: /** the user that performed the ack/unack */
056: private String ackUser;
057:
058: /** the system ack/unack came from */
059: private String ackSystem;
060:
061: // CTORS ---------------------------------------------------------
062:
063: /**
064: * CTOR, creates an AlarmTableNotification object
065: *
066: * Same restrictions with AlarmNotification apply
067: */
068: public AlarmTableNotification(String alarmId, String type,
069: Object source, ObjectName target, int severity,
070: int alarmState, long sequenceNumber, long timeStamp,
071: String message) {
072: super (type, source, target, severity, alarmState,
073: sequenceNumber, timeStamp, message);
074:
075: this .alarmId = alarmId;
076: }
077:
078: /**
079: * Copy Constructor.
080: *
081: * Note, userData is not deep copied!
082: */
083: public AlarmTableNotification(AlarmTableNotification atn) {
084: super (atn.getType(), atn.getSource(), atn.getTarget(), atn
085: .getSeverity(), atn.getAlarmState(), atn
086: .getSequenceNumber(), atn.getTimeStamp(), atn
087: .getMessage());
088:
089: // this is not a deep copy!
090: this .setUserData(atn.getUserData());
091:
092: this .alarmId = atn.alarmId;
093: this .ackState = atn.ackState;
094: this .ackTime = atn.ackTime;
095: this .ackUser = atn.ackUser;
096: this .ackSystem = atn.ackSystem;
097: }
098:
099: // Accessors/Mutators --------------------------------------------
100:
101: /**
102: * Gets alarmId
103: */
104: public String getAlarmId() {
105: return alarmId;
106: }
107:
108: /**
109: * Gets the acked/unacked status of the alarm
110: */
111: public boolean getAckState() {
112: return ackState;
113: }
114:
115: /**
116: * Gets the last time the alarm was acked/unacked
117: */
118: public long getAckTime() {
119: return ackTime;
120: }
121:
122: /**
123: * Gets the user that performed the ack/unack
124: */
125: public String getAckUser() {
126: return ackUser;
127: }
128:
129: /**
130: * Gets the system that performed the ack/unack
131: */
132: public String getAckSystem() {
133: return ackSystem;
134: }
135:
136: /**
137: * Sets all ack parameters
138: */
139: public void setAckParams(boolean ackState, long ackTime,
140: String ackUser, String ackSystem) {
141: this .ackState = ackState;
142: this .ackTime = ackTime;
143: this .ackUser = ackUser;
144: this .ackSystem = ackSystem;
145: }
146:
147: // Object stuff --------------------------------------------------
148:
149: /**
150: * toString()
151: */
152: public String toString() {
153: StringBuffer sbuf = new StringBuffer(256);
154:
155: sbuf.append(AlarmTableNotification.class.getName());
156: sbuf.append(" [ alarmId=").append(alarmId);
157: sbuf.append(", type=").append(getType());
158: sbuf.append(", source=").append(getSource());
159: sbuf.append(", target=").append(getTarget());
160: sbuf.append(", severity=").append(
161: Alarm.SEVERITY_STRINGS[getSeverity()]);
162: sbuf.append(", alarmState=").append(
163: Alarm.STATE_STRINGS[getAlarmState()]);
164: sbuf.append(", sequenceNumber=").append(getSequenceNumber());
165: sbuf.append(", timeStamp=").append(getTimeStamp());
166: sbuf.append(", message=").append(getMessage());
167: sbuf.append(", userData={").append(getUserData());
168: sbuf.append("}, ackState=").append(ackState);
169: sbuf.append(", ackTime=").append(ackTime);
170: sbuf.append(", ackUser=").append(ackUser);
171: sbuf.append(", ackSystem=").append(ackSystem);
172: sbuf.append(" ]");
173:
174: return sbuf.toString();
175: }
176: }
|