1 23 24 29 30 package com.sun.enterprise.deployment.util; 31 32 import java.util.Properties ; 33 import java.util.Iterator ; 34 import java.util.HashMap ; 35 import java.util.Map ; 36 import java.io.File ; 37 import javax.enterprise.deploy.shared.ModuleType ; 38 39 45 public class DeploymentProperties extends Properties { 46 47 static final long serialVersionUID = -6891581813642829148L; 52 53 public DeploymentProperties() { 54 super(); 55 } 56 57 public DeploymentProperties(Properties props) { 60 super(); 61 putAll(props); 62 } 63 64 public DeploymentProperties(Map map) { 74 super(); 75 if (map == null) { 76 return; 77 } 78 Properties props = new Properties (); 79 for (Iterator itr = map.keySet().iterator(); itr.hasNext();) { 80 String mapKey = (String ) itr.next(); 81 String mapValue = (String ) map.get(mapKey); 82 String propsKey = (String ) keyMap.get(mapKey); 83 if (mapValue != null) { 84 if (propsKey != null) { 86 props.put(propsKey, mapValue); 87 } 88 else { 91 props.put(mapKey, mapValue); 92 } 93 } 94 } 95 putAll(props); 96 } 97 98 public static Map propsToMap(Properties dProps) { 109 Map map = new HashMap (); 110 if (dProps == null) { 111 return map; 112 } 113 for (Iterator itr = dProps.keySet().iterator(); itr.hasNext();) { 114 String propsKey = (String ) itr.next(); 115 String propsValue = (String ) dProps.get(propsKey); 116 String mapKey = (String ) keyMap.get(propsKey); 117 if (propsValue != null) { 118 if (mapKey != null) { 120 map.put(mapKey, propsValue); 121 } else { 124 map.put(propsKey, propsValue); 125 } 126 } 127 } 128 return map; 129 } 130 131 136 137 public String getWsdlTargetHint() throws IllegalArgumentException { 138 return getProperty(WSDL_TARGET_HINT, null); 139 } 140 141 public void setWsdlTargetHint(String target) { 142 if(target != null) { 143 setProperty(WSDL_TARGET_HINT, target); 144 } 145 } 146 147 public String getTarget() throws IllegalArgumentException { 148 return getProperty(TARGET, null); 149 } 150 151 public void setTarget(String target) { 152 if (target != null) 153 setProperty(TARGET, target); 154 } 155 156 public boolean getRedeploy() { 157 return Boolean.valueOf(getProperty(REDEPLOY, DEFAULT_REDEPLOY)).booleanValue(); 158 } 159 160 public void setRedeploy(boolean redeploy) { 161 setProperty(REDEPLOY, new Boolean (redeploy).toString()); 162 } 163 164 public String getArchiveName() throws IllegalArgumentException { 165 return getProperty(ARCHIVE_NAME, null); 166 } 167 168 public void setArchiveName(String archiveName) { 169 if(archiveName != null) 170 setProperty(ARCHIVE_NAME, archiveName); 171 } 172 173 public boolean getForce() { 174 return Boolean.valueOf(getProperty(FORCE,DEFAULT_FORCE)).booleanValue(); 175 } 176 177 public void setForce(boolean force) { 178 setProperty(FORCE, new Boolean (force).toString()); 179 } 180 181 public boolean getReload() { 182 return Boolean.valueOf(getProperty(RELOAD,DEFAULT_RELOAD)).booleanValue(); 183 } 184 185 public void setReload(boolean reload) { 186 setProperty(RELOAD, new Boolean (reload).toString()); 187 } 188 189 public boolean getCascade() { 190 return Boolean.valueOf(getProperty(CASCADE,DEFAULT_CASCADE)).booleanValue(); 191 } 192 193 public void setCascade(boolean cascade) { 194 setProperty(CASCADE, new Boolean (cascade).toString()); 195 } 196 197 public boolean getPrecompileJSP() { 198 return Boolean.valueOf(getProperty(PRECOMPILE_JSP,DEFAULT_PRECOMPILE_JSP)).booleanValue(); 199 } 200 201 public void setPrecompileJSP(boolean precompileJSP) { 202 setProperty(PRECOMPILE_JSP, new Boolean (precompileJSP).toString()); 203 } 204 205 public boolean getVerify() { 206 return Boolean.valueOf(getProperty(VERIFY,DEFAULT_VERIFY)).booleanValue(); 207 } 208 209 public void setVerify(boolean verify) { 210 setProperty(VERIFY, new Boolean (verify).toString()); 211 } 212 213 public String getVirtualServers() { 214 return getProperty(VIRTUAL_SERVERS , DEFAULT_VIRTUAL_SERVERS); 215 } 216 217 public void setVirtualServers(String virtualServers) { 218 if(virtualServers != null) 219 setProperty(VIRTUAL_SERVERS, virtualServers); 220 } 221 222 public boolean getEnable() { 223 return Boolean.valueOf(getProperty(ENABLE,DEFAULT_ENABLE)).booleanValue(); 224 } 225 226 public void setEnable(boolean enable) { 227 setProperty(ENABLE, new Boolean (enable).toString()); 228 } 229 230 public String getContextRoot() { 231 return getProperty(CONTEXT_ROOT, null); 232 } 233 234 public void setContextRoot(String contextRoot) { 235 if(contextRoot != null) 236 setProperty(CONTEXT_ROOT, contextRoot); 237 } 238 239 public String getName(String filePath) { 240 return getProperty(NAME, getDefaultComponentName(filePath)); 241 } 242 243 public void setName(String name) { 244 if(name != null) 245 setProperty(NAME, name); 246 } 247 248 public String getDescription() { 249 return getProperty(DESCRIPTION, ""); 250 } 251 252 public void setDescription(String description) { 253 if(description != null) 254 setProperty(DESCRIPTION, description); 255 } 256 257 public boolean getGenerateRMIStubs() { 258 return Boolean.valueOf(getProperty(GENERATE_RMI_STUBS,DEFAULT_GENERATE_RMI_STUBS)).booleanValue(); 259 } 260 261 public void setGenerateRMIStubs(boolean generateRMIStubs ) { 262 setProperty(GENERATE_RMI_STUBS, new Boolean (generateRMIStubs).toString()); 263 } 264 265 public boolean getAvailabilityEnabled() { 266 return Boolean.valueOf(getProperty(AVAILABILITY_ENABLED,DEFAULT_AVAILABILITY_ENABLED)).booleanValue(); 267 } 268 269 public void setAvailabilityEnabled(boolean availabilityEnabled ) { 270 setProperty(AVAILABILITY_ENABLED, new Boolean (availabilityEnabled).toString()); 271 } 272 273 public boolean getJavaWebStartEnabled() { 274 return Boolean.valueOf(getProperty(DEPLOY_OPTION_JAVA_WEB_START_ENABLED_KEY, DEFAULT_JAVA_WEB_START_ENABLED)).booleanValue(); 275 } 276 277 public void setJavaWebStartEnabled(boolean javaWebStartEnabled) { 278 setProperty(DEPLOY_OPTION_JAVA_WEB_START_ENABLED_KEY, new Boolean (javaWebStartEnabled).toString()); 279 } 280 281 public String getLibraries() { 282 return getProperty(DEPLOY_OPTION_LIBRARIES_KEY, null ); 283 } 284 285 public void setLibraries(String libraries) { 286 if(libraries != null) { 287 setProperty(DEPLOY_OPTION_LIBRARIES_KEY, libraries); 288 } 289 } 290 291 public String getResourceAction() { 292 return getProperty(RESOURCE_ACTION, null ); 293 } 294 295 public void setResourceAction(String resourceAction) { 296 if(resourceAction != null) { 297 setProperty(RESOURCE_ACTION, resourceAction); 298 } 299 } 300 301 public String getResourceTargetList() { 302 return getProperty(RESOURCE_TARGET_LIST, null ); 303 } 304 305 public void setResourceTargetList(String resTargetList) { 306 if(resTargetList != null) { 307 setProperty(RESOURCE_TARGET_LIST, resTargetList); 308 } 309 } 310 311 public void setType(ModuleType type) { 312 if (type != null) { 313 setProperty(TYPE, String.valueOf(type.getValue())); 314 } 315 } 316 317 public ModuleType getType() { 318 String t = getProperty(TYPE, null); 319 if ( t != null ) { 320 return ModuleType.getModuleType((new Integer (t)).intValue()); 321 } 322 return null; 323 } 324 325 326 public Properties getPropertiesForInvoke(){ 327 return (Properties )this; 328 } 329 330 public Properties prune() { 331 332 remove(FORCE); 333 remove(RELOAD); 334 remove(CONTEXT_ROOT); 335 remove(PRECOMPILE_JSP); 336 remove(VERIFY); 337 remove(ENABLE); 338 remove(VIRTUAL_SERVERS); 339 remove(NAME); 340 remove(TYPE); 341 remove(ARCHIVE_NAME); 342 remove(CASCADE); 343 remove(REDEPLOY); 344 remove(GENERATE_RMI_STUBS); 345 remove(AVAILABILITY_ENABLED); 346 remove(DEPLOY_OPTION_JAVA_WEB_START_ENABLED_KEY); 347 remove(DEPLOY_OPTION_LIBRARIES_KEY); 348 remove(RESOURCE_ACTION); 349 remove(RESOURCE_TARGET_LIST); 350 return this; 351 } 352 353 public String getDefaultContextRoot(String filePath) { 355 return getDefaultComponentName(filePath); 356 } 357 358 private String getDefaultComponentName(String filePath) { 359 final String fileName = new File (filePath).getName(); 360 int toIndex = fileName.lastIndexOf('.'); 361 if (toIndex < 0) { 362 toIndex = fileName.length(); 363 } 364 final String name = fileName.substring(0, toIndex); 365 return name; 367 } 368 369 private static void initializeKeyMap() { 380 keyMap = new HashMap (); 381 keyMap.put(REDEPLOY, DEPLOY_OPTION_REDEPLOY_KEY); 382 keyMap.put(DEPLOY_OPTION_REDEPLOY_KEY, REDEPLOY); 383 keyMap.put(FORCE, DEPLOY_OPTION_FORCE_KEY); 384 keyMap.put(DEPLOY_OPTION_FORCE_KEY, FORCE); 385 keyMap.put(CASCADE, DEPLOY_OPTION_CASCADE_KEY); 386 keyMap.put(DEPLOY_OPTION_CASCADE_KEY, CASCADE); 387 keyMap.put(VERIFY, DEPLOY_OPTION_VERIFY_KEY); 388 keyMap.put(DEPLOY_OPTION_VERIFY_KEY, VERIFY); 389 keyMap.put(VIRTUAL_SERVERS, DEPLOY_OPTION_VIRTUAL_SERVERS_KEY); 390 keyMap.put(DEPLOY_OPTION_VIRTUAL_SERVERS_KEY, VIRTUAL_SERVERS); 391 keyMap.put(PRECOMPILE_JSP, DEPLOY_OPTION_PRECOMPILE_JSP_KEY); 392 keyMap.put(DEPLOY_OPTION_PRECOMPILE_JSP_KEY, PRECOMPILE_JSP); 393 keyMap.put(ENABLE, DEPLOY_OPTION_ENABLE_KEY); 394 keyMap.put(DEPLOY_OPTION_ENABLE_KEY, ENABLE); 395 keyMap.put(CONTEXT_ROOT, DEPLOY_OPTION_CONTEXT_ROOT_KEY); 396 keyMap.put(DEPLOY_OPTION_CONTEXT_ROOT_KEY, CONTEXT_ROOT); 397 keyMap.put(NAME, DEPLOY_OPTION_NAME_KEY); 398 keyMap.put(DEPLOY_OPTION_NAME_KEY, NAME); 399 keyMap.put(DESCRIPTION, DEPLOY_OPTION_DESCRIPTION_KEY); 400 keyMap.put(DEPLOY_OPTION_DESCRIPTION_KEY, DESCRIPTION); 401 keyMap.put(GENERATE_RMI_STUBS, DEPLOY_OPTION_GENERATE_RMI_STUBS_KEY); 402 keyMap.put(DEPLOY_OPTION_GENERATE_RMI_STUBS_KEY, GENERATE_RMI_STUBS); 403 keyMap.put(AVAILABILITY_ENABLED, DEPLOY_OPTION_AVAILABILITY_ENABLED_KEY); 404 keyMap.put(DEPLOY_OPTION_AVAILABILITY_ENABLED_KEY, AVAILABILITY_ENABLED); 405 } 406 407 public static final String WSDL_TARGET_HINT = "wsdlTargetHint"; 411 public static final String TARGET = "target"; 412 public static final String REDEPLOY = "redeploy"; 413 public static final String DEFAULT_REDEPLOY = "false"; 414 public static final String FORCE = "force"; 415 public static final String DEFAULT_FORCE = "true"; 416 public static final String RELOAD = "reload"; 417 public static final String DEFAULT_RELOAD = "false"; 418 public static final String CASCADE = "cascade"; 419 public static final String DEFAULT_CASCADE = "false"; 420 public static final String VERIFY = "verify"; 421 public static final String DEFAULT_VERIFY = "false"; 422 public static final String VIRTUAL_SERVERS = "virtualservers"; 423 public static final String DEFAULT_VIRTUAL_SERVERS = null; 424 public static final String PRECOMPILE_JSP = "precompilejsp"; 425 public static final String DEFAULT_PRECOMPILE_JSP = "false"; 426 public static final String GENERATE_RMI_STUBS = "generatermistubs"; 427 public static final String DEFAULT_GENERATE_RMI_STUBS= "false"; 428 public static final String AVAILABILITY_ENABLED = "availabilityenabled"; 429 public static final String DEFAULT_AVAILABILITY_ENABLED = "false"; 430 public static final String ENABLE = "enable"; 431 public static final String DEFAULT_ENABLE = "true"; 432 public static final String CONTEXT_ROOT = "contextRoot"; 433 public static final String ARCHIVE_NAME = "archiveName"; 434 public static final String NAME = "name"; 435 public static final String TYPE = "type"; 436 public static final String DESCRIPTION = "description"; 437 public static final String CLIENTJARREQUESTED = "clientJarRequested"; 438 439 public static final String MODULE_ID = "moduleid"; 443 444 445 public static final String KEY_PREFIX = "X-DeploymentMgr."; 447 public static final String DEPLOY_OPTION_REDEPLOY_KEY = 448 KEY_PREFIX + "Redeploy"; 449 public static final String DEPLOY_OPTION_FORCE_KEY = KEY_PREFIX + "Force"; 450 public static final String DEPLOY_OPTION_CASCADE_KEY = KEY_PREFIX + "Cascade"; 451 public static final String DEPLOY_OPTION_VERIFY_KEY = KEY_PREFIX + "Verify"; 452 public static final String DEPLOY_OPTION_VIRTUAL_SERVERS_KEY = 453 KEY_PREFIX + "VirtualServers"; 454 public static final String DEPLOY_OPTION_PRECOMPILE_JSP_KEY = 455 KEY_PREFIX + "PrecompileJSP"; 456 public static final String DEPLOY_OPTION_ENABLE_KEY = KEY_PREFIX + "Enable"; 457 public static final String DEPLOY_OPTION_CONTEXT_ROOT_KEY = 458 KEY_PREFIX + "ContextRoot"; 459 public static final String DEPLOY_OPTION_NAME_KEY = KEY_PREFIX + "Name"; 460 public static final String DEPLOY_OPTION_DESCRIPTION_KEY = 461 KEY_PREFIX + "Description"; 462 public static final String DEPLOY_OPTION_GENERATE_RMI_STUBS_KEY = 463 KEY_PREFIX + "GenerateRMIStubs"; 464 public static final String DEPLOY_OPTION_AVAILABILITY_ENABLED_KEY = 465 KEY_PREFIX + "AvailabilityEnabled"; 466 467 468 public static final String DEPLOY_OPTION_JAVA_WEB_START_ENABLED_KEY = 471 KEY_PREFIX + "JavaWebStartEnabled"; 472 public static final String DEPLOY_OPTION_LIBRARIES_KEY = 473 KEY_PREFIX + "Libraries"; 474 public static final String DEFAULT_JAVA_WEB_START_ENABLED = "true"; 475 476 public static final String RESOURCE_ACTION = "resourceAction"; 478 public static final String RESOURCE_TARGET_LIST = "resourceTargetList"; 479 480 public static final String RES_DEPLOYMENT = "resDeployment"; 482 public static final String RES_CREATE_REF = "resCreateRef"; 483 public static final String RES_DELETE_REF = "resDeleteRef"; 484 public static final String RES_UNDEPLOYMENT = "resUndeployment"; 485 public static final String RES_REDEPLOYMENT = "resRedeployment"; 486 public static final String RES_NO_OP = "resNoOp"; 487 488 static Map keyMap; 489 490 static { 491 initializeKeyMap(); 492 } 493 } 494 | Popular Tags |