01: package com.bm.ejb3metadata.annotations.analyzer.classes;
02:
03: import java.util.ArrayList;
04: import java.util.List;
05:
06: import com.bm.ejb3metadata.annotations.analyzer.JavaxEjbEJBVisitor;
07: import com.bm.ejb3metadata.annotations.impl.JEjbEJB;
08: import com.bm.ejb3metadata.annotations.metadata.ClassAnnotationMetadata;
09:
10: /**
11: * This class manages the handling of @{@link javax.ejb.EJBs} annotation.
12: * @author Daniel Wiese
13: */
14: public class JavaxEjbEJBsVisitor extends
15: JavaxEjbEJBVisitor<ClassAnnotationMetadata> {
16:
17: /**
18: * Type of annotation.
19: */
20: public static final String TYPE = "Ljavax/ejb/EJBs;";
21:
22: /**
23: * List of jEjbEJB object.
24: */
25: private List<JEjbEJB> jEjbEJBs = null;
26:
27: /**
28: * Object is added to the list.
29: */
30: private boolean isAdded = false;
31:
32: /**
33: * Constructor.
34: * @param annotationMetadata linked to a class or method metadata
35: */
36: public JavaxEjbEJBsVisitor(
37: final ClassAnnotationMetadata annotationMetadata) {
38: super (annotationMetadata);
39: jEjbEJBs = new ArrayList<JEjbEJB>();
40: }
41:
42: /**
43: * Visits a primitive value of the annotation.<br>
44: * @param name the value name.
45: * @param value the actual value, whose type must be {@link Byte},
46: * {@link Boolean}, {@link Character}, {@link Short},
47: * {@link Integer}, {@link Long}, {@link Float}, {@link Double},
48: * {@link String} or {@link org.ejb3unit.asm.Type}.
49: */
50: @Override
51: public void visit(final String name, final Object value) {
52: // list not empty, need to create another reference
53: // at the first item found
54: if (jEjbEJBs.size() > 0 && isAdded) {
55: setJEjbEJB(new JEjbEJB());
56: isAdded = false;
57: }
58:
59: // do super code
60: super .visit(name, value);
61: }
62:
63: /**
64: * Visits the end of the annotation. <br>
65: * Creates the object and store it.
66: */
67: @Override
68: public void visitEnd() {
69: // add object in the list
70: if (!isAdded) {
71: jEjbEJBs.add(getJEjbEJB());
72: isAdded = true;
73: }
74:
75: // update list
76: getAnnotationMetadata().setJEjbEJBs(jEjbEJBs);
77: }
78:
79: /**
80: * @return type of the annotation (its description)
81: */
82: @Override
83: public String getType() {
84: return TYPE;
85: }
86:
87: }
|