Search in sources :

Example 11 with EjbInterceptor

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

the class EjbDescriptor method getCallbackInterceptors.

/**
 * Common code to add the bean class as a LC interceptor
 */
private LinkedList<EjbInterceptor> getCallbackInterceptors(CallbackType type, Set<LifecycleCallbackDescriptor> callbackDescriptors) {
    LinkedList<EjbInterceptor> callbackInterceptors = new LinkedList<EjbInterceptor>();
    ClassLoader classLoader = getEjbBundleDescriptor().getClassLoader();
    List<EjbInterceptor> classOrMethodInterceptors = (type.equals(CallbackType.AROUND_CONSTRUCT)) ? getConstructorInterceptors(classLoader) : interceptorChain;
    for (EjbInterceptor next : classOrMethodInterceptors) {
        if (next.getCallbackDescriptors(type).size() > 0) {
            callbackInterceptors.add(next);
        }
    }
    if (callbackDescriptors != null && callbackDescriptors.size() > 0) {
        EjbInterceptor beanClassCallbackInfo = new EjbInterceptor();
        beanClassCallbackInfo.setFromBeanClass(true);
        beanClassCallbackInfo.addCallbackDescriptors(type, callbackDescriptors);
        beanClassCallbackInfo.setInterceptorClassName(getEjbImplClassName());
        callbackInterceptors.add(beanClassCallbackInfo);
    }
    return callbackInterceptors;
}
Also used : EjbInterceptor(com.sun.enterprise.deployment.EjbInterceptor) LinkedList(java.util.LinkedList)

Example 12 with EjbInterceptor

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

the class AroundInvokeNode method getDescriptor.

@Override
public LifecycleCallbackDescriptor getDescriptor() {
    if (descriptor == null) {
        descriptor = new LifecycleCallbackDescriptor();
        Descriptor parentDesc = (Descriptor) getParentNode().getDescriptor();
        if (parentDesc instanceof EjbDescriptor) {
            EjbDescriptor ejbDesc = (EjbDescriptor) parentDesc;
            descriptor.setDefaultLifecycleCallbackClass(ejbDesc.getEjbClassName());
        } else if (parentDesc instanceof EjbInterceptor) {
            EjbInterceptor ejbInterceptor = (EjbInterceptor) parentDesc;
            descriptor.setDefaultLifecycleCallbackClass(ejbInterceptor.getInterceptorClassName());
        }
    }
    return descriptor;
}
Also used : LifecycleCallbackDescriptor(com.sun.enterprise.deployment.LifecycleCallbackDescriptor) LifecycleCallbackDescriptor(com.sun.enterprise.deployment.LifecycleCallbackDescriptor) Descriptor(org.glassfish.deployment.common.Descriptor) EjbDescriptor(com.sun.enterprise.deployment.EjbDescriptor) EjbInterceptor(com.sun.enterprise.deployment.EjbInterceptor) EjbDescriptor(com.sun.enterprise.deployment.EjbDescriptor)

Example 13 with EjbInterceptor

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

the class AroundTimeoutHandler method processAnnotation.

protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbInterceptorContext ejbInterceptorContext) throws AnnotationProcessorException {
    EjbInterceptor ejbInterceptor = ejbInterceptorContext.getDescriptor();
    ejbInterceptor.addAroundTimeoutDescriptor(getAroundInvocationDescriptor(ainfo));
    return getDefaultProcessedResult();
}
Also used : EjbInterceptor(com.sun.enterprise.deployment.EjbInterceptor)

Example 14 with EjbInterceptor

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

the class InterceptorsHandler method processInterceptorClass.

private void processInterceptorClass(Class interceptorClass, EjbBundleDescriptorImpl ejbBundle, AnnotationInfo ainfo) throws AnnotationProcessorException {
    Set<LifecycleCallbackDescriptor> aroundInvokeDescriptors = new HashSet<LifecycleCallbackDescriptor>();
    Set<LifecycleCallbackDescriptor> aroundTimeoutDescriptors = new HashSet<LifecycleCallbackDescriptor>();
    Set<LifecycleCallbackDescriptor> postActivateDescriptors = new HashSet<LifecycleCallbackDescriptor>();
    Set<LifecycleCallbackDescriptor> prePassivateDescriptors = new HashSet<LifecycleCallbackDescriptor>();
    ComponentDefinition cdef = new ComponentDefinition(interceptorClass);
    for (Method m : cdef.getMethods()) {
        if (m.getAnnotation(AroundInvoke.class) != null) {
            aroundInvokeDescriptors.add(getLifecycleCallbackDescriptor(m));
        }
        if (m.getAnnotation(AroundTimeout.class) != null) {
            aroundTimeoutDescriptors.add(getLifecycleCallbackDescriptor(m));
        }
        if (m.getAnnotation(PostActivate.class) != null) {
            postActivateDescriptors.add(getLifecycleCallbackDescriptor(m));
        }
        if (m.getAnnotation(PrePassivate.class) != null) {
            prePassivateDescriptors.add(getLifecycleCallbackDescriptor(m));
        }
    }
    EjbInterceptor interceptor = ejbBundle.getInterceptorByClassName(interceptorClass.getName());
    if (interceptor == null) {
        interceptor = new EjbInterceptor();
        interceptor.setInterceptorClassName(interceptorClass.getName());
        // Add interceptor to the set of all interceptors in the ejb-jar
        ejbBundle.addInterceptor(interceptor);
    }
    if (aroundInvokeDescriptors.size() > 0) {
        interceptor.addAroundInvokeDescriptors(aroundInvokeDescriptors);
    }
    if (aroundTimeoutDescriptors.size() > 0) {
        interceptor.addAroundTimeoutDescriptors(aroundTimeoutDescriptors);
    }
    if (postActivateDescriptors.size() > 0) {
        interceptor.addCallbackDescriptors(CallbackType.POST_ACTIVATE, postActivateDescriptors);
    }
    if (prePassivateDescriptors.size() > 0) {
        interceptor.addCallbackDescriptors(CallbackType.PRE_PASSIVATE, prePassivateDescriptors);
    }
    // process resource related annotations
    EjbInterceptorContext ejbInterceptorContext = new EjbInterceptorContext(interceptor);
    ProcessingContext procContext = ainfo.getProcessingContext();
    procContext.pushHandler(ejbInterceptorContext);
    procContext.getProcessor().process(procContext, new Class[] { interceptorClass });
    return;
}
Also used : PostActivate(javax.ejb.PostActivate) ProcessingContext(org.glassfish.apf.ProcessingContext) LifecycleCallbackDescriptor(com.sun.enterprise.deployment.LifecycleCallbackDescriptor) PrePassivate(javax.ejb.PrePassivate) EjbInterceptorContext(com.sun.enterprise.deployment.annotation.context.EjbInterceptorContext) EjbInterceptor(com.sun.enterprise.deployment.EjbInterceptor) Method(java.lang.reflect.Method) AroundTimeout(javax.interceptor.AroundTimeout) AroundInvoke(javax.interceptor.AroundInvoke) HashSet(java.util.HashSet) ComponentDefinition(org.glassfish.apf.impl.ComponentDefinition)

Example 15 with EjbInterceptor

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

the class PrePassivateHandler method processAnnotation.

protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbInterceptorContext ejbInterceptorContext) throws AnnotationProcessorException {
    EjbInterceptor ejbInterceptor = ejbInterceptorContext.getDescriptor();
    ejbInterceptor.addPrePassivateDescriptor(getPrePassivateDescriptor(ainfo));
    return getDefaultProcessedResult();
}
Also used : EjbInterceptor(com.sun.enterprise.deployment.EjbInterceptor)

Aggregations

EjbInterceptor (com.sun.enterprise.deployment.EjbInterceptor)34 LifecycleCallbackDescriptor (com.sun.enterprise.deployment.LifecycleCallbackDescriptor)9 LinkedList (java.util.LinkedList)6 Method (java.lang.reflect.Method)5 HashSet (java.util.HashSet)5 EjbDescriptor (com.sun.enterprise.deployment.EjbDescriptor)3 InterceptorDescriptor (com.sun.enterprise.deployment.InterceptorDescriptor)3 MethodDescriptor (com.sun.enterprise.deployment.MethodDescriptor)3 Result (com.sun.enterprise.tools.verifier.Result)3 ComponentNameConstructor (com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor)3 ArrayList (java.util.ArrayList)3 EjbSessionDescriptor (org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor)3 Descriptor (org.glassfish.deployment.common.Descriptor)2 Node (org.w3c.dom.Node)2 JCDIService (com.sun.enterprise.container.common.spi.JCDIService)1 BundleDescriptor (com.sun.enterprise.deployment.BundleDescriptor)1 EjbBundleDescriptor (com.sun.enterprise.deployment.EjbBundleDescriptor)1 EjbMessageBeanDescriptor (com.sun.enterprise.deployment.EjbMessageBeanDescriptor)1 EntityManagerFactoryReferenceDescriptor (com.sun.enterprise.deployment.EntityManagerFactoryReferenceDescriptor)1 EntityManagerReferenceDescriptor (com.sun.enterprise.deployment.EntityManagerReferenceDescriptor)1