Search in sources :

Example 6 with LifecycleCallbackDescriptor

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

the class EjbNode method writeAroundTimeoutDescriptors.

protected static void writeAroundTimeoutDescriptors(Node parentNode, Iterator aroundTimeoutDescs) {
    if (aroundTimeoutDescs == null || !aroundTimeoutDescs.hasNext())
        return;
    AroundTimeoutNode subNode = new AroundTimeoutNode();
    for (; aroundTimeoutDescs.hasNext(); ) {
        LifecycleCallbackDescriptor next = (LifecycleCallbackDescriptor) aroundTimeoutDescs.next();
        subNode.writeDescriptor(parentNode, EjbTagNames.AROUND_TIMEOUT_METHOD, next);
    }
}
Also used : LifecycleCallbackDescriptor(com.sun.enterprise.deployment.LifecycleCallbackDescriptor)

Example 7 with LifecycleCallbackDescriptor

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

the class EjbBundleValidator method getAllPrePassivatePostActivateCallbackInfo.

private String getAllPrePassivatePostActivateCallbackInfo(EjbSessionDescriptor sessionDesc) {
    List<LifecycleCallbackDescriptor> descriptors = new ArrayList<LifecycleCallbackDescriptor>();
    descriptors.addAll(sessionDesc.getPrePassivateDescriptors());
    descriptors.addAll(sessionDesc.getPostActivateDescriptors());
    for (EjbInterceptor interceptor : sessionDesc.getInterceptorClasses()) {
        descriptors.addAll(interceptor.getCallbackDescriptors(LifecycleCallbackDescriptor.CallbackType.PRE_PASSIVATE));
        descriptors.addAll(interceptor.getCallbackDescriptors(LifecycleCallbackDescriptor.CallbackType.POST_ACTIVATE));
    }
    StringBuilder result = new StringBuilder();
    for (LifecycleCallbackDescriptor each : descriptors) {
        result.append(each.getLifecycleCallbackClass());
        result.append(".");
        result.append(each.getLifecycleCallbackMethod());
        result.append(", ");
    }
    if (result.length() > 2) {
        return result.substring(0, result.length() - 2);
    } else {
        return result.toString();
    }
}
Also used : LifecycleCallbackDescriptor(com.sun.enterprise.deployment.LifecycleCallbackDescriptor) ArrayList(java.util.ArrayList) EjbInterceptor(com.sun.enterprise.deployment.EjbInterceptor)

Example 8 with LifecycleCallbackDescriptor

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

the class BeanCallbackInterceptor method addAroundInvokeInterceptors.

private void addAroundInvokeInterceptors(List<AroundInvokeInterceptor> interceptors, InterceptorDescriptor interceptor, List<LifecycleCallbackDescriptor> orderedInterceptors, String className, ClassLoader classLoaderToUse) {
    // if interceptor already has the class loaded use its classloader
    if (interceptor.getInterceptorClass() != null) {
        classLoaderToUse = interceptor.getInterceptorClass().getClassLoader();
    }
    for (LifecycleCallbackDescriptor desc : orderedInterceptors) {
        Method method = null;
        try {
            method = desc.getLifecycleCallbackMethodObject(classLoaderToUse);
        } catch (Exception e) {
            throw new IllegalStateException("No callback method of name " + desc.getLifecycleCallbackMethod() + " found on class " + className, e);
        }
        if (interceptor.getFromBeanClass()) {
            interceptors.add(new BeanAroundInvokeInterceptor(method));
        } else {
            Integer bigInt = instanceIndexMap.get(className);
            int index = (bigInt == null) ? -1 : bigInt;
            if (index == -1) {
                throw new IllegalStateException(getInternalErrorString(className));
            }
            Class clazz = interceptorClasses[index];
            _logger.log(Level.FINE, "*[md.getDeclaredMethod() => " + method + " FOR CLAZZ: " + clazz);
            interceptors.add(new AroundInvokeInterceptor(index, method));
        }
    }
}
Also used : LifecycleCallbackDescriptor(com.sun.enterprise.deployment.LifecycleCallbackDescriptor) Method(java.lang.reflect.Method) EJBException(javax.ejb.EJBException)

Example 9 with LifecycleCallbackDescriptor

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

the class BeanCallbackInterceptor method getAroundInvokeChain.

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

Example 10 with LifecycleCallbackDescriptor

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

the class SystemInterceptorProxy method createInterceptorDesc.

public static InterceptorDescriptor createInterceptorDesc() {
    InterceptorDescriptor interceptor = new InterceptorDescriptor();
    Class interceptorClass = SystemInterceptorProxy.class;
    String interceptorName = interceptorClass.getName();
    interceptor.setInterceptorClass(interceptorClass);
    {
        LifecycleCallbackDescriptor desc = new LifecycleCallbackDescriptor();
        desc.setLifecycleCallbackClass(interceptorName);
        desc.setLifecycleCallbackMethod("create");
        interceptor.addCallbackDescriptor(CallbackType.AROUND_CONSTRUCT, desc);
    }
    {
        LifecycleCallbackDescriptor desc = new LifecycleCallbackDescriptor();
        desc.setLifecycleCallbackClass(interceptorName);
        desc.setLifecycleCallbackMethod("init");
        interceptor.addCallbackDescriptor(CallbackType.POST_CONSTRUCT, desc);
    }
    {
        LifecycleCallbackDescriptor desc = new LifecycleCallbackDescriptor();
        desc.setLifecycleCallbackClass(interceptorName);
        desc.setLifecycleCallbackMethod("destroy");
        interceptor.addCallbackDescriptor(CallbackType.PRE_DESTROY, desc);
    }
    {
        LifecycleCallbackDescriptor desc = new LifecycleCallbackDescriptor();
        desc.setLifecycleCallbackClass(interceptorName);
        desc.setLifecycleCallbackMethod("aroundInvoke");
        interceptor.addAroundInvokeDescriptor(desc);
    }
    {
        LifecycleCallbackDescriptor desc = new LifecycleCallbackDescriptor();
        desc.setLifecycleCallbackClass(interceptorName);
        desc.setLifecycleCallbackMethod("aroundTimeout");
        interceptor.addAroundTimeoutDescriptor(desc);
    }
    return interceptor;
}
Also used : InterceptorDescriptor(com.sun.enterprise.deployment.InterceptorDescriptor) LifecycleCallbackDescriptor(com.sun.enterprise.deployment.LifecycleCallbackDescriptor)

Aggregations

LifecycleCallbackDescriptor (com.sun.enterprise.deployment.LifecycleCallbackDescriptor)38 Method (java.lang.reflect.Method)15 EjbInterceptor (com.sun.enterprise.deployment.EjbInterceptor)9 ArrayList (java.util.ArrayList)4 EJBException (javax.ejb.EJBException)4 InterceptorDescriptor (com.sun.enterprise.deployment.InterceptorDescriptor)3 MethodDescriptor (com.sun.enterprise.deployment.MethodDescriptor)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 EjbContext (com.sun.enterprise.deployment.annotation.context.EjbContext)1 EjbInterceptorContext (com.sun.enterprise.deployment.annotation.context.EjbInterceptorContext)1 Collection (java.util.Collection)1 LinkedList (java.util.LinkedList)1 Set (java.util.Set)1