KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > monitor > alarm > AlarmTableNotification


1 /*
2  * JBoss, Home of Professional Open Source
3  * Copyright 2005, JBoss Inc., and individual contributors as indicated
4  * by the @authors tag. See the copyright.txt in the distribution for a
5  * full listing of individual contributors.
6  *
7  * This is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation; either version 2.1 of
10  * the License, or (at your option) any later version.
11  *
12  * This software is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this software; if not, write to the Free
19  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21  */

22 package org.jboss.monitor.alarm;
23
24 import javax.management.ObjectName JavaDoc;
25
26 /**
27  * AlarmTableNotification
28  *
29  * userData field, holds a reference to the source Notification
30  *
31  * @author <a HREF="mailto:dimitris@jboss.org">Dimitris Andreadis</a>
32  * @version $Revision: 42955 $
33  */

34 public class AlarmTableNotification extends AlarmNotification
35 {
36    // Constants -----------------------------------------------------
37

38    /** The type of AlarmTableNotification */
39    public static final String JavaDoc ALARM_TABLE_UPDATE = "jboss.alarm.table.update";
40
41    // Private Data --------------------------------------------------
42

43    /** @since 4.0.4 */
44    private static final long serialVersionUID = -2307598716282112101L;
45    
46    /** A unique id for the alarm */
47    private String JavaDoc alarmId;
48    
49    // AckStuff
50
/** the acked/unacked status of the alarm */
51    private boolean ackState;
52
53    /** the time the ack/unack happened */
54    private long ackTime;
55    
56    /** the user that performed the ack/unack */
57    private String JavaDoc ackUser;
58    
59    /** the system ack/unack came from */
60    private String JavaDoc ackSystem;
61    
62    // CTORS ---------------------------------------------------------
63

64    /**
65     * CTOR, creates an AlarmTableNotification object
66     *
67     * Same restrictions with AlarmNotification apply
68     */

69    public AlarmTableNotification(
70       String JavaDoc alarmId,
71       String JavaDoc type, Object JavaDoc source,
72       ObjectName JavaDoc target, int severity, int alarmState,
73       long sequenceNumber, long timeStamp, String JavaDoc message)
74    {
75       super(type, source, target, severity, alarmState, sequenceNumber, timeStamp, message);
76       
77       this.alarmId = alarmId;
78    }
79    
80    /**
81     * Copy Constructor.
82     *
83     * Note, userData is not deep copied!
84     */

85    public AlarmTableNotification(AlarmTableNotification atn)
86    {
87       super(
88          atn.getType(), atn.getSource(),
89          atn.getTarget(), atn.getSeverity(), atn.getAlarmState(),
90          atn.getSequenceNumber(), atn.getTimeStamp(), atn.getMessage()
91          );
92       
93       // this is not a deep copy!
94
this.setUserData(atn.getUserData());
95       
96       this.alarmId = atn.alarmId;
97       this.ackState = atn.ackState;
98       this.ackTime = atn.ackTime;
99       this.ackUser = atn.ackUser;
100       this.ackSystem = atn.ackSystem;
101    }
102    
103    // Accessors/Mutators --------------------------------------------
104

105    /**
106     * Gets alarmId
107     */

108    public String JavaDoc getAlarmId()
109    {
110       return alarmId;
111    }
112
113    /**
114     * Gets the acked/unacked status of the alarm
115     */

116    public boolean getAckState()
117    {
118       return ackState;
119    }
120    
121    /**
122     * Gets the last time the alarm was acked/unacked
123     */

124    public long getAckTime()
125    {
126       return ackTime;
127    }
128    
129    /**
130     * Gets the user that performed the ack/unack
131     */

132    public String JavaDoc getAckUser()
133    {
134       return ackUser;
135    }
136    
137    /**
138     * Gets the system that performed the ack/unack
139     */

140    public String JavaDoc getAckSystem()
141    {
142       return ackSystem;
143    }
144    
145    /**
146     * Sets all ack parameters
147     */

148    public void setAckParams(boolean ackState, long ackTime, String JavaDoc ackUser, String JavaDoc ackSystem)
149    {
150       this.ackState = ackState;
151       this.ackTime = ackTime;
152       this.ackUser = ackUser;
153       this.ackSystem = ackSystem;
154    }
155    
156    // Object stuff --------------------------------------------------
157

158    /**
159     * toString()
160     */

161    public String JavaDoc toString()
162    {
163       StringBuffer JavaDoc sbuf = new StringBuffer JavaDoc(256);
164       
165       sbuf.append(AlarmTableNotification.class.getName());
166       sbuf.append(" [ alarmId=").append(alarmId);
167       sbuf.append(", type=").append(getType());
168       sbuf.append(", source=").append(getSource());
169       sbuf.append(", target=").append(getTarget());
170       sbuf.append(", severity=").append(Alarm.SEVERITY_STRINGS[getSeverity()]);
171       sbuf.append(", alarmState=").append(Alarm.STATE_STRINGS[getAlarmState()]);
172       sbuf.append(", sequenceNumber=").append(getSequenceNumber());
173       sbuf.append(", timeStamp=").append(getTimeStamp());
174       sbuf.append(", message=").append(getMessage());
175       sbuf.append(", userData={").append(getUserData());
176       sbuf.append("}, ackState=").append(ackState);
177       sbuf.append(", ackTime=").append(ackTime);
178       sbuf.append(", ackUser=").append(ackUser);
179       sbuf.append(", ackSystem=").append(ackSystem);
180       sbuf.append(" ]");
181       
182       return sbuf.toString();
183    }
184 }
185
Popular Tags