1 23 24 package com.sun.enterprise.tools.verifier.tests.ejb; 25 26 27 import com.sun.enterprise.tools.verifier.tests.VerifierTest; 28 import com.sun.enterprise.tools.verifier.tests.VerifierCheck; 29 import com.sun.enterprise.tools.verifier.*; 30 import com.sun.enterprise.deployment.*; 31 import com.sun.enterprise.deployment.util.ModuleDescriptor; 32 import com.sun.enterprise.tools.verifier.Verifier; 33 import java.lang.ClassLoader ; 34 import com.sun.enterprise.tools.verifier.tests.*; 35 import com.sun.enterprise.util.io.FileUtils; 36 37 import java.io.File ; 38 39 45 public abstract class EjbTest extends VerifierTest implements VerifierCheck, EjbCheck 46 { 47 57 public Result check(Descriptor descriptor) { 58 59 try { 60 return check((EjbDescriptor) descriptor); 61 } 62 catch(Throwable t) { 63 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 66 Result r = getInitializedResult(); 67 68 if (t instanceof java.lang.NoClassDefFoundError ) { 69 70 String s = t.toString(); 71 String className = s.substring(s.indexOf(":")); 72 73 addWarningDetails(r, compName); 74 r.warning(smh.getLocalString 75 ("com.sun.enterprise.tools.verifier.checkinclasspath", 76 "The class [ {0} ] was not found, check manifest classpath, or make sure it is available in classpath at runtime.", 77 new Object [] {className})); 78 return r; 79 } 80 else 81 throw new RuntimeException (t); 82 } 83 } 84 85 95 public abstract Result check(EjbDescriptor descriptor); 96 97 106 protected Class loadEjbClass(EjbDescriptor descriptor, Result result) { 107 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 108 109 try { 110 return Class.forName(descriptor.getEjbClassName(), false, getVerifierContext().getClassLoader()); 111 } catch (ClassNotFoundException e) { 112 Verifier.debug(e); 113 addErrorDetails(result, compName); 114 result.failed(smh.getLocalString 115 ("com.sun.enterprise.tools.verifier.tests.ejb.EjbTest.failedException", 116 "Error: [ {0} ] class not found.", 117 new Object [] {descriptor.getEjbClassName()})); 118 return null; 119 } 120 } 121 122 protected String getAbstractArchiveUri(EjbDescriptor desc) { 123 String archBase = getVerifierContext().getAbstractArchive(). 124 getArchiveUri(); 125 final ModuleDescriptor moduleDescriptor = desc.getEjbBundleDescriptor(). 126 getModuleDescriptor(); 127 if (moduleDescriptor.isStandalone()) { 128 return archBase; } else { 130 return archBase + File.separator + 131 FileUtils.makeFriendlyFileName(moduleDescriptor.getArchiveUri()); 132 } 133 } 134 135 public boolean implementsEndpoints(EjbDescriptor descriptor) { 136 137 BundleDescriptor bdesc = descriptor.getEjbBundleDescriptor(); 138 if (bdesc.hasWebServices()) { 139 WebServicesDescriptor wdesc = bdesc.getWebServices(); 140 if (wdesc.hasEndpointsImplementedBy(descriptor)) 141 return true; 142 } 143 return false; 144 } 145 public String getArchiveURI(EjbDescriptor desc){ 146 return getAbstractArchiveUri(desc); 148 159 160 161 } 162 } 163 | Popular Tags |