1 23 24 25 26 39 40 package com.sun.enterprise.config; 41 42 43 44 import javax.management.Notification ; 45 46 47 48 53 54 public class ConfigContextEvent extends Notification { 55 56 57 public static final String PRE_ACCESS = "PRE_ACCESS"; 58 59 public static final String POST_ACCESS = "POST_ACCESS"; 60 61 public static final String PRE_ADD_CHANGE = "PRE_ADD_CHANGE"; 62 63 public static final String POST_ADD_CHANGE = "POST_ADD_CHANGE"; 64 65 public static final String PRE_UPDATE_CHANGE = "PRE_UPDATE_CHANGE"; 66 67 public static final String POST_UPDATE_CHANGE = "POST_UPDATE_CHANGE"; 68 69 public static final String PRE_DELETE_CHANGE = "PRE_DELETE_CHANGE"; 70 71 public static final String POST_DELETE_CHANGE = "POST_DELETE_CHANGE"; 72 73 public static final String PRE_SET_CHANGE = "PRE_SET_CHANGE"; 74 75 public static final String POST_SET_CHANGE = "POST_SET_CHANGE"; 76 77 public static final String PRE_FLUSH_CHANGE = "PRE_FLUSH_CHANGE"; 78 79 public static final String POST_FLUSH_CHANGE = "POST_FLUSH_CHANGE"; 80 81 82 83 private static long eventCounter = 0; 84 85 private String name; 86 87 private Object value; 88 89 private String choice; 90 91 private String beanName; 92 93 98 99 private Object classObject; 100 101 103 104 105 112 113 public ConfigContextEvent(ConfigContext ctx, String eventType) { 114 115 super(eventType, ctx, ++eventCounter, System.currentTimeMillis()); 116 117 } 118 119 120 121 123 public ConfigContextEvent(final ConfigContext ctx, 124 final String eventType, 125 final String name, 126 final Object value, 127 final String choice) { 128 this(ctx, eventType, name, value, choice, null); 129 } 130 131 public ConfigContextEvent(final ConfigContext ctx, 132 final String eventType, 133 final String name, 134 final Object value, 135 final String choice, 136 final String beanName) { 137 this(ctx,eventType); 138 this.name = name; 139 this.value = value; 140 this.choice = choice; 141 this.beanName = beanName; 142 } 143 144 145 146 147 148 public Object getObject(){ 149 150 return value; 151 152 } 153 154 155 156 public String getName(){ 157 158 return name; 159 160 } 161 162 163 164 public String getChoice(){ 165 166 return choice; 167 168 } 169 170 171 172 public void setBeanName(String beanName){ 173 174 this.beanName = beanName; 175 176 } 177 178 179 180 public String getBeanName() { 181 182 return beanName; 183 184 } 185 186 188 189 190 201 202 public ConfigContext getConfigContext() { 203 204 return (ConfigContext)getSource(); 205 206 } 207 208 209 210 215 216 public String toString() { 217 218 return this.getClass().getName() + " -- " 219 220 + " [Id:" + this.getSequenceNumber() 221 222 + ", ts:" + this.getTimeStamp() + "]"; 223 224 } 225 226 227 228 230 241 242 public Object getClassObject() 243 244 { 245 246 return classObject; 247 248 } 249 250 251 252 261 262 public void setClassObject(Object obj) 263 264 { 265 266 this.classObject = obj; 267 268 } 269 270 272 282 public ConfigBean getValidationTarget() throws ConfigException{ 290 final String choice = this.getChoice(); 291 if (choice.equals("VALIDATE")){ 292 return (ConfigBean) this.getObject(); 293 } else if (choice.equals("ADD")) { 294 return (ConfigBean) this.getObject(); 295 } else if (choice.equals("DELETE")) { 296 return (ConfigBean) this.getObject(); 297 } else if (choice.equals("UPDATE")) { 298 return (ConfigBean) this.getClassObject(); 299 } else if (choice.equals("SET")) { 300 if (null == this.getBeanName()){ 301 if (this.getName().equals("Description")){ 302 throw new ConfigException("Internal error - invalid condition - attempting to validate a SET operation with a \"Description\" object"); 303 } else { 304 return (ConfigBean) this.getObject(); 305 } 306 } else { 307 return (ConfigBean) this.getClassObject(); 308 } 309 } else { 310 throw new ConfigException("Internal error - invalid choice received: \""+choice+"\". Only expecting ADD, DELETE, UPDATE or SET"); 311 } 312 } 313 314 315 316 317 } 318 319 | Popular Tags |