1 23 24 25 package com.sun.enterprise.deployment; 26 27 import com.sun.enterprise.deployment.util.ModuleDescriptor; 28 import com.sun.enterprise.util.io.FileUtils; 29 30 import javax.enterprise.deploy.shared.ModuleType ; 31 import java.util.List ; 32 import java.util.ArrayList ; 33 import java.util.Collections ; 34 35 40 public class PersistenceUnitsDescriptor extends RootDeploymentDescriptor { 41 42 43 private RootDeploymentDescriptor parent; 44 45 53 private String puRoot; 54 55 List <PersistenceUnitDescriptor> persistenceUnitDescriptors = 56 new ArrayList <PersistenceUnitDescriptor>(); 57 58 private static final String JPA_1_0 = "1.0"; 59 60 public PersistenceUnitsDescriptor() { 61 } 62 63 public RootDeploymentDescriptor getParent() { 64 return parent; 65 } 66 67 public void setParent(RootDeploymentDescriptor parent) { 68 this.parent = parent; 69 } 70 71 public String getPuRoot() { 72 return puRoot; 73 } 74 75 public void setPuRoot(String puRoot) { 76 this.puRoot = puRoot; 77 } 78 79 public String getDefaultSpecVersion() { 80 return JPA_1_0; 81 } 82 83 public String getModuleID() { 84 throw new RuntimeException (); 85 } 86 87 public ModuleType getModuleType() { 88 throw new RuntimeException (); 89 } 90 91 public ClassLoader getClassLoader() { 92 return parent.getClassLoader(); 93 } 94 95 public boolean isApplication() { 96 return false; 97 } 98 99 104 public void addPersistenceUnitDescriptor(PersistenceUnitDescriptor pud){ 105 persistenceUnitDescriptors.add(pud); 106 pud.setParent(this); 107 } 108 109 112 public List <PersistenceUnitDescriptor> getPersistenceUnitDescriptors() { 113 return Collections.unmodifiableList(persistenceUnitDescriptors); 114 } 115 116 125 public String getAbsolutePuRoot() { 126 RootDeploymentDescriptor rootDD = getParent(); 127 if(rootDD.isApplication()){ 128 return getPuRoot(); 129 } else { 130 ModuleDescriptor module = BundleDescriptor.class.cast(rootDD). 131 getModuleDescriptor(); 132 if(module.isStandalone()) { 133 return getPuRoot(); 134 } else { 135 final String moduleLocation = FileUtils.makeFriendlyFileName( 136 module.getArchiveUri()); 137 return moduleLocation + '/' + getPuRoot(); } 139 } 140 } 141 142 } 143 | Popular Tags |