Search in sources :

Example 6 with EjbContext

use of com.sun.enterprise.deployment.annotation.context.EjbContext in project Payara by payara.

the class BeforeCompletionHandler method processAnnotation.

protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
    for (EjbContext ejbContext : ejbContexts) {
        EjbSessionDescriptor ejbDesc = (EjbSessionDescriptor) ejbContext.getDescriptor();
        Method annMethod = (Method) ainfo.getAnnotatedElement();
        checkValid(annMethod);
        if (logger.isLoggable(Level.FINE)) {
            logger.fine("Setting BeforeCompletion method " + annMethod);
        }
        ejbDesc.setBeforeCompletionMethodIfNotSet(new MethodDescriptor(annMethod));
    }
    return getDefaultProcessedResult();
}
Also used : EjbContext(com.sun.enterprise.deployment.annotation.context.EjbContext) Method(java.lang.reflect.Method) EjbSessionDescriptor(org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor)

Example 7 with EjbContext

use of com.sun.enterprise.deployment.annotation.context.EjbContext in project Payara by payara.

the class ExcludeClassInterceptorsHandler method processAnnotation.

protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
    EjbBundleDescriptorImpl ejbBundle = ((EjbDescriptor) ejbContexts[0].getDescriptor()).getEjbBundleDescriptor();
    for (EjbContext next : ejbContexts) {
        EjbDescriptor ejbDescriptor = (EjbDescriptor) next.getDescriptor();
        // Create binding information.
        InterceptorBindingDescriptor binding = new InterceptorBindingDescriptor();
        binding.setEjbName(ejbDescriptor.getName());
        binding.setExcludeClassInterceptors(true);
        // Annotation can be defined at a method level or constructor level.
        MethodDescriptor md = null;
        if (ElementType.METHOD.equals(ainfo.getElementType())) {
            Method m = (Method) ainfo.getAnnotatedElement();
            md = new MethodDescriptor(m, MethodDescriptor.EJB_BEAN);
        } else if (ElementType.CONSTRUCTOR.equals(ainfo.getElementType())) {
            Constructor c = (Constructor) ainfo.getAnnotatedElement();
            Class cl = c.getDeclaringClass();
            Class[] ctorParamTypes = c.getParameterTypes();
            String[] parameterClassNames = (new MethodDescriptor()).getParameterClassNamesFor(null, ctorParamTypes);
            md = new MethodDescriptor(cl.getSimpleName(), null, parameterClassNames, MethodDescriptor.EJB_BEAN);
        }
        // else throw Exception?
        binding.setBusinessMethod(md);
        ejbBundle.prependInterceptorBinding(binding);
    }
    return getDefaultProcessedResult();
}
Also used : EjbContext(com.sun.enterprise.deployment.annotation.context.EjbContext) InterceptorBindingDescriptor(org.glassfish.ejb.deployment.descriptor.InterceptorBindingDescriptor) Constructor(java.lang.reflect.Constructor) Method(java.lang.reflect.Method) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor) EjbDescriptor(org.glassfish.ejb.deployment.descriptor.EjbDescriptor) EjbBundleDescriptorImpl(org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)

Example 8 with EjbContext

use of com.sun.enterprise.deployment.annotation.context.EjbContext in project Payara by payara.

the class InitHandler method processAnnotation.

protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
    Init init = (Init) ainfo.getAnnotation();
    for (EjbContext next : ejbContexts) {
        EjbSessionDescriptor sessionDescriptor = (EjbSessionDescriptor) next.getDescriptor();
        Method m = (Method) ainfo.getAnnotatedElement();
        // Check for matching method on home and/or local home interface.
        int numMatches = 0;
        String adaptedCreateMethodName = init.value();
        try {
            if (sessionDescriptor.isRemoteInterfacesSupported()) {
                addInitMethod(sessionDescriptor, m, adaptedCreateMethodName, false);
                numMatches++;
            }
        } catch (Exception e) {
        }
        try {
            if (sessionDescriptor.isLocalInterfacesSupported()) {
                addInitMethod(sessionDescriptor, m, adaptedCreateMethodName, true);
                numMatches++;
            }
        } catch (Exception e) {
        }
        if (numMatches == 0) {
            log(Level.SEVERE, ainfo, localStrings.getLocalString("enterprise.deployment.annotation.handlers.notmatchcreate", "Unable to find matching Home create method for Init method {0} on bean {1}.", new Object[] { m, sessionDescriptor.getName() }));
            return getDefaultFailedResult();
        }
    }
    return getDefaultProcessedResult();
}
Also used : Init(javax.ejb.Init) EjbContext(com.sun.enterprise.deployment.annotation.context.EjbContext) Method(java.lang.reflect.Method) EjbSessionDescriptor(org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor) AnnotationProcessorException(org.glassfish.apf.AnnotationProcessorException)

Example 9 with EjbContext

use of com.sun.enterprise.deployment.annotation.context.EjbContext in project Payara by payara.

the class InterceptorsHandler method processAnnotation.

protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
    Interceptors interceptors = (Interceptors) ainfo.getAnnotation();
    EjbBundleDescriptorImpl ejbBundle = ((EjbDescriptor) ejbContexts[0].getDescriptor()).getEjbBundleDescriptor();
    // Process each of the interceptor classes.
    for (Class interceptor : interceptors.value()) {
        processInterceptorClass(interceptor, ejbBundle, ainfo);
    }
    for (EjbContext next : ejbContexts) {
        EjbDescriptor ejbDescriptor = (EjbDescriptor) next.getDescriptor();
        // Create binding information.
        InterceptorBindingDescriptor binding = new InterceptorBindingDescriptor();
        binding.setEjbName(ejbDescriptor.getName());
        for (Class interceptor : interceptors.value()) {
            binding.appendInterceptorClass(interceptor.getName());
        }
        if (ElementType.METHOD.equals(ainfo.getElementType())) {
            Method m = (Method) ainfo.getAnnotatedElement();
            MethodDescriptor md = new MethodDescriptor(m, MethodDescriptor.EJB_BEAN);
            binding.setBusinessMethod(md);
        } else if (ElementType.CONSTRUCTOR.equals(ainfo.getElementType())) {
            Constructor c = (Constructor) ainfo.getAnnotatedElement();
            Class cl = c.getDeclaringClass();
            Class[] ctorParamTypes = c.getParameterTypes();
            String[] parameterClassNames = (new MethodDescriptor()).getParameterClassNamesFor(null, ctorParamTypes);
            MethodDescriptor md = new MethodDescriptor(cl.getSimpleName(), null, parameterClassNames, MethodDescriptor.EJB_BEAN);
            binding.setBusinessMethod(md);
        }
        // All binding information processed from annotations should go
        // before the binding information processed from the descriptors.
        // Since descriptors are processed first, always place the binding
        // info at the front.  The binding information from the descriptor
        // is ordered, but there is no prescribed order in which the
        // annotations are processed, so all that matters is that it's
        // before the descriptor bindings and that the descriptor binding
        // order is preserved.
        ejbBundle.prependInterceptorBinding(binding);
    }
    return getDefaultProcessedResult();
}
Also used : Interceptors(javax.interceptor.Interceptors) EjbContext(com.sun.enterprise.deployment.annotation.context.EjbContext) InterceptorBindingDescriptor(org.glassfish.ejb.deployment.descriptor.InterceptorBindingDescriptor) Constructor(java.lang.reflect.Constructor) Method(java.lang.reflect.Method) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor) EjbDescriptor(org.glassfish.ejb.deployment.descriptor.EjbDescriptor) EjbBundleDescriptorImpl(org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)

Example 10 with EjbContext

use of com.sun.enterprise.deployment.annotation.context.EjbContext in project Payara by payara.

the class PrePassivateHandler method processAnnotation.

protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
    for (EjbContext next : ejbContexts) {
        EjbSessionDescriptor ejbSessionDescriptor = (EjbSessionDescriptor) next.getDescriptor();
        ejbSessionDescriptor.addPrePassivateDescriptor(getPrePassivateDescriptor(ainfo));
    }
    return getDefaultProcessedResult();
}
Also used : EjbContext(com.sun.enterprise.deployment.annotation.context.EjbContext) EjbSessionDescriptor(org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor)

Aggregations

EjbContext (com.sun.enterprise.deployment.annotation.context.EjbContext)26 Method (java.lang.reflect.Method)12 MethodDescriptor (com.sun.enterprise.deployment.MethodDescriptor)10 EjbDescriptor (org.glassfish.ejb.deployment.descriptor.EjbDescriptor)10 EjbSessionDescriptor (org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor)10 EjbDescriptor (com.sun.enterprise.deployment.EjbDescriptor)4 EjbsContext (com.sun.enterprise.deployment.annotation.context.EjbsContext)4 EjbBundleDescriptorImpl (org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)4 Role (org.glassfish.security.common.Role)4 AnnotatedElement (java.lang.reflect.AnnotatedElement)3 Constructor (java.lang.reflect.Constructor)3 AnnotationProcessorException (org.glassfish.apf.AnnotationProcessorException)3 InterceptorBindingDescriptor (org.glassfish.ejb.deployment.descriptor.InterceptorBindingDescriptor)3 RunAsIdentityDescriptor (com.sun.enterprise.deployment.RunAsIdentityDescriptor)2 EjbBundleContext (com.sun.enterprise.deployment.annotation.context.EjbBundleContext)2 WebBundleContext (com.sun.enterprise.deployment.annotation.context.WebBundleContext)2 WebComponentContext (com.sun.enterprise.deployment.annotation.context.WebComponentContext)2 Annotation (java.lang.annotation.Annotation)2 DeclareRoles (javax.annotation.security.DeclareRoles)2 RunAs (javax.annotation.security.RunAs)2