01: package com.bm.ejb3metadata.annotations.analyzer;
02:
03: import static javax.ejb.TransactionAttributeType.MANDATORY;
04: import static javax.ejb.TransactionAttributeType.REQUIRED;
05: import static javax.ejb.TransactionAttributeType.REQUIRES_NEW;
06: import static javax.ejb.TransactionAttributeType.SUPPORTS;
07: import static javax.ejb.TransactionAttributeType.NOT_SUPPORTED;
08: import static javax.ejb.TransactionAttributeType.NEVER;
09:
10: import com.bm.ejb3metadata.annotations.metadata.interfaces.ITransactionAttribute;
11:
12: /**
13: * This class manages the handling of @{@link javax.ejb.TransactionAttribute} annotation.
14: * @param <T> An implementation of ITransactionAttribute interface.
15: * @author Daniel Wiese
16: */
17: public class JavaxEjbTransactionAttributeVisitor<T extends ITransactionAttribute>
18: extends EnumAnnotationVisitor<T> implements AnnotationType {
19:
20: /**
21: * Type of annotation.
22: */
23: public static final String TYPE = "Ljavax/ejb/TransactionAttribute;";
24:
25: /**
26: * Constructor.
27: * @param annotationMetadata linked to a class or method metadata
28: */
29: public JavaxEjbTransactionAttributeVisitor(
30: final T annotationMetadata) {
31: super (annotationMetadata);
32: }
33:
34: /**
35: * Visits the end of the annotation. <br>
36: * Creates the object and store it.
37: */
38: @Override
39: public void visitEnd() {
40: String s = getValue();
41: // TYPE annotation
42: if (getAnnotationMetadata() != null) {
43: if (MANDATORY.name().equals(s)) {
44: getAnnotationMetadata().setTransactionAttributeType(
45: MANDATORY);
46: } else if (REQUIRED.name().equals(s)) {
47: getAnnotationMetadata().setTransactionAttributeType(
48: REQUIRED);
49: } else if (REQUIRES_NEW.name().equals(s)) {
50: getAnnotationMetadata().setTransactionAttributeType(
51: REQUIRES_NEW);
52: } else if (SUPPORTS.name().equals(s)) {
53: getAnnotationMetadata().setTransactionAttributeType(
54: SUPPORTS);
55: } else if (NOT_SUPPORTED.name().equals(s)) {
56: getAnnotationMetadata().setTransactionAttributeType(
57: NOT_SUPPORTED);
58: } else if (NEVER.name().equals(s)) {
59: getAnnotationMetadata().setTransactionAttributeType(
60: NEVER);
61: } else {
62: // set default
63: getAnnotationMetadata().setTransactionAttributeType(
64: REQUIRED);
65: }
66: }
67: }
68:
69: /**
70: * @return type of the annotation (its description)
71: */
72: public String getType() {
73: return TYPE;
74: }
75:
76: }
|