1 /** 2 * EasyBeans 3 * Copyright (C) 2006 Bull S.A.S. 4 * Contact: easybeans@objectweb.org 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 * USA 20 * 21 * -------------------------------------------------------------------------- 22 * $Id: JavaxEjbTransactionManagementVisitor.java 9 2006-02-19 18:53:32Z benoitf $ 23 * -------------------------------------------------------------------------- 24 */ 25 26 package org.objectweb.easybeans.deployment.annotations.analyzer.classes; 27 28 import static javax.ejb.TransactionManagementType.BEAN; 29 import static javax.ejb.TransactionManagementType.CONTAINER; 30 31 import org.objectweb.easybeans.deployment.annotations.analyzer.AnnotationType; 32 import org.objectweb.easybeans.deployment.annotations.analyzer.EnumAnnotationVisitor; 33 import org.objectweb.easybeans.deployment.annotations.metadata.ClassAnnotationMetadata; 34 35 /** 36 * This class manages the handling of @{@link javax.ejb.TransactionManagement} annotation. 37 * @author Florent Benoit 38 */ 39 public class JavaxEjbTransactionManagementVisitor 40 extends EnumAnnotationVisitor<ClassAnnotationMetadata> 41 implements AnnotationType { 42 43 /** 44 * Type of annotation. 45 */ 46 public static final String TYPE = "Ljavax/ejb/TransactionManagement;"; 47 48 /** 49 * Constructor. 50 * @param classAnnotationMetadata linked to a class metadata 51 */ 52 public JavaxEjbTransactionManagementVisitor(final ClassAnnotationMetadata classAnnotationMetadata) { 53 super(classAnnotationMetadata); 54 } 55 56 /** 57 * Visits the end of the annotation.<br> 58 * Creates the object and store it. 59 */ 60 @Override 61 public void visitEnd() { 62 String s = getValue(); 63 if (BEAN.name().equals(s)) { 64 getAnnotationMetadata().setTransactionManagementType(BEAN); 65 } else if (CONTAINER.name().equals(s)) { 66 getAnnotationMetadata().setTransactionManagementType(CONTAINER); 67 } else { 68 // set default 69 getAnnotationMetadata().setTransactionManagementType(CONTAINER); 70 } 71 72 } 73 74 /** 75 * @return type of the annotation (its description). 76 */ 77 public String getType() { 78 return TYPE; 79 } 80 81 } 82