01: /**
02: * EasyBeans
03: * Copyright (C) 2006 Bull S.A.S.
04: * Contact: easybeans@ow2.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * 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 2059 2007-11-22 17:22:33Z benoitf $
23: * --------------------------------------------------------------------------
24: */package org.ow2.easybeans.deployment.annotations.analyzer;
25:
26: import static javax.ejb.TransactionAttributeType.MANDATORY;
27: import static javax.ejb.TransactionAttributeType.REQUIRED;
28: import static javax.ejb.TransactionAttributeType.REQUIRES_NEW;
29: import static javax.ejb.TransactionAttributeType.SUPPORTS;
30: import static javax.ejb.TransactionAttributeType.NOT_SUPPORTED;
31: import static javax.ejb.TransactionAttributeType.NEVER;
32:
33: import org.ow2.easybeans.deployment.annotations.metadata.interfaces.ITransactionAttribute;
34:
35: /**
36: * This class manages the handling of @{@link javax.ejb.TransactionAttribute} annotation.
37: * @param <T> An implementation of ITransactionAttribute interface.
38: * @author Florent Benoit
39: */
40: public class JavaxEjbTransactionAttributeVisitor<T extends ITransactionAttribute>
41: extends EnumAnnotationVisitor<T> implements AnnotationType {
42:
43: /**
44: * Type of annotation.
45: */
46: public static final String TYPE = "Ljavax/ejb/TransactionAttribute;";
47:
48: /**
49: * Constructor.
50: * @param annotationMetadata linked to a class or method metadata
51: */
52: public JavaxEjbTransactionAttributeVisitor(
53: final T annotationMetadata) {
54: super (annotationMetadata);
55: }
56:
57: /**
58: * Visits the end of the annotation. <br>
59: * Creates the object and store it.
60: */
61: @Override
62: public void visitEnd() {
63: String s = getValue();
64: // TYPE annotation
65: if (getAnnotationMetadata() != null) {
66: if (MANDATORY.name().equals(s)) {
67: getAnnotationMetadata().setTransactionAttributeType(
68: MANDATORY);
69: } else if (REQUIRED.name().equals(s)) {
70: getAnnotationMetadata().setTransactionAttributeType(
71: REQUIRED);
72: } else if (REQUIRES_NEW.name().equals(s)) {
73: getAnnotationMetadata().setTransactionAttributeType(
74: REQUIRES_NEW);
75: } else if (SUPPORTS.name().equals(s)) {
76: getAnnotationMetadata().setTransactionAttributeType(
77: SUPPORTS);
78: } else if (NOT_SUPPORTED.name().equals(s)) {
79: getAnnotationMetadata().setTransactionAttributeType(
80: NOT_SUPPORTED);
81: } else if (NEVER.name().equals(s)) {
82: getAnnotationMetadata().setTransactionAttributeType(
83: NEVER);
84: } else {
85: // set default
86: getAnnotationMetadata().setTransactionAttributeType(
87: REQUIRED);
88: }
89: }
90: }
91:
92: /**
93: * @return type of the annotation (its description)
94: */
95: public String getType() {
96: return TYPE;
97: }
98:
99: }
|