1 22 package org.jboss.mx.util; 23 24 import javax.management.ObjectName ; 25 26 29 public class ObservedObject 30 { 31 35 public static final int RESET_FLAGS_ALREADY_NOTIFIED = 0; 36 37 40 public static final int RUNTIME_ERROR_NOTIFIED = 8; 41 42 45 public static final int OBSERVED_OBJECT_ERROR_NOTIFIED = 1; 46 47 50 public static final int OBSERVED_ATTRIBUTE_ERROR_NOTIFIED = 2; 51 52 55 public static final int OBSERVED_ATTRIBUTE_TYPE_ERROR_NOTIFIED = 4; 56 57 59 62 private ObjectName objectName; 63 64 67 private int alreadyNotified = RESET_FLAGS_ALREADY_NOTIFIED; 68 69 72 private Object derivedGauge; 73 74 77 private Object lastValue; 78 79 82 private long derivedGaugeTimeStamp; 83 84 87 private Object threshold; 88 89 91 93 98 public ObservedObject(ObjectName objectName) 99 { 100 if (objectName == null) 101 throw new IllegalArgumentException ("Null object name"); 102 this.objectName = objectName; 103 } 104 105 107 public ObjectName getObjectName() 108 { 109 return objectName; 110 } 111 112 public int getAlreadyNotified() 113 { 114 return alreadyNotified; 115 } 116 117 public boolean isAlreadyNotified(int mask) 118 { 119 return (alreadyNotified & mask) != 0; 120 } 121 122 public boolean notAlreadyNotified(int mask) 123 { 124 if ((alreadyNotified & mask) == 0) 125 { 126 alreadyNotified |= mask; 127 return true; 128 } 129 return false; 130 } 131 132 public void setNotAlreadyNotified(int mask) 133 { 134 alreadyNotified &= ~mask; 135 } 136 137 public void setAlreadyNotified(int mask) 138 { 139 alreadyNotified |= mask; 140 } 141 142 public void resetAlreadyNotified() 143 { 144 alreadyNotified = RESET_FLAGS_ALREADY_NOTIFIED; 145 } 146 147 public Object getDerivedGauge() 148 { 149 return derivedGauge; 150 } 151 152 public void setDerivedGauge(Object gauge) 153 { 154 derivedGauge = gauge; 155 } 156 157 public Object getLastValue() 158 { 159 return lastValue; 160 } 161 162 public void setLastValue(Object last) 163 { 164 lastValue = last; 165 } 166 167 public long getDerivedGaugeTimeStamp() 168 { 169 return derivedGaugeTimeStamp; 170 } 171 172 public void setDerivedGaugeTimeStamp(long ts) 173 { 174 derivedGaugeTimeStamp = ts; 175 } 176 177 public Object getThreshold() 178 { 179 return threshold; 180 } 181 182 public void setThreshold(Object threshold) 183 { 184 this.threshold = threshold; 185 } 186 187 190 public String toString() 191 { 192 StringBuffer buffer = new StringBuffer (100); 193 buffer.append(getClass().getName()).append("@").append(System.identityHashCode(this)).append("{"); 194 buffer.append(" objectName=").append(getObjectName()); 195 buffer.append(" alreadyNotified=").append(getAlreadyNotified()); 196 buffer.append(" threshold=").append(getThreshold()); 197 buffer.append(" derivedGauge=").append(getDerivedGauge()); 198 buffer.append(" derivedGaugeTS=").append(getDerivedGaugeTimeStamp()); 199 buffer.append(" lastValue=").append(getLastValue()); 200 return buffer.append("}").toString(); 201 } 202 203 } 204 | Popular Tags |