1 23 package com.sun.enterprise.tools.verifier.tests.ejb; 24 25 import java.util.Iterator ; 26 27 import com.sun.enterprise.deployment.EjbDescriptor; 28 import com.sun.enterprise.tools.verifier.Result; 29 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor; 30 31 35 public class EjbNameUnique extends EjbTest implements EjbCheck { 36 37 45 public Result check(EjbDescriptor descriptor) { 46 47 Result result = getInitializedResult(); 48 String ejbName = descriptor.getName(); 49 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 50 51 int found = 0; 53 54 for (Iterator itr =descriptor.getEjbBundleDescriptor().getEjbs().iterator(); 60 itr.hasNext();) { 61 EjbDescriptor ejbDescriptor = (EjbDescriptor) itr.next(); 62 if (ejbDescriptor.getName().equals(ejbName)) { 63 found++; 64 if (found > 1) { 65 addErrorDetails(result, compName); 66 result.failed(smh.getLocalString 67 (getClass().getName() + ".failed", 68 "Error: [ {0} ] has found [ {1} ] duplicate ejb name(s) within the same jar.", 69 new Object [] {ejbName, new Integer ((found - 1))})); 70 } 71 } 72 } 73 74 if (result.getStatus() != Result.FAILED) { 75 addGoodDetails(result, compName); 76 result.passed(smh.getLocalString 77 (getClass().getName() + ".passed", 78 "Valid: [ {0} ] was found once within jar, ejb-name is unique.", 79 new Object [] {ejbName})); 80 } 81 return result; 82 } 83 } 84 | Popular Tags |