Search in sources :

Example 1 with SessionBeanInterceptor

use of org.jboss.weld.module.ejb.SessionBeanInterceptor 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)

Aggregations

EjbInterceptor (com.sun.enterprise.deployment.EjbInterceptor)1 LifecycleCallbackDescriptor (com.sun.enterprise.deployment.LifecycleCallbackDescriptor)1 Method (java.lang.reflect.Method)1 SessionBeanInterceptor (org.jboss.weld.module.ejb.SessionBeanInterceptor)1