1 23 package com.sun.enterprise.tools.verifier.tests.ejb.elements; 24 25 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest; 26 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck; 27 import java.util.*; 28 import java.util.logging.Level ; 29 30 import com.sun.enterprise.deployment.*; 31 import com.sun.enterprise.tools.verifier.*; 32 import com.sun.enterprise.tools.verifier.tests.*; 33 34 38 public class EjbLinkElement extends EjbTest implements EjbCheck { 39 40 46 public Result check(EjbDescriptor descriptor) { 47 48 Result result = getInitializedResult(); 49 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 50 51 boolean resolved = false; 52 boolean oneFailed = false; 53 int na = 0; 54 55 71 72 if (!descriptor.getEjbReferenceDescriptors().isEmpty()) { 76 for (Iterator itr = descriptor.getEjbReferenceDescriptors().iterator(); 77 itr.hasNext();) { 78 EjbReferenceDescriptor nextEjbReference = (EjbReferenceDescriptor) itr.next(); 79 if (nextEjbReference.isLinked()) { 80 String ejb_link = nextEjbReference.getLinkName(); 81 ejb_link = ejb_link.substring(ejb_link.indexOf("#") + 1); 82 83 try { 84 85 Set ejbBundles = descriptor.getApplication().getEjbBundleDescriptors(); 89 Iterator ejbBundlesIterator = ejbBundles.iterator(); 90 EjbBundleDescriptor ejbBundle = null; 91 92 while (ejbBundlesIterator.hasNext()) { 93 ejbBundle = (EjbBundleDescriptor)ejbBundlesIterator.next(); 94 for (Iterator itr2 = ejbBundle.getEjbs().iterator(); itr2.hasNext();) { 98 99 EjbDescriptor ejbDescriptor = (EjbDescriptor) itr2.next(); 100 if (ejbDescriptor.getName().equals(ejb_link)) { 101 resolved = true; 102 logger.log(Level.FINE, getClass().getName() + ".passed", 103 new Object [] {ejb_link,ejbDescriptor.getName()}); 104 addGoodDetails(result, compName); 105 result.addGoodDetails 106 (smh.getLocalString 107 (getClass().getName() + ".passed", 108 "Valid referenced bean [ {0} ].", 109 new Object [] {ejb_link})); 110 break; 111 } 112 } 113 114 } 115 } catch(Exception e) { 116 addErrorDetails(result, compName); 117 result.addErrorDetails(smh.getLocalString 118 (getClass().getName() + ".failedException1", 119 "Exception occured while opening or saving the J2EE archive.", 120 new Object [] {})); 121 logger.log(Level.FINE, "com.sun.enterprise.tools.verifier.testsprint", 122 new Object [] {"[" + getClass() + "] Error: " + e.getMessage()}); 123 124 if (!oneFailed) { 125 oneFailed = true; 126 } 127 } 128 129 if (!resolved) { 132 if (!oneFailed) { 133 oneFailed = true; 134 } 135 addErrorDetails(result, compName); 136 result.addErrorDetails(smh.getLocalString 137 (getClass().getName() + ".failed", 138 "Error: No EJB matching [ {0} ] found within [ {1} ] jar file.", 139 new Object [] {ejb_link, descriptor.getName()})); 140 } else { 141 resolved =false; 143 } 144 145 } else { 146 addNaDetails(result, compName); 151 result.addNaDetails 152 (smh.getLocalString 153 (getClass().getName() + ".notApplicable1", 154 "Warning: Cannot verify the existence of an ejb reference [ {0} ] to external bean within different .ear file.", 155 new Object [] {nextEjbReference.getName()})); 156 na++; 157 } 158 } 159 160 if (oneFailed) { 161 result.setStatus(Result.FAILED); 162 } else if (na == descriptor.getEjbReferenceDescriptors().size()) { 163 result.setStatus(Result.NOT_APPLICABLE); 164 } else { 165 result.setStatus(Result.PASSED); 166 } 167 return result; 171 172 } else { 173 addNaDetails(result, compName); 174 result.notApplicable(smh.getLocalString 175 (getClass().getName() + ".notApplicable", 176 "There are no ejb references to other beans within this bean [ {0} ]", 177 new Object [] {descriptor.getName()})); 178 } 179 180 return result; 181 } 182 } 183 | Popular Tags |