Search in sources :

Example 6 with InterceptorDescriptor

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

the class BeanCallbackInterceptor method getAroundTimeoutChain.

public InterceptorManager.InterceptorChain getAroundTimeoutChain(MethodDescriptor mDesc, Method beanMethod) {
    ArrayList<AroundInvokeInterceptor> interceptors = new ArrayList<AroundInvokeInterceptor>();
    for (InterceptorDescriptor interceptor : frameworkInterceptors) {
        Set<LifecycleCallbackDescriptor> aroundTimeoutDescs = interceptor.getAroundTimeoutDescriptors();
        if (aroundTimeoutDescs.isEmpty()) {
            continue;
        }
        List<LifecycleCallbackDescriptor> orderedAIInterceptors = null;
        Class interceptorClass = interceptor.getInterceptorClass();
        ClassLoader classLoaderToUse = (interceptorClass != null) ? interceptorClass.getClassLoader() : loader;
        try {
            orderedAIInterceptors = interceptor.getOrderedAroundTimeoutDescriptors(classLoaderToUse);
        } catch (Exception e) {
            throw new IllegalStateException("No AroundTimeoutIntercetpors found " + " on class " + interceptor.getInterceptorClassName(), e);
        }
        addAroundInvokeInterceptors(interceptors, interceptor, orderedAIInterceptors, interceptor.getInterceptorClassName(), classLoaderToUse);
    }
    List<EjbInterceptor> list = (ejbDesc != null) ? ejbDesc.getAroundTimeoutInterceptors(mDesc) : new LinkedList<EjbInterceptor>();
    for (EjbInterceptor interceptor : list) {
        String className = interceptor.getInterceptorClassName();
        Set<LifecycleCallbackDescriptor> aroundTimeoutDescs = interceptor.getAroundTimeoutDescriptors();
        if (aroundTimeoutDescs.isEmpty()) {
            continue;
        }
        List<LifecycleCallbackDescriptor> orderedATInterceptors;
        try {
            orderedATInterceptors = interceptor.getOrderedAroundTimeoutDescriptors(loader);
        } catch (Exception e) {
            throw new IllegalStateException("No AroundTimeoutIntercetpors found " + " on class " + className, e);
        }
        addAroundInvokeInterceptors(interceptors, interceptor, orderedATInterceptors, className, loader);
    }
    AroundInvokeInterceptor[] inter = interceptors.toArray(new AroundInvokeInterceptor[interceptors.size()]);
    return new AroundInvokeChainImpl(inter);
}
Also used : ArrayList(java.util.ArrayList) EjbInterceptor(com.sun.enterprise.deployment.EjbInterceptor) EJBException(javax.ejb.EJBException) InterceptorDescriptor(com.sun.enterprise.deployment.InterceptorDescriptor) LifecycleCallbackDescriptor(com.sun.enterprise.deployment.LifecycleCallbackDescriptor)

Example 7 with InterceptorDescriptor

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

the class BeanCallbackInterceptor method initCallbackIndices.

private void initCallbackIndices(List<InterceptorDescriptor> callbackList, CallbackType callbackType) throws Exception {
    ArrayList<CallbackInterceptor> callbacks = new ArrayList<CallbackInterceptor>();
    int index = callbackType.ordinal();
    for (InterceptorDescriptor callback : frameworkInterceptors) {
        if (callback.hasCallbackDescriptor(callbackType)) {
            Class interceptorClass = callback.getInterceptorClass();
            ClassLoader classLoaderToUse = (interceptorClass != null) ? interceptorClass.getClassLoader() : loader;
            List<CallbackInterceptor> inters = createCallbackInterceptors(callbackType, callback, classLoaderToUse);
            for (CallbackInterceptor inter : inters) {
                callbacks.add(inter);
            }
        }
    }
    for (InterceptorDescriptor callback : callbackList) {
        List<CallbackInterceptor> inters = createCallbackInterceptors(callbackType, callback);
        for (CallbackInterceptor inter : inters) {
            callbacks.add(inter);
        }
    }
    // move above callbackChain = new CallbackChainImpl[size];
    CallbackInterceptor[] interceptors = (CallbackInterceptor[]) callbacks.toArray(new CallbackInterceptor[callbacks.size()]);
    callbackChain[index] = new CallbackChainImpl(interceptors);
}
Also used : InterceptorDescriptor(com.sun.enterprise.deployment.InterceptorDescriptor) ArrayList(java.util.ArrayList)

Aggregations

InterceptorDescriptor (com.sun.enterprise.deployment.InterceptorDescriptor)7 ArrayList (java.util.ArrayList)4 EjbInterceptor (com.sun.enterprise.deployment.EjbInterceptor)3 LifecycleCallbackDescriptor (com.sun.enterprise.deployment.LifecycleCallbackDescriptor)3 HashSet (java.util.HashSet)2 EJBException (javax.ejb.EJBException)2 CallbackType (com.sun.enterprise.deployment.LifecycleCallbackDescriptor.CallbackType)1 EjbSessionDescriptor (org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor)1