Search in sources :

Example 16 with EjbContext

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

the class AsynchronousHandler method processAnnotation.

protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
    for (EjbContext ejbContext : ejbContexts) {
        EjbDescriptor ejbDesc = (EjbDescriptor) ejbContext.getDescriptor();
        if (ElementType.TYPE.equals(ainfo.getElementType())) {
            ejbContext.addPostProcessInfo(ainfo, this);
        } else {
            Method annMethod = (Method) ainfo.getAnnotatedElement();
            setAsynchronous(annMethod, ejbDesc);
        }
    }
    return getDefaultProcessedResult();
}
Also used : EjbContext(com.sun.enterprise.deployment.annotation.context.EjbContext) Method(java.lang.reflect.Method) EjbDescriptor(org.glassfish.ejb.deployment.descriptor.EjbDescriptor)

Example 17 with EjbContext

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

the class ConcurrencyManagementHandler method processAnnotation.

protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
    ConcurrencyManagement cmAn = (ConcurrencyManagement) ainfo.getAnnotation();
    ConcurrencyManagementType cmType = cmAn.value();
    for (EjbContext ejbContext : ejbContexts) {
        EjbDescriptor ejbDesc = ejbContext.getDescriptor();
        if (ejbDesc instanceof EjbSessionDescriptor) {
            EjbSessionDescriptor.ConcurrencyManagementType descCMType;
            switch(cmType) {
                case CONTAINER:
                    descCMType = EjbSessionDescriptor.ConcurrencyManagementType.Container;
                    break;
                case BEAN:
                    descCMType = EjbSessionDescriptor.ConcurrencyManagementType.Bean;
                    break;
                default:
                    throw new AnnotationProcessorException("Unsupported concurrency management " + "type = " + cmType);
            }
            EjbSessionDescriptor sDesc = (EjbSessionDescriptor) ejbDesc;
            // Set value on descriptor unless it has been set by .xml
            sDesc.setConcurrencyManagementTypeIfNotSet(descCMType);
        }
    }
    return getDefaultProcessedResult();
}
Also used : ConcurrencyManagement(javax.ejb.ConcurrencyManagement) ConcurrencyManagementType(javax.ejb.ConcurrencyManagementType) EjbContext(com.sun.enterprise.deployment.annotation.context.EjbContext) AnnotationProcessorException(org.glassfish.apf.AnnotationProcessorException) EjbSessionDescriptor(org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor) EjbDescriptor(com.sun.enterprise.deployment.EjbDescriptor)

Example 18 with EjbContext

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

the class ExcludeDefaultInterceptorsHandler 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.setExcludeDefaultInterceptors(true);
        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);
        }
        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 19 with EjbContext

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

the class PostActivateHandler method processAnnotation.

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

Example 20 with EjbContext

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

the class RemoveHandler method processAnnotation.

protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
    Remove remove = (Remove) ainfo.getAnnotation();
    for (EjbContext next : ejbContexts) {
        EjbSessionDescriptor sessionDescriptor = (EjbSessionDescriptor) next.getDescriptor();
        Method m = (Method) ainfo.getAnnotatedElement();
        MethodDescriptor removeMethod = new MethodDescriptor(m, MethodDescriptor.EJB_BEAN);
        EjbRemovalInfo removalInfo = sessionDescriptor.getRemovalInfo(removeMethod);
        if (removalInfo == null) {
            // if this element is not defined in xml
            // use all information from annotation
            removalInfo = new EjbRemovalInfo();
            removalInfo.setRemoveMethod(removeMethod);
            removalInfo.setRetainIfException(remove.retainIfException());
            sessionDescriptor.addRemoveMethod(removalInfo);
        } else {
            // is not defined in xml
            if (!removalInfo.isRetainIfExceptionSet()) {
                removalInfo.setRetainIfException(remove.retainIfException());
            }
        }
    }
    return getDefaultProcessedResult();
}
Also used : EjbContext(com.sun.enterprise.deployment.annotation.context.EjbContext) EjbRemovalInfo(org.glassfish.ejb.deployment.descriptor.EjbRemovalInfo) Remove(javax.ejb.Remove) Method(java.lang.reflect.Method) EjbSessionDescriptor(org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor)

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