Search in sources :

Example 1 with EjbApplicationExceptionInfo

use of org.glassfish.ejb.deployment.descriptor.EjbApplicationExceptionInfo in project Payara by payara.

the class ApplicationExceptionHandler method processAnnotation.

public HandlerProcessingResult processAnnotation(AnnotationInfo ainfo) throws AnnotationProcessorException {
    AnnotatedElement ae = ainfo.getAnnotatedElement();
    Annotation annotation = ainfo.getAnnotation();
    AnnotatedElementHandler aeHandler = ainfo.getProcessingContext().getHandler();
    if (aeHandler instanceof EjbBundleContext) {
        EjbBundleContext ejbBundleContext = (EjbBundleContext) aeHandler;
        EjbBundleDescriptorImpl ejbBundle = (EjbBundleDescriptorImpl) ejbBundleContext.getDescriptor();
        ApplicationException appExcAnn = (ApplicationException) annotation;
        EjbApplicationExceptionInfo appExcInfo = new EjbApplicationExceptionInfo();
        Class annotatedClass = (Class) ae;
        appExcInfo.setExceptionClassName(annotatedClass.getName());
        appExcInfo.setRollback(appExcAnn.rollback());
        appExcInfo.setInherited(appExcAnn.inherited());
        // in ejb-jar.xml
        if (!ejbBundle.getApplicationExceptions().containsKey(annotatedClass.getName())) {
            ejbBundle.addApplicationException(appExcInfo);
        }
    }
    return getDefaultProcessedResult();
}
Also used : ApplicationException(javax.ejb.ApplicationException) EjbBundleContext(com.sun.enterprise.deployment.annotation.context.EjbBundleContext) EjbApplicationExceptionInfo(org.glassfish.ejb.deployment.descriptor.EjbApplicationExceptionInfo) AnnotatedElement(java.lang.reflect.AnnotatedElement) AnnotatedElementHandler(org.glassfish.apf.AnnotatedElementHandler) Annotation(java.lang.annotation.Annotation) EjbBundleDescriptorImpl(org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)

Aggregations

EjbBundleContext (com.sun.enterprise.deployment.annotation.context.EjbBundleContext)1 Annotation (java.lang.annotation.Annotation)1 AnnotatedElement (java.lang.reflect.AnnotatedElement)1 ApplicationException (javax.ejb.ApplicationException)1 AnnotatedElementHandler (org.glassfish.apf.AnnotatedElementHandler)1 EjbApplicationExceptionInfo (org.glassfish.ejb.deployment.descriptor.EjbApplicationExceptionInfo)1 EjbBundleDescriptorImpl (org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)1