Search in sources :

Example 6 with InterceptorBindingDescriptor

use of org.glassfish.ejb.deployment.descriptor.InterceptorBindingDescriptor in project Payara by payara.

the class InterceptorBindingTranslator method processMethod.

private void processMethod(MethodDescriptor businessMethod, List<InterceptorBindingDescriptor> bindings) {
    LinkedList<String> tempDefaultInterceptorChain = new LinkedList<String>();
    LinkedList<String> tempClassInterceptorChain = new LinkedList<String>();
    LinkedList<String> tempMethodInterceptorChain = new LinkedList<String>();
    if (hasTotalClassLevelOrdering) {
        tempClassInterceptorChain.addAll(totalClassLevelOrdering);
    } else {
        tempDefaultInterceptorChain.addAll(defaultInterceptorChain);
        tempClassInterceptorChain.addAll(classInterceptorChain);
    }
    for (InterceptorBindingDescriptor nextBinding : bindings) {
        if (nextBinding.getExcludeDefaultInterceptors()) {
            if (hasTotalClassLevelOrdering) {
                tempClassInterceptorChain.removeAll(defaultInterceptorChain);
            } else {
                tempDefaultInterceptorChain.clear();
            }
        }
        if (nextBinding.getExcludeClassInterceptors()) {
            if (hasTotalClassLevelOrdering) {
                tempClassInterceptorChain.removeAll(classInterceptorChain);
            } else {
                tempClassInterceptorChain.clear();
            }
        }
        if (nextBinding.getIsTotalOrdering()) {
            tempDefaultInterceptorChain.clear();
            tempClassInterceptorChain.clear();
            tempMethodInterceptorChain.clear();
        }
        tempMethodInterceptorChain.addAll(nextBinding.getInterceptorClasses());
    }
    LinkedList<String> methodInterceptors = new LinkedList<String>();
    methodInterceptors.addAll(tempDefaultInterceptorChain);
    methodInterceptors.addAll(tempClassInterceptorChain);
    methodInterceptors.addAll(tempMethodInterceptorChain);
    methodInterceptorsMap.put(businessMethod, methodInterceptors);
}
Also used : InterceptorBindingDescriptor(org.glassfish.ejb.deployment.descriptor.InterceptorBindingDescriptor) LinkedList(java.util.LinkedList)

Example 7 with InterceptorBindingDescriptor

use of org.glassfish.ejb.deployment.descriptor.InterceptorBindingDescriptor in project Payara by payara.

the class ExcludeDefaultInterceptorsHandler method processAnnotation.

protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
    EjbBundleDescriptorImpl ejbBundle = ((EjbDescriptor) ejbContexts[0].getDescriptor()).getEjbBundleDescriptor();
    for (EjbContext next : ejbContexts) {
        EjbDescriptor ejbDescriptor = (EjbDescriptor) next.getDescriptor();
        // Create binding information.
        InterceptorBindingDescriptor binding = new InterceptorBindingDescriptor();
        binding.setEjbName(ejbDescriptor.getName());
        binding.setExcludeDefaultInterceptors(true);
        if (ElementType.METHOD.equals(ainfo.getElementType())) {
            Method m = (Method) ainfo.getAnnotatedElement();
            MethodDescriptor md = new MethodDescriptor(m, MethodDescriptor.EJB_BEAN);
            binding.setBusinessMethod(md);
        } else if (ElementType.CONSTRUCTOR.equals(ainfo.getElementType())) {
            Constructor c = (Constructor) ainfo.getAnnotatedElement();
            Class cl = c.getDeclaringClass();
            Class[] ctorParamTypes = c.getParameterTypes();
            String[] parameterClassNames = (new MethodDescriptor()).getParameterClassNamesFor(null, ctorParamTypes);
            MethodDescriptor md = new MethodDescriptor(cl.getSimpleName(), null, parameterClassNames, MethodDescriptor.EJB_BEAN);
            binding.setBusinessMethod(md);
        }
        ejbBundle.prependInterceptorBinding(binding);
    }
    return getDefaultProcessedResult();
}
Also used : EjbContext(com.sun.enterprise.deployment.annotation.context.EjbContext) InterceptorBindingDescriptor(org.glassfish.ejb.deployment.descriptor.InterceptorBindingDescriptor) Constructor(java.lang.reflect.Constructor) Method(java.lang.reflect.Method) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor) EjbDescriptor(org.glassfish.ejb.deployment.descriptor.EjbDescriptor) EjbBundleDescriptorImpl(org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)

Aggregations

InterceptorBindingDescriptor (org.glassfish.ejb.deployment.descriptor.InterceptorBindingDescriptor)7 MethodDescriptor (com.sun.enterprise.deployment.MethodDescriptor)5 Method (java.lang.reflect.Method)4 EjbDescriptor (org.glassfish.ejb.deployment.descriptor.EjbDescriptor)4 EjbContext (com.sun.enterprise.deployment.annotation.context.EjbContext)3 Constructor (java.lang.reflect.Constructor)3 LinkedList (java.util.LinkedList)3 EjbBundleDescriptorImpl (org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)3 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Interceptors (javax.interceptor.Interceptors)1 DummyEjbDescriptor (org.glassfish.ejb.deployment.descriptor.DummyEjbDescriptor)1