KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jmanage > core > config > AlertSourceConfig


1 /**
2 * Copyright (c) 2004-2005 jManage.org
3 *
4 * This is a free software; you can redistribute it and/or
5 * modify it under the terms of the license at
6 * http://www.jmanage.org.
7 *
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and
12 * limitations under the License.
13 */

14 package org.jmanage.core.config;
15
16 /**
17  * Specifies a source of an alert. Alert source could be one of:
18  * <li> MBean Notification
19  * <li> Attribute Value changes
20  *
21  * Date: Jul 31, 2005
22  * @author Rakesh Kalra
23  */

24 public class AlertSourceConfig {
25
26     public static final String JavaDoc SOURCE_TYPE_NOTIFICATION = "notification";
27     public static final String JavaDoc SOURCE_TYPE_GAUGE_MONITOR = "gauge";
28     public static final String JavaDoc SOURCE_TYPE_COUNTER_MONITOR = "counter";
29     public static final String JavaDoc SOURCE_TYPE_STRING_MONITOR = "string";
30
31     private static final String JavaDoc SOURCE_TYPE_NOTIFICATION_DESC = "MBean Notification";
32     private static final String JavaDoc SOURCE_TYPE_GAUGE_MONITOR_DESC = "MBean Attribute Value Thresholds";
33     private static final String JavaDoc SOURCE_TYPE_STRING_MONITOR_DESC = "MBean Attribute String Value Match";
34
35     private String JavaDoc sourceType;
36     private ApplicationConfig appConfig;
37     private String JavaDoc objectName;
38
39     /* for notification */
40     private String JavaDoc notificationType;
41
42     /* for attribute change */
43     // attr name
44
private String JavaDoc attributeName;
45     private Number JavaDoc lowThreshold;
46     private Number JavaDoc highThreshold;
47     private String JavaDoc stringAttributeValue;
48     private String JavaDoc attributeDataTYpe;
49
50     public AlertSourceConfig(String JavaDoc objectName, String JavaDoc notificationType){
51         this.sourceType = SOURCE_TYPE_NOTIFICATION;
52         this.objectName = objectName;
53         this.notificationType = notificationType;
54     }
55
56     public AlertSourceConfig(String JavaDoc objectName, String JavaDoc attributeName,
57                              Number JavaDoc minValue, Number JavaDoc maxValue,
58                              String JavaDoc attributeDataType){
59         this.sourceType = SOURCE_TYPE_GAUGE_MONITOR;
60         this.objectName = objectName;
61         this.attributeName = attributeName;
62         this.lowThreshold = minValue;
63         this.highThreshold = maxValue;
64         this.attributeDataTYpe = attributeDataType;
65     }
66
67     public AlertSourceConfig(String JavaDoc objectName, String JavaDoc attributeName,
68                              String JavaDoc stringAttributeValue){
69         this.sourceType = SOURCE_TYPE_STRING_MONITOR;
70         this.objectName = objectName;
71         this.attributeName = attributeName;
72         this.stringAttributeValue = stringAttributeValue;
73     }
74
75     /* todo: enable if this could be useful - rk
76     // alert on any change to the attribute value
77     //private Boolean anyChange;
78
79     public AlertSourceConfig(String objectName, String attributeName,
80                              boolean anyChange){
81         this.sourceType = SOURCE_TYPE_ATTRIBUTE_CHANGE;
82         this.objectName = new ObjectName(objectName);
83         this.attributeName = attributeName;
84         assert anyChange == true;
85         this.anyChange = Boolean.TRUE;
86     }
87     */

88
89     public String JavaDoc getSourceType() {
90         return sourceType;
91     }
92
93     public String JavaDoc getSourceTypeDesc(){
94         return getSourceTypeDescription(sourceType);
95     }
96
97     public String JavaDoc getObjectName() {
98         return objectName;
99     }
100
101     public String JavaDoc getNotificationType() {
102         return notificationType;
103     }
104
105     public String JavaDoc getAttributeName() {
106         return attributeName;
107     }
108
109     public Number JavaDoc getLowThreshold() {
110         return lowThreshold;
111     }
112
113     public Number JavaDoc getHighThreshold() {
114         return highThreshold;
115     }
116
117     public String JavaDoc getStringAttributeValue(){
118         return stringAttributeValue;
119     }
120
121     public void setApplicationConfig(ApplicationConfig appConfig) {
122         this.appConfig = appConfig;
123     }
124
125     public ApplicationConfig getApplicationConfig(){
126         return appConfig;
127     }
128     public String JavaDoc getAttributeDataTYpe() {
129         return attributeDataTYpe;
130     }
131
132     public static String JavaDoc getSourceTypeDescription(String JavaDoc sourceType){
133         if (sourceType.equals(SOURCE_TYPE_NOTIFICATION)){
134             return SOURCE_TYPE_NOTIFICATION_DESC;
135         }
136         if(sourceType.equals(SOURCE_TYPE_GAUGE_MONITOR)){
137             return SOURCE_TYPE_GAUGE_MONITOR_DESC;
138         }
139         if(sourceType.equals(SOURCE_TYPE_STRING_MONITOR)){
140             return SOURCE_TYPE_STRING_MONITOR_DESC;
141         }
142         return null;
143     }
144
145 }
146
Popular Tags