FileDocCategorySizeDatePackage
CallbacksOnBeanClass.javaAPI DocGlassfish v2 API6368Fri May 04 22:33:34 BST 2007com.sun.enterprise.tools.verifier.tests.ejb.ejb30

CallbacksOnBeanClass

public class CallbacksOnBeanClass extends com.sun.enterprise.tools.verifier.tests.ejb.EjbTest
If the PostConstruct lifecycle callback interceptor method is the ejbCreate method, if the PreDestroy lifecycle callback interceptor method is the ejbRemove method, if the PostActivate lifecycle callback interceptor method is the ejbActivate method, or if the Pre-Passivate lifecycle callback interceptor method is the ejbPassivate method, these callback methods must be implemented on the bean class itself (or on its superclasses).
author
Vikas Awasthi

Fields Summary
com.sun.enterprise.tools.verifier.Result
result
com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor
compName
Constructors Summary
Methods Summary
public com.sun.enterprise.tools.verifier.Resultcheck(com.sun.enterprise.deployment.EjbDescriptor descriptor)

    
        
        result = getInitializedResult();
        compName = getVerifierContext().getComponentNameConstructor();
        
        Set<EjbInterceptor> interceptors = descriptor.getInterceptorClasses();
        for (EjbInterceptor interceptor : interceptors) {
            if (interceptor.hasCallbackDescriptor(
                    LifecycleCallbackDescriptor.CallbackType.POST_ACTIVATE)) {
                Set<LifecycleCallbackDescriptor> callBackDescs = 
                        interceptor.getCallbackDescriptors(
                                LifecycleCallbackDescriptor.CallbackType.POST_ACTIVATE);
                reportError(callBackDescs, "ejbActivate",interceptor.getInterceptorClassName());
            }
            if (interceptor.hasCallbackDescriptor(
                    LifecycleCallbackDescriptor.CallbackType.PRE_PASSIVATE)) {
                Set<LifecycleCallbackDescriptor> callBackDescs = 
                        interceptor.getCallbackDescriptors(
                                LifecycleCallbackDescriptor.CallbackType.PRE_PASSIVATE);
                reportError(callBackDescs, "ejbPassivate",interceptor.getInterceptorClassName());
            }
            if (interceptor.hasCallbackDescriptor(
                    LifecycleCallbackDescriptor.CallbackType.POST_CONSTRUCT)) {
                Set<LifecycleCallbackDescriptor> callBackDescs = 
                        interceptor.getCallbackDescriptors(
                                LifecycleCallbackDescriptor.CallbackType.POST_CONSTRUCT);
                reportError(callBackDescs, "ejbCreate",interceptor.getInterceptorClassName());
            }
            if (interceptor.hasCallbackDescriptor(
                    LifecycleCallbackDescriptor.CallbackType.PRE_DESTROY)) {
                Set<LifecycleCallbackDescriptor> callBackDescs = 
                        interceptor.getCallbackDescriptors(
                                LifecycleCallbackDescriptor.CallbackType.PRE_DESTROY);
                reportError(callBackDescs, "ejbRemove",interceptor.getInterceptorClassName());
            }
        }
        
        if(result.getStatus() != Result.FAILED) {
            addGoodDetails(result, compName);
            result.passed(smh.getLocalString
                            (getClass().getName()+".passed",
                            "Valid lifecycle callback method(s)"));
        }
        return result;
    
private voidreportError(java.util.Set callBackDescs, java.lang.String callbackMethodName, java.lang.String interceptorClassName)

        for (LifecycleCallbackDescriptor callbackDesc : callBackDescs) {
            String callbackMethod = callbackDesc.getLifecycleCallbackMethod();
            if(callbackMethod.contains(callbackMethodName)) {
                result.getFaultLocation().setFaultyClassName(interceptorClassName);
                result.getFaultLocation().setFaultyMethodName(callbackMethod);
                addErrorDetails(result, compName);
                result.failed(smh.getLocalString
                        (getClass().getName()+".failed",
                        "Wrong method [ {0} ] in class [ {1} ]",
                        new Object[] {callbackMethod, interceptorClassName}));
            }
        }