1 23 24 25 package com.sun.enterprise.tools.verifier.persistence; 26 27 import com.sun.enterprise.tools.verifier.*; 28 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor; 29 import com.sun.enterprise.deployment.Descriptor; 30 import com.sun.enterprise.deployment.PersistenceUnitDescriptor; 31 import com.sun.enterprise.deployment.BundleDescriptor; 32 import com.sun.enterprise.deployment.RootDeploymentDescriptor; 33 import com.sun.enterprise.deployment.util.ModuleDescriptor; 34 import com.sun.enterprise.util.io.FileUtils; 35 import com.sun.enterprise.util.LocalStringManagerImpl; 36 37 import javax.enterprise.deploy.shared.ModuleType ; 38 import java.io.File ; 39 40 46 public class PersistenceUnitCheckMgrImpl extends CheckMgr { 47 48 private String moduleName; 51 private LocalStringManagerImpl smh = StringManagerHelper.getLocalStringsManager(); 52 53 54 public PersistenceUnitCheckMgrImpl( 55 FrameworkContext frameworkContext, Context context) { 56 this.frameworkContext = frameworkContext; 57 this.context = context; 58 } 59 60 @Override protected void check(Descriptor descriptor) throws Exception { 61 PersistenceUnitDescriptor pu = 62 PersistenceUnitDescriptor.class.cast(descriptor); 63 RootDeploymentDescriptor rootDD = pu.getParent().getParent(); 64 if(rootDD.isApplication()) { 65 moduleName = Result.APP; 66 } else { 67 ModuleDescriptor mdesc = 68 BundleDescriptor.class.cast(rootDD).getModuleDescriptor(); 69 final ModuleType moduleType = mdesc.getModuleType(); 70 if(moduleType == ModuleType.EJB) { 71 moduleName = Result.EJB; 72 } else if (moduleType == ModuleType.WAR) { 73 moduleName = Result.WEB; 74 } else if (moduleType == ModuleType.CAR) { 75 moduleName = Result.APPCLIENT; 76 } else { 77 throw new RuntimeException ( 78 smh.getLocalString(getClass().getName()+".exception", "Unknown module type : {0}", new Object [] {moduleType})); 81 } 82 } 83 super.check(descriptor); 84 } 85 86 90 @Override protected void setRuntimeDDPresent(String uri) { 91 isDDPresent = false; 92 } 93 94 protected ComponentNameConstructor getComponentNameConstructor( 95 Descriptor descriptor) { 96 return new ComponentNameConstructor( 97 PersistenceUnitDescriptor.class.cast(descriptor)); 98 } 99 100 protected String getTestsListFileName() { 101 return "TestNamesPersistence.xml"; } 103 104 protected void setModuleName(Result r) { 105 r.setModuleName(moduleName); 106 } 107 108 protected String getSchemaVersion(Descriptor descriptor) { 109 return PersistenceUnitDescriptor.class.cast(descriptor).getParent(). 111 getSpecVersion(); 112 } 113 114 protected String getSunONETestsListFileName() { 115 return null; 116 } 117 118 123 protected String getAbstractArchiveUri(Descriptor descriptor) { 124 String archBase = context.getAbstractArchive().getArchiveUri(); 125 RootDeploymentDescriptor rootDD = 126 PersistenceUnitDescriptor.class.cast(descriptor).getParent().getParent(); 127 if(rootDD.isApplication()) { 128 return archBase; 129 } else { 130 ModuleDescriptor mdesc = 131 BundleDescriptor.class.cast(rootDD).getModuleDescriptor(); 132 if(mdesc.isStandalone()) { 133 return archBase; 134 } else { 135 return archBase + File.separator + 136 FileUtils.makeFriendlyFileName(mdesc.getArchiveUri()); 137 } 138 } 139 } 140 } 141 | Popular Tags |