Search in sources :

Example 21 with LifecycleCallbackDescriptor

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

the class PreDestroyHandler method processAnnotation.

protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, ResourceContainerContext[] rcContexts) throws AnnotationProcessorException {
    Method annMethod = (Method) ainfo.getAnnotatedElement();
    validateAnnotatedLifecycleMethod(annMethod);
    String pdMethodName = annMethod.getName();
    String pdClassName = annMethod.getDeclaringClass().getName();
    for (ResourceContainerContext rcContext : rcContexts) {
        LifecycleCallbackDescriptor preDestroyDesc = new LifecycleCallbackDescriptor();
        preDestroyDesc.setLifecycleCallbackClass(pdClassName);
        preDestroyDesc.setLifecycleCallbackMethod(pdMethodName);
        preDestroyDesc.setMetadataSource(MetadataSource.ANNOTATION);
        // override by xml is handled in addPreDestroyDescriptor
        rcContext.addPreDestroyDescriptor(preDestroyDesc);
    }
    return getDefaultProcessedResult();
}
Also used : LifecycleCallbackDescriptor(com.sun.enterprise.deployment.LifecycleCallbackDescriptor) ResourceContainerContext(com.sun.enterprise.deployment.annotation.context.ResourceContainerContext) Method(java.lang.reflect.Method)

Example 22 with LifecycleCallbackDescriptor

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

the class EjbDescriptorImpl method createSystemLevelCDIInterceptor.

/*  enabled for debugging 
    public int hashCode() {
        return getEjbName().hashCode();
    }

    public boolean equals(Object o) {

        boolean equal = false;

        if( (o != null) && (o instanceof EjbDescriptorImpl) ) {

            equal = getEjbName().equals( ((EjbDescriptorImpl)o).getEjbName() );

        }

        return equal;

    }
    */
// JJS: 4/2/13 Removing superinterfaces to track down cdi tck failures.
// http://java.net/jira/browse/GLASSFISH-19970
// private void addIfLocal(Class<?>[] interfaces, Set<String> names) {
// for(Class<?> next : interfaces) {
// if( next.getAnnotation(Local.class) != null ) {
// names.add(next.getName());
// }
// addIfLocal(next.getInterfaces(), names);
// }
// }
// 
// private void addIfRemote(Class<?>[] interfaces, Set<String> names) {
// for(Class<?> next : interfaces) {
// if( next.getAnnotation(Remote.class) != null ) {
// names.add(next.getName());
// }
// addIfRemote(next.getInterfaces(), names);
// }
// }
private EjbInterceptor createSystemLevelCDIInterceptor() {
    EjbInterceptor interceptor = new EjbInterceptor();
    Class<SessionBeanInterceptor> interceptorClass = SessionBeanInterceptor.class;
    String interceptorName = interceptorClass.getName();
    interceptor.setInterceptorClass(interceptorClass);
    // we have to look for method explicitly.
    try {
        Method aroundInvokeMethod = interceptorClass.getMethod("aroundInvoke", InvocationContext.class);
        if (aroundInvokeMethod != null) {
            LifecycleCallbackDescriptor aroundInvokeDesc = new LifecycleCallbackDescriptor();
            aroundInvokeDesc.setLifecycleCallbackClass(interceptorName);
            aroundInvokeDesc.setLifecycleCallbackMethod(aroundInvokeMethod.getName());
            interceptor.addAroundInvokeDescriptor(aroundInvokeDesc);
            // TODO BUG -- Existing SessionBeanInterceptor does not define an @AroundTimeout method.
            // Until that's fixed, work around it by adding the method marked @AroundInvoke as an
            // @AroundTimeout.
            LifecycleCallbackDescriptor aroundTimeoutDesc = new LifecycleCallbackDescriptor();
            aroundTimeoutDesc.setLifecycleCallbackClass(interceptorName);
            aroundTimeoutDesc.setLifecycleCallbackMethod(aroundInvokeMethod.getName());
            interceptor.addAroundTimeoutDescriptor(aroundTimeoutDesc);
            // SessionBeanInterceptor does not define an @PostConstruct method so use the aroundInvoke method
            LifecycleCallbackDescriptor postConstructDesc = new LifecycleCallbackDescriptor();
            postConstructDesc.setLifecycleCallbackClass(interceptorName);
            postConstructDesc.setLifecycleCallbackMethod(aroundInvokeMethod.getName());
            interceptor.addPostConstructDescriptor(postConstructDesc);
        }
    } catch (NoSuchMethodException nsme) {
        throw new RuntimeException("Cannot find weld EJB interceptor aroundInvoke method");
    }
    return interceptor;
}
Also used : LifecycleCallbackDescriptor(com.sun.enterprise.deployment.LifecycleCallbackDescriptor) EjbInterceptor(com.sun.enterprise.deployment.EjbInterceptor) Method(java.lang.reflect.Method) SessionBeanInterceptor(org.jboss.weld.module.ejb.SessionBeanInterceptor)

Example 23 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 24 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 25 with LifecycleCallbackDescriptor

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

the class InterceptorsHandler method getLifecycleCallbackDescriptor.

private LifecycleCallbackDescriptor getLifecycleCallbackDescriptor(Method m) {
    LifecycleCallbackDescriptor lccDesc = new LifecycleCallbackDescriptor();
    lccDesc.setLifecycleCallbackClass(m.getDeclaringClass().getName());
    lccDesc.setLifecycleCallbackMethod(m.getName());
    return lccDesc;
}
Also used : 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