1 /*2 * The contents of this file are subject to the terms 3 * of the Common Development and Distribution License 4 * (the License). You may not use this file except in5 * compliance with the License.6 * 7 * You can obtain a copy of the license at 8 * https://glassfish.dev.java.net/public/CDDLv1.0.html or9 * glassfish/bootstrap/legal/CDDLv1.0.txt.10 * See the License for the specific language governing 11 * permissions and limitations under the License.12 * 13 * When distributing Covered Code, include this CDDL 14 * Header Notice in each file and include the License file 15 * at glassfish/bootstrap/legal/CDDLv1.0.txt. 16 * If applicable, add the following below the CDDL Header, 17 * with the fields enclosed by brackets [] replaced by18 * you own identifying information: 19 * "Portions Copyrighted [year] [name of copyright owner]"20 * 21 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.22 */23 package com.sun.enterprise.deployment.annotation.handlers;24 25 import java.lang.annotation.Annotation ;26 import java.lang.reflect.AnnotatedElement ;27 28 import javax.ejb.ApplicationException ;29 30 import com.sun.enterprise.deployment.EjbDescriptor;31 import com.sun.enterprise.deployment.EjbBundleDescriptor;32 import com.sun.enterprise.deployment.EjbApplicationExceptionInfo;33 34 import com.sun.enterprise.deployment.annotation.HandlerProcessingResult;35 import com.sun.enterprise.deployment.annotation.AnnotationInfo;36 import com.sun.enterprise.deployment.annotation.AnnotatedElementHandler;37 import com.sun.enterprise.deployment.annotation.AnnotationProcessorException;38 import com.sun.enterprise.deployment.annotation.context.EjbBundleContext;39 40 /**41 * Handles @javax.ejb.ApplicationException 42 */43 public class ApplicationExceptionHandler extends AbstractHandler {44 45 public ApplicationExceptionHandler() {46 }47 48 /**49 * @return the annoation type this annotation handler is handling50 */51 public Class <? extends Annotation > getAnnotationType() {52 return ApplicationException .class;53 } 54 55 public HandlerProcessingResult processAnnotation56 (AnnotationInfo ainfo) throws AnnotationProcessorException {57 58 AnnotatedElement ae = ainfo.getAnnotatedElement();59 Annotation annotation = ainfo.getAnnotation();60 61 AnnotatedElementHandler aeHandler = 62 ainfo.getProcessingContext().getHandler();63 64 65 if (aeHandler instanceof EjbBundleContext) {66 EjbBundleContext ejbBundleContext = (EjbBundleContext)aeHandler;67 68 EjbBundleDescriptor ejbBundle = ejbBundleContext.getDescriptor();69 70 ApplicationException appExcAnn = (ApplicationException ) annotation;71 72 EjbApplicationExceptionInfo appExcInfo = new 73 EjbApplicationExceptionInfo();74 Class annotatedClass = (Class ) ae;75 appExcInfo.setExceptionClassName(annotatedClass.getName());76 appExcInfo.setRollback(appExcAnn.rollback());77 78 ejbBundle.addApplicationException(appExcInfo);79 80 }81 82 return getDefaultProcessedResult();83 84 }85 86 protected boolean supportTypeInheritance() {87 return true;88 }89 }90