1 23 package com.sun.enterprise.tools.verifier.tests.ejb.session; 24 25 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest; 26 import java.util.logging.Level ; 27 28 import com.sun.enterprise.tools.verifier.tests.*; 29 import com.sun.enterprise.deployment.EjbDescriptor; 30 import com.sun.enterprise.deployment.EjbSessionDescriptor; 31 import com.sun.enterprise.tools.verifier.*; 32 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck; 33 34 41 public class SessionSynchronizationInterface extends EjbTest implements EjbCheck { 42 43 54 public Result check(EjbDescriptor descriptor) { 55 56 Result result = getInitializedResult(); 57 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 58 59 if (descriptor instanceof EjbSessionDescriptor) { 60 String stateType = ((EjbSessionDescriptor)descriptor).getSessionType(); 61 try { 62 Class c = Class.forName(descriptor.getEjbClassName(), false, getVerifierContext().getClassLoader()); 63 do { 65 for(Class interfaces : c.getInterfaces()) { 68 logger.log(Level.FINE, getClass().getName() + ".debug1", 69 new Object [] {interfaces.getName()}); 70 71 if (interfaces.getName().equals("javax.ejb.SessionSynchronization") ) { 72 String transactionType = descriptor.getTransactionType(); 73 if ((EjbSessionDescriptor.STATELESS.equals(stateType)) || 74 ((EjbSessionDescriptor.STATEFUL.equals(stateType)) 75 && EjbSessionDescriptor.BEAN_TRANSACTION_TYPE 76 .equals(transactionType) )) { 77 addErrorDetails(result, compName); 78 result.failed(smh.getLocalString 79 (getClass().getName() + ".failed", 80 "Error: [ {0} ] does not properly implement the SessionSynchronization interface. " + 81 " SessionSynchronization interface must not be implemented by a stateless Session Bean. " + 82 "[ {1} ] is not a valid bean.", 83 new Object [] {descriptor.getEjbClassName(),descriptor.getEjbClassName()})); 84 break; 85 86 } 87 } 88 } 89 } while ((c=c.getSuperclass()) != null); 90 91 } catch (ClassNotFoundException e) { 92 Verifier.debug(e); 93 result.addErrorDetails(smh.getLocalString 94 ("tests.componentNameConstructor", 95 "For [ {0} ]", 96 new Object [] {compName.toString()})); 97 result.failed(smh.getLocalString 98 (getClass().getName() + ".failedException", 99 "Error: [ {0} ] class not found.", 100 new Object [] {descriptor.getEjbClassName()})); 101 } 102 } 103 104 if (result.getStatus()!=Result.FAILED) { 105 addGoodDetails(result, compName); 106 result.passed(smh.getLocalString(getClass().getName() + ".passed", 107 "The required interface is properly implemented")); 108 } 109 return result; 110 } 111 } 112 | Popular Tags |