Source Code Cross Referenced for ScanClassVisitor.java in  » Testing » Ejb3Unit » com » bm » ejb3metadata » annotations » analyzer » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Testing » Ejb3Unit » com.bm.ejb3metadata.annotations.analyzer 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.bm.ejb3metadata.annotations.analyzer;
002:
003:        import org.ejb3unit.asm.ClassVisitor;
004:        import org.ejb3unit.asm.FieldVisitor;
005:        import org.ejb3unit.asm.MethodVisitor;
006:
007:        import com.bm.ejb3metadata.annotations.JField;
008:        import com.bm.ejb3metadata.annotations.JMethod;
009:        import com.bm.ejb3metadata.annotations.analyzer.classes.JBossEjbServiceVisitor;
010:        import com.bm.ejb3metadata.annotations.analyzer.classes.JavaxAnnotationResourcesVisitor;
011:        import com.bm.ejb3metadata.annotations.analyzer.classes.JavaxEjbApplicationExceptionVisitor;
012:        import com.bm.ejb3metadata.annotations.analyzer.classes.JavaxEjbEJBsVisitor;
013:        import com.bm.ejb3metadata.annotations.analyzer.classes.JavaxEjbLocalHomeVisitor;
014:        import com.bm.ejb3metadata.annotations.analyzer.classes.JavaxEjbLocalVisitor;
015:        import com.bm.ejb3metadata.annotations.analyzer.classes.JavaxEjbMessageDrivenVisitor;
016:        import com.bm.ejb3metadata.annotations.analyzer.classes.JavaxEjbRemoteHomeVisitor;
017:        import com.bm.ejb3metadata.annotations.analyzer.classes.JavaxEjbRemoteVisitor;
018:        import com.bm.ejb3metadata.annotations.analyzer.classes.JavaxEjbStatefulVisitor;
019:        import com.bm.ejb3metadata.annotations.analyzer.classes.JavaxEjbStatelessVisitor;
020:        import com.bm.ejb3metadata.annotations.analyzer.classes.JavaxEjbTransactionManagementVisitor;
021:        import com.bm.ejb3metadata.annotations.analyzer.classes.JavaxPersistencePersistenceContextsVisitor;
022:        import com.bm.ejb3metadata.annotations.analyzer.classes.JavaxPersistencePersistenceUnitsVisitor;
023:        import com.bm.ejb3metadata.annotations.metadata.ClassAnnotationMetadata;
024:        import com.bm.ejb3metadata.annotations.metadata.EjbJarAnnotationMetadata;
025:
026:        /**
027:         * This classes analyses a given class and build/fill meta data information.
028:         * 
029:         * @author Daniel Wiese
030:         */
031:        public class ScanClassVisitor extends
032:                ScanCommonVisitor<ClassAnnotationMetadata> implements 
033:                ClassVisitor {
034:
035:            /**
036:             * Class generated by the visitor which correspond to meta data contained
037:             * in. the parsed class
038:             */
039:            private ClassAnnotationMetadata classAnnotationMetadata = null;
040:
041:            /**
042:             * Parent of classannotation meta data that are built by this visitor.
043:             */
044:            private EjbJarAnnotationMetadata ejbJarAnnotationMetadata = null;
045:
046:            /**
047:             * Constructor.
048:             * 
049:             * @param ejbJarAnnotationMetadata
050:             *            the parent object on which add generated meta-data
051:             */
052:            public ScanClassVisitor(
053:                    final EjbJarAnnotationMetadata ejbJarAnnotationMetadata) {
054:                this .ejbJarAnnotationMetadata = ejbJarAnnotationMetadata;
055:            }
056:
057:            /**
058:             * Build the meta-data class with the given name (given by asm).
059:             * 
060:             * @param className
061:             *            name of the class that is visited
062:             * @param superName
063:             *            the internal of name of the super class (see
064:             *            {@link org.ejb3unit.asm.Type#getInternalName() getInternalName}).
065:             *            For interfaces, the super class is {@link Object}. May be
066:             *            <tt>null</tt>, but only for the {@link Object} class.
067:             * @param interfaces
068:             *            the internal names of the class's interfaces (see
069:             *            {@link org.ejb3unit.asm.Type#getInternalName() getInternalName}).
070:             *            May be <tt>null</tt>.
071:             */
072:            private void init(final String className, final String super Name,
073:                    final String[] interfaces) {
074:                classAnnotationMetadata = new ClassAnnotationMetadata(
075:                        className, ejbJarAnnotationMetadata);
076:                classAnnotationMetadata.setSuperName(super Name);
077:                classAnnotationMetadata.setInterfaces(interfaces);
078:                initVisitors();
079:            }
080:
081:            /**
082:             * Build visitors used by this one.
083:             */
084:            protected void initVisitors() {
085:                super .initVisitors(classAnnotationMetadata);
086:                // add @Local
087:                getAnnotationVisitors().put(JavaxEjbLocalVisitor.TYPE,
088:                        new JavaxEjbLocalVisitor(classAnnotationMetadata));
089:
090:                // add @Remote
091:                getAnnotationVisitors().put(JavaxEjbRemoteVisitor.TYPE,
092:                        new JavaxEjbRemoteVisitor(classAnnotationMetadata));
093:
094:                // add @Stateless
095:                getAnnotationVisitors().put(JavaxEjbStatelessVisitor.TYPE,
096:                        new JavaxEjbStatelessVisitor(classAnnotationMetadata));
097:
098:                // add @Stateful
099:                getAnnotationVisitors().put(JavaxEjbStatefulVisitor.TYPE,
100:                        new JavaxEjbStatefulVisitor(classAnnotationMetadata));
101:
102:                // add @Service
103:                getAnnotationVisitors().put(JBossEjbServiceVisitor.TYPE,
104:                        new JBossEjbServiceVisitor(classAnnotationMetadata));
105:
106:                // add @MessageDriven
107:                getAnnotationVisitors().put(
108:                        JavaxEjbMessageDrivenVisitor.TYPE,
109:                        new JavaxEjbMessageDrivenVisitor(
110:                                classAnnotationMetadata));
111:
112:                // add @LocalHome
113:                getAnnotationVisitors().put(JavaxEjbLocalHomeVisitor.TYPE,
114:                        new JavaxEjbLocalHomeVisitor(classAnnotationMetadata));
115:
116:                // add @RemoteHome
117:                getAnnotationVisitors().put(JavaxEjbRemoteHomeVisitor.TYPE,
118:                        new JavaxEjbRemoteHomeVisitor(classAnnotationMetadata));
119:
120:                // add @TransactionManagement
121:                getAnnotationVisitors().put(
122:                        JavaxEjbTransactionManagementVisitor.TYPE,
123:                        new JavaxEjbTransactionManagementVisitor(
124:                                classAnnotationMetadata));
125:
126:                // add @TransactionAttribute
127:                getAnnotationVisitors()
128:                        .put(
129:                                JavaxEjbTransactionAttributeVisitor.TYPE,
130:                                new JavaxEjbTransactionAttributeVisitor<ClassAnnotationMetadata>(
131:                                        classAnnotationMetadata));
132:
133:                // add @Interceptors
134:                getAnnotationVisitors()
135:                        .put(
136:                                JavaxInterceptorInterceptorsVisitor.TYPE,
137:                                new JavaxInterceptorInterceptorsVisitor<ClassAnnotationMetadata>(
138:                                        classAnnotationMetadata));
139:
140:                // add @ApplicationException
141:                getAnnotationVisitors().put(
142:                        JavaxEjbApplicationExceptionVisitor.TYPE,
143:                        new JavaxEjbApplicationExceptionVisitor(
144:                                classAnnotationMetadata));
145:
146:                // add @EJBs
147:                getAnnotationVisitors().put(JavaxEjbEJBsVisitor.TYPE,
148:                        new JavaxEjbEJBsVisitor(classAnnotationMetadata));
149:
150:                // add @Resources
151:                getAnnotationVisitors().put(
152:                        JavaxAnnotationResourcesVisitor.TYPE,
153:                        new JavaxAnnotationResourcesVisitor(
154:                                classAnnotationMetadata));
155:
156:                // add @PersistenceContexts
157:                getAnnotationVisitors().put(
158:                        JavaxPersistencePersistenceContextsVisitor.TYPE,
159:                        new JavaxPersistencePersistenceContextsVisitor(
160:                                classAnnotationMetadata));
161:
162:                // add @PersistenceUnits
163:                getAnnotationVisitors().put(
164:                        JavaxPersistencePersistenceUnitsVisitor.TYPE,
165:                        new JavaxPersistencePersistenceUnitsVisitor(
166:                                classAnnotationMetadata));
167:
168:            }
169:
170:            /**
171:             * Visits the header of the class.
172:             * 
173:             * @param version
174:             *            the class version.
175:             * @param access
176:             *            the class's access flags (see {@link org.ejb3unit.asm.Opcodes}).
177:             *            This parameter also indicates if the class is deprecated.
178:             * @param name
179:             *            the internal name of the class (see
180:             *            {@link org.ejb3unit.asm.Type#getInternalName() getInternalName}).
181:             * @param signature
182:             *            the signature of this class. May be <tt>null</tt> if the
183:             *            class is not a generic one, and does not extend or implement
184:             *            generic classes or interfaces.
185:             * @param superName
186:             *            the internal of name of the super class (see
187:             *            {@link org.ejb3unit.asm.Type#getInternalName() getInternalName}).
188:             *            For interfaces, the super class is {@link Object}. May be
189:             *            <tt>null</tt>, but only for the {@link Object} class.
190:             * @param interfaces
191:             *            the internal names of the class's interfaces (see
192:             *            {@link org.ejb3unit.asm.Type#getInternalName() getInternalName}).
193:             *            May be <tt>null</tt>.
194:             */
195:            @Override
196:            public void visit(final int version, final int access,
197:                    final String name, final String signature,
198:                    final String super Name, final String[] interfaces) {
199:                init(name, super Name, interfaces);
200:            }
201:
202:            /**
203:             * Visits a method of the class. This method <i>must</i> return a new
204:             * {@link org.ejb3unit.asm.MethodVisitor} instance (or <tt>null</tt>)
205:             * each time it is called, i.e., it should not return a previously returned
206:             * visitor.
207:             * 
208:             * @param access
209:             *            the method's access flags (see
210:             *            {@link org.ejb3unit.asm.Opcodes}). This parameter also
211:             *            indicates if the method is synthetic and/or deprecated.
212:             * @param name
213:             *            the method's name.
214:             * @param desc
215:             *            the method's descriptor (see {@link org.ejb3unit.asm.Type}).
216:             * @param signature
217:             *            the method's signature. May be <tt>null</tt> if the method
218:             *            parameters, return type and exceptions do not use generic
219:             *            types.
220:             * @param exceptions
221:             *            the internal names of the method's exception classes (see
222:             *            {@link org.ejb3unit.asm.Type#getInternalName() getInternalName}).
223:             *            May be <tt>null</tt>.
224:             * @return an object to visit the byte code of the method, or <tt>null</tt>
225:             *         if this class visitor is not interested in visiting the code of
226:             *         this method.
227:             */
228:            @Override
229:            public MethodVisitor visitMethod(final int access,
230:                    final String name, final String desc,
231:                    final String signature, final String[] exceptions) {
232:                JMethod jMethod = new JMethod(access, name, desc, signature,
233:                        exceptions);
234:                return new ScanMethodVisitor(jMethod, classAnnotationMetadata);
235:            }
236:
237:            /**
238:             * Visits the end of the class. This method, which is the last one to be
239:             * called, is used to inform the visitor that all the fields and methods of
240:             * the class have been visited.
241:             */
242:            @Override
243:            public void visitEnd() {
244:                ejbJarAnnotationMetadata
245:                        .addClassAnnotationMetadata(classAnnotationMetadata);
246:            }
247:
248:            /**
249:             * Visits a field of the class.
250:             * 
251:             * @param access
252:             *            the field's access flags (see {@link org.ejb3unit.asm.Opcodes}).
253:             *            This parameter also indicates if the field is synthetic and/or
254:             *            deprecated.
255:             * @param name
256:             *            the field's name.
257:             * @param desc
258:             *            the field's descriptor (see {@link org.ejb3unit.asm.Type}).
259:             * @param signature
260:             *            the field's signature. May be <tt>null</tt> if the field's
261:             *            type does not use generic types.
262:             * @param value
263:             *            the field's initial value. This parameter, which may be
264:             *            <tt>null</tt> if the field does not have an initial value,
265:             *            must be an {@link Integer}, a {@link Float}, a {@link Long},
266:             *            a {@link Double} or a {@link String} (for <tt>int</tt>,
267:             *            <tt>float</tt>, <tt>long</tt> or <tt>String</tt> fields
268:             *            respectively). <i>This parameter is only used for static
269:             *            fields</i>. Its value is ignored for non static fields, which
270:             *            must be initialized through bytecode instructions in
271:             *            constructors or methods.
272:             * @return a visitor to visit field annotations and attributes, or
273:             *         <tt>null</tt> if this class visitor is not interested in
274:             *         visiting these annotations and attributes.
275:             */
276:            @Override
277:            public FieldVisitor visitField(final int access, final String name,
278:                    final String desc, final String signature,
279:                    final Object value) {
280:                JField jField = new JField(access, name, desc, signature, value);
281:                return new ScanFieldVisitor(jField, classAnnotationMetadata);
282:            }
283:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.