Search in sources :

Example 1 with LifecycleCallbackDescriptor

use of com.sun.enterprise.deployment.LifecycleCallbackDescriptor in project Payara by payara.

the class WebBundleDescriptorImpl method addPreDestroyDescriptor.

@Override
public void addPreDestroyDescriptor(LifecycleCallbackDescriptor preDestroyDesc) {
    String className = preDestroyDesc.getLifecycleCallbackClass();
    boolean found = false;
    for (LifecycleCallbackDescriptor next : getPreDestroyDescriptors()) {
        if (next.getLifecycleCallbackClass().equals(className)) {
            found = true;
            break;
        }
    }
    if (!found) {
        getPreDestroyDescriptors().add(preDestroyDesc);
    }
}
Also used : LifecycleCallbackDescriptor(com.sun.enterprise.deployment.LifecycleCallbackDescriptor)

Example 2 with LifecycleCallbackDescriptor

use of com.sun.enterprise.deployment.LifecycleCallbackDescriptor in project Payara by payara.

the class WebBundleDescriptorImpl method addPostConstructDescriptor.

@Override
public void addPostConstructDescriptor(LifecycleCallbackDescriptor postConstructDesc) {
    String className = postConstructDesc.getLifecycleCallbackClass();
    boolean found = false;
    for (LifecycleCallbackDescriptor next : getPostConstructDescriptors()) {
        if (next.getLifecycleCallbackClass().equals(className)) {
            found = true;
            break;
        }
    }
    if (!found) {
        getPostConstructDescriptors().add(postConstructDesc);
    }
}
Also used : LifecycleCallbackDescriptor(com.sun.enterprise.deployment.LifecycleCallbackDescriptor)

Example 3 with LifecycleCallbackDescriptor

use of com.sun.enterprise.deployment.LifecycleCallbackDescriptor in project Payara by payara.

the class AroundInvokeNotBusinessMethod method check.

public Result check(EjbDescriptor descriptor) {
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    ClassLoader cl = getVerifierContext().getClassLoader();
    if (descriptor.hasAroundInvokeMethod()) {
        Set<MethodDescriptor> businessMethods = descriptor.getMethodDescriptors();
        Set<LifecycleCallbackDescriptor> aiDescriptors = descriptor.getAroundInvokeDescriptors();
        for (LifecycleCallbackDescriptor aiDesc : aiDescriptors) {
            try {
                Method interceptorMethod = aiDesc.getLifecycleCallbackMethodObject(cl);
                MethodDescriptor interceptorMD = new MethodDescriptor(interceptorMethod);
                if (businessMethods.contains(interceptorMD)) {
                    addErrorDetails(result, compName);
                    result.failed(smh.getLocalString(getClass().getName() + ".failed", "AroundInvoke method [ {0} ] is a business method.", new Object[] { interceptorMethod }));
                }
            }// will be caught in other tests
             catch (Exception e) {
            }
        }
    }
    if (result.getStatus() != Result.FAILED) {
        addGoodDetails(result, compName);
        result.passed(smh.getLocalString(getClass().getName() + ".passed", "Valid Interceptor methods."));
    }
    return result;
}
Also used : LifecycleCallbackDescriptor(com.sun.enterprise.deployment.LifecycleCallbackDescriptor) Method(java.lang.reflect.Method) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor) ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) Result(com.sun.enterprise.tools.verifier.Result)

Example 4 with LifecycleCallbackDescriptor

use of com.sun.enterprise.deployment.LifecycleCallbackDescriptor in project Payara by payara.

the class EJBCreatePostConstruct method check.

public Result check(EjbSessionDescriptor descriptor) {
    if (descriptor.isStateless() && descriptor.hasPostConstructMethod() && hasEJBCreateMethod(descriptor.getEjbClassName())) {
        for (LifecycleCallbackDescriptor callbackDesc : descriptor.getPostConstructDescriptors()) {
            String cmName = callbackDesc.getLifecycleCallbackMethod();
            if (!cmName.contains("ejbCreate")) {
                addErrorDetails(result, compName);
                result.failed(smh.getLocalString(getClass().getName() + ".failed", "Wrong postconstruct method [ {0} ]", new Object[] { cmName }));
            }
        }
    }
    if (result.getStatus() != Result.FAILED) {
        addGoodDetails(result, compName);
        result.passed(smh.getLocalString(getClass().getName() + ".passed", "Valid postcontruct method(s) in Bean"));
    }
    return result;
}
Also used : LifecycleCallbackDescriptor(com.sun.enterprise.deployment.LifecycleCallbackDescriptor)

Example 5 with LifecycleCallbackDescriptor

use of com.sun.enterprise.deployment.LifecycleCallbackDescriptor in project Payara by payara.

the class CallbackMethodArgument method testInterceptorMethods.

void testInterceptorMethods(Set<LifecycleCallbackDescriptor> callbackDescs, String callbackMethodName, Boolean isBeanMethod) {
    if (callbackMethodName.equals("AroundInvoke"))
        // this test applies only to lifecycle callback methods
        return;
    ClassLoader cl = getVerifierContext().getClassLoader();
    for (LifecycleCallbackDescriptor callbackDesc : callbackDescs) {
        try {
            Method method = callbackDesc.getLifecycleCallbackMethodObject(cl);
            Class<?>[] args = method.getParameterTypes();
            if (isBeanMethod && args.length != 0) {
                logFailure(callbackMethodName, method);
            } else if (!isBeanMethod && (args.length != 1 || !javax.interceptor.InvocationContext.class.isAssignableFrom(args[0]))) {
                logFailure(callbackMethodName, method);
            }
        }// ignore as it will be caught in other tests
         catch (Exception e) {
        }
    }
}
Also used : LifecycleCallbackDescriptor(com.sun.enterprise.deployment.LifecycleCallbackDescriptor) Method(java.lang.reflect.Method)

Aggregations

LifecycleCallbackDescriptor (com.sun.enterprise.deployment.LifecycleCallbackDescriptor)40 Method (java.lang.reflect.Method)16 EjbInterceptor (com.sun.enterprise.deployment.EjbInterceptor)9 MethodDescriptor (com.sun.enterprise.deployment.MethodDescriptor)4 ArrayList (java.util.ArrayList)4 EJBException (javax.ejb.EJBException)4 InterceptorDescriptor (com.sun.enterprise.deployment.InterceptorDescriptor)3 EjbSessionDescriptor (org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor)3 EjbDescriptor (com.sun.enterprise.deployment.EjbDescriptor)2 ResourceContainerContext (com.sun.enterprise.deployment.annotation.context.ResourceContainerContext)2 Result (com.sun.enterprise.tools.verifier.Result)2 ComponentNameConstructor (com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor)2 HashSet (java.util.HashSet)2 Descriptor (org.glassfish.deployment.common.Descriptor)2 EjbDescriptor (org.glassfish.ejb.deployment.descriptor.EjbDescriptor)2 WebServiceEndpoint (com.sun.enterprise.deployment.WebServiceEndpoint)1 EjbContext (com.sun.enterprise.deployment.annotation.context.EjbContext)1 EjbInterceptorContext (com.sun.enterprise.deployment.annotation.context.EjbInterceptorContext)1 LinkedList (java.util.LinkedList)1 Set (java.util.Set)1