1 23 24 31 package com.sun.enterprise.admin.event; 32 33 import java.util.ArrayList ; 34 import com.sun.enterprise.admin.event.BaseDeployEvent; 35 import com.sun.enterprise.config.ConfigChange; 36 37 import com.sun.enterprise.util.i18n.StringManager; 39 40 45 public class ResourceDeployEvent extends BaseDeployEvent implements Cloneable { 46 47 50 public static final String RES_TYPE_CUSTOM = "custom"; 51 52 55 public static final String RES_TYPE_EXTERNAL_JNDI = "external-jndi"; 56 57 60 public static final String RES_TYPE_JDBC = "jdbc"; 61 62 65 public static final String RES_TYPE_MAIL = "mail"; 66 67 70 public static final String RES_TYPE_JMS = "jms"; 71 72 75 public static final String RES_TYPE_PMF = "pmf"; 76 77 80 public static final String RES_TYPE_JCP = "jcp"; 81 82 85 public static final String RES_TYPE_AOR = "aor"; 86 87 90 public static final String RES_TYPE_CCP = "ccp"; 91 92 95 public static final String RES_TYPE_CR = "cr"; 96 97 100 public static final String RES_TYPE_RAC = "rac"; 101 102 105 static final String eventType = ResourceDeployEvent.class.getName(); 106 107 110 private String resourceType; 111 112 117 private boolean resourceExists = true; 118 119 122 private boolean noOp = false; 123 124 private static StringManager localStrings = 126 StringManager.getManager( ResourceDeployEvent.class ); 127 128 145 public ResourceDeployEvent(String instance, String resourceName, 146 String resourceType, String actionCode) { 147 super(eventType, instance, BaseDeployEvent.RESOURCE, resourceName, 148 actionCode); 149 if(resourceType!=null) 150 setResourceType(resourceType); 151 if (DEPLOY.equals(actionCode)) { 152 resourceExists = false; 153 } 154 } 155 156 private ResourceDeployEvent(String type, Object source, 157 long seqNumber,long time) { 158 super(type, source, seqNumber, time); 159 setResourceType(type); 160 this.j2eeComponentType = BaseDeployEvent.RESOURCE; 161 162 } 164 165 169 public String getResourceName() { 170 return getJ2EEComponentName(); 171 } 172 173 178 public String getResourceType() { 179 return resourceType; 180 } 181 182 185 public void setResourceType(String resType) { 186 boolean valid = false; 187 if (RES_TYPE_CUSTOM.equals(resType) 188 || RES_TYPE_EXTERNAL_JNDI.equals(resType) 189 || RES_TYPE_JDBC.equals(resType) 190 || RES_TYPE_MAIL.equals(resType) 191 || RES_TYPE_JMS.equals(resType) 192 || RES_TYPE_PMF.equals(resType) 193 || RES_TYPE_JCP.equals(resType) 194 || RES_TYPE_AOR.equals(resType) 195 || RES_TYPE_CCP.equals(resType) 196 || RES_TYPE_CR.equals(resType) 197 || RES_TYPE_RAC.equals(resType)) { 198 valid = true; 199 } 200 if (!valid) { 201 String msg = localStrings.getString( "admin.event.invalid_resource_type", resType ); 202 throw new IllegalArgumentException ( msg ); 203 } 204 this.resourceType = resType; 205 } 206 207 265 272 private void setActionForAdd() { 273 if (resourceExists) { 274 String currentAction = getAction(); 275 if (UNDEPLOY.equals(currentAction)) { 276 setAction(REDEPLOY); 277 } else { 278 } 281 } else { 282 if (noOp) { 283 setAction(DEPLOY); 284 noOp = false; 285 } else { 286 } 291 } 292 } 293 294 299 private void setActionForUpdate() { 300 } 308 309 314 private void setActionForDelete() { 315 if (resourceExists) { 316 String currentAction = getAction(); 317 if (UNDEPLOY.equals(currentAction)) { 318 } else { 321 setAction(UNDEPLOY); 322 } 323 } else { 324 if (noOp) { 325 } else { 328 noOp = true; 329 } 330 } 331 } 332 333 338 void setNewAction(String newAction) { 339 if (DEPLOY.equals(newAction)) { 340 setActionForAdd(); 341 } else if (REDEPLOY.equals(newAction)) { 342 setActionForUpdate(); 343 } else if (UNDEPLOY.equals(newAction)) { 344 setActionForDelete(); 345 } else { 346 String msg = localStrings.getString( "admin.event.illegal_new_action", newAction ); 347 throw new IllegalArgumentException ( msg ); 348 } 349 } 350 351 355 boolean isNoOp() { 356 return noOp; 357 } 358 359 public String toString() { 360 return "ResourceDeployEvent -- " + getAction() + " " + resourceType + "/" + getJ2EEComponentName(); 361 } 362 363 public Object clone() throws CloneNotSupportedException { 364 ResourceDeployEvent re = (ResourceDeployEvent) super.clone(); 365 return re; 366 } 367 } 368 | Popular Tags |