1 23 package com.sun.enterprise.deployment; 24 25 import java.util.*; 26 import javax.enterprise.deploy.shared.ModuleType ; 27 import java.util.logging.*; 28 import com.sun.enterprise.deployment.util.DOLUtils; 29 30 37 public abstract class RootDeploymentDescriptor extends Descriptor { 38 39 42 protected String moduleID; 43 44 47 private String specVersion; 48 49 53 protected ClassLoader classLoader = null; 54 55 58 protected Map<String , PersistenceUnitsDescriptor> persistenceUnitsDescriptors 59 = new HashMap<String , PersistenceUnitsDescriptor>(); 60 61 64 public RootDeploymentDescriptor() { 65 super(); 66 } 67 68 71 public RootDeploymentDescriptor(String name, String description) { 72 super(name, description); 73 } 74 75 79 public void setModuleID(String moduleID) { 80 this.moduleID = moduleID; 81 } 82 83 86 public abstract String getModuleID(); 87 88 92 public abstract String getDefaultSpecVersion(); 93 94 95 99 public String getSpecVersion() { 100 if (specVersion == null) { 101 specVersion = getDefaultSpecVersion(); 102 } 103 try { 104 Double.parseDouble(specVersion); 105 } catch (NumberFormatException nfe) { 106 DOLUtils.getDefaultLogger().log(Level.WARNING, "invalidSpecVersion", 107 new Object [] {specVersion, getDefaultSpecVersion()}); 108 specVersion = getDefaultSpecVersion(); 109 } 110 111 return specVersion; 112 } 113 114 118 public void setSpecVersion(String specVersion) { 119 this.specVersion = specVersion; 120 } 121 122 125 public abstract ModuleType getModuleType(); 126 127 130 public void setClassLoader(ClassLoader classLoader) { 131 this.classLoader = classLoader; 132 } 133 134 137 public abstract ClassLoader getClassLoader(); 138 139 142 public void setDisplayName(String name) { 143 super.setName(name); 144 } 145 146 149 public String getDisplayName() { 150 return super.getName(); 151 } 152 153 158 public void setName(String name) { 159 setModuleID(name); 160 } 161 162 168 public String getName() { 169 if (getModuleID()!=null) { 170 return getModuleID(); 171 } else { 172 return getDisplayName(); 173 } 174 } 175 176 public void setSchemaLocation(String schemaLocation) { 177 addExtraAttribute("schema-location", schemaLocation); 178 } 179 180 public String getSchemaLocation() { 181 return (String ) getExtraAttribute("schema-location"); 182 } 183 184 187 public abstract boolean isApplication(); 188 189 192 public void print(StringBuffer toStringBuffer) { 193 super.print(toStringBuffer); 194 toStringBuffer.append("\n Module Type = ").append(getModuleType()); 195 toStringBuffer.append("\n Module spec version = ").append(getSpecVersion()); 196 if (moduleID!=null) 197 toStringBuffer.append("\n Module ID = ").append(moduleID); 198 if (getSchemaLocation()!=null) 199 toStringBuffer.append("\n Client SchemaLocation = ").append(getSchemaLocation()); 200 } 201 202 208 public Collection<PersistenceUnitsDescriptor> getPersistenceUnitsDescriptors() { 209 return Collections.unmodifiableCollection(persistenceUnitsDescriptors.values()); 210 } 211 212 219 public PersistenceUnitsDescriptor getPersistenceUnitsDescriptor( 220 String puRoot) { 221 return persistenceUnitsDescriptors.get(puRoot); 222 } 223 224 234 public void addPersistenceUnitsDescriptor(String puRoot, PersistenceUnitsDescriptor persistenceUnitsDescriptor) { 235 assert(persistenceUnitsDescriptor.getParent() == null); 238 persistenceUnitsDescriptor.setParent(this); 239 persistenceUnitsDescriptor.setPuRoot(puRoot); 240 persistenceUnitsDescriptors.put(puRoot, persistenceUnitsDescriptor); 241 } 242 243 } 244 245 | Popular Tags |