KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > deployment > annotations > analyzer > JavaxEjbTransactionAttributeVisitor


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: JavaxEjbTransactionAttributeVisitor.java 9 2006-02-19 18:53:32Z benoitf $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.easybeans.deployment.annotations.analyzer;
27
28 import static javax.ejb.TransactionAttributeType.MANDATORY JavaDoc;
29 import static javax.ejb.TransactionAttributeType.REQUIRED JavaDoc;
30 import static javax.ejb.TransactionAttributeType.REQUIRES_NEW JavaDoc;
31 import static javax.ejb.TransactionAttributeType.SUPPORTS JavaDoc;
32 import static javax.ejb.TransactionAttributeType.NOT_SUPPORTED JavaDoc;
33 import static javax.ejb.TransactionAttributeType.NEVER JavaDoc;
34
35 import org.objectweb.easybeans.deployment.annotations.metadata.interfaces.ITransactionAttribute;
36
37 /**
38  * This class manages the handling of @{@link javax.ejb.TransactionAttribute} annotation.
39  * @param <T> An implementation of ITransactionAttribute interface.
40  * @author Florent Benoit
41  */

42 public class JavaxEjbTransactionAttributeVisitor<T extends ITransactionAttribute>
43           extends EnumAnnotationVisitor<T> implements AnnotationType {
44
45     /**
46      * Type of annotation.
47      */

48     public static final String JavaDoc TYPE = "Ljavax/ejb/TransactionAttribute;";
49
50     /**
51      * Constructor.
52      * @param annotationMetadata linked to a class or method metadata
53      */

54     public JavaxEjbTransactionAttributeVisitor(final T annotationMetadata) {
55         super(annotationMetadata);
56     }
57
58     /**
59      * Visits the end of the annotation. <br>
60      * Creates the object and store it.
61      */

62     @Override JavaDoc
63     public void visitEnd() {
64         String JavaDoc s = getValue();
65         // TYPE annotation
66
if (getAnnotationMetadata() != null) {
67             if (MANDATORY.name().equals(s)) {
68                 getAnnotationMetadata().setTransactionAttributeType(MANDATORY);
69             } else if (REQUIRED.name().equals(s)) {
70                 getAnnotationMetadata().setTransactionAttributeType(REQUIRED);
71             } else if (REQUIRES_NEW.name().equals(s)) {
72                 getAnnotationMetadata().setTransactionAttributeType(REQUIRES_NEW);
73             } else if (SUPPORTS.name().equals(s)) {
74                 getAnnotationMetadata().setTransactionAttributeType(SUPPORTS);
75             } else if (NOT_SUPPORTED.name().equals(s)) {
76                 getAnnotationMetadata().setTransactionAttributeType(NOT_SUPPORTED);
77             } else if (NEVER.name().equals(s)) {
78                 getAnnotationMetadata().setTransactionAttributeType(NEVER);
79             } else {
80                 // set default
81
getAnnotationMetadata().setTransactionAttributeType(REQUIRED);
82             }
83         }
84     }
85
86     /**
87      * @return type of the annotation (its description)
88      */

89     public String JavaDoc getType() {
90         return TYPE;
91     }
92
93 }
94
Popular Tags