KickJava   Java API By Example, From Geeks To Geeks.

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


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: JavaxEjbEJBVisitor.java 410 2006-04-25 14:58:06Z benoitf $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.easybeans.deployment.annotations.analyzer;
27
28 import org.objectweb.asm.Type;
29
30 import org.objectweb.easybeans.deployment.annotations.impl.JEjbEJB;
31 import org.objectweb.easybeans.deployment.annotations.metadata.interfaces.IEjbEJB;
32
33 /**
34  * This class manages the handling of @{@link javax.ejb.EJB} annotation.
35  * @param <T> An implementation of IAnnotationEJB interface.
36  * @author Florent Benoit
37  */

38 public class JavaxEjbEJBVisitor<T extends IEjbEJB>
39           extends AbsAnnotationVisitor<T> implements AnnotationType {
40
41     /**
42      * Name attribute of the annotation.
43      */

44     private static final String JavaDoc NAME = "name";
45
46     /**
47      * Bean interface attribute of the annotation.
48      */

49     private static final String JavaDoc BEAN_INTERFACE = "beanInterface";
50
51     /**
52      * Bean name attribute of the annotation.
53      */

54     private static final String JavaDoc BEAN_NAME = "beanName";
55
56     /**
57      * Mapped name attribute of the annotation.
58      */

59     private static final String JavaDoc MAPPED_NAME = "mappedName";
60
61     /**
62      * Type of annotation.
63      */

64     public static final String JavaDoc TYPE = "Ljavax/ejb/EJB;";
65
66     /**
67      * Internal object used representing &#64;{@link javax.ejb.EJB} annotation.
68      */

69     private JEjbEJB jEjbEJB = null;
70
71     /**
72      * Constructor.
73      * @param annotationMetadata linked to a class or method metadata
74      */

75     public JavaxEjbEJBVisitor(final T annotationMetadata) {
76         super(annotationMetadata);
77         jEjbEJB = new JEjbEJB();
78     }
79
80
81     /**
82      * Visits a primitive value of the annotation.<br>
83      * @param name the value name.
84      * @param value the actual value, whose type must be {@link Byte},
85      * {@link Boolean}, {@link Character}, {@link Short},
86      * {@link Integer}, {@link Long}, {@link Float}, {@link Double},
87      * {@link String} or {@link org.objectweb.asm.Type}.
88      */

89     @Override JavaDoc
90     public void visit(final String JavaDoc name, final Object JavaDoc value) {
91         if (name.equals(NAME)) {
92             jEjbEJB.setName((String JavaDoc) value);
93         } else if (name.equals(BEAN_INTERFACE)) {
94             Type type = (Type) value;
95             jEjbEJB.setBeanInterface(type.getClassName());
96         } else if (name.equals(BEAN_NAME)) {
97             jEjbEJB.setBeanName((String JavaDoc) value);
98         } else if (name.equals(MAPPED_NAME)) {
99             jEjbEJB.setMappedName((String JavaDoc) value);
100         }
101     }
102
103     /**
104      * Visits the end of the annotation. <br>
105      * Creates the object and store it.
106      */

107     @Override JavaDoc
108     public void visitEnd() {
109         // add object
110
getAnnotationMetadata().setJEjbEJB(jEjbEJB);
111     }
112
113     /**
114      * @return type of the annotation (its description)
115      */

116     public String JavaDoc getType() {
117         return TYPE;
118     }
119
120
121     /**
122      * @return Internal object used representing &#64;{@link javax.ejb.EJB} annotation.
123      */

124     protected JEjbEJB getJEjbEJB() {
125         return jEjbEJB;
126     }
127
128     /**
129      * Sets the jEjbEJB object.
130      * @param jEjbEJB the object which replaced the previous one.
131      */

132     protected void setJEjbEJB(final JEjbEJB jEjbEJB) {
133         this.jEjbEJB = jEjbEJB;
134     }
135
136 }
137
Popular Tags