1 25 26 package org.objectweb.easybeans.deployment.annotations.analyzer; 27 28 import org.objectweb.asm.ClassVisitor; 29 import org.objectweb.asm.FieldVisitor; 30 import org.objectweb.asm.MethodVisitor; 31 import org.objectweb.easybeans.deployment.annotations.JField; 32 import org.objectweb.easybeans.deployment.annotations.JMethod; 33 import org.objectweb.easybeans.deployment.annotations.analyzer.classes.JavaxAnnotationResourcesVisitor; 34 import org.objectweb.easybeans.deployment.annotations.analyzer.classes.JavaxAnnotationSecurityDeclareRolesVisitor; 35 import org.objectweb.easybeans.deployment.annotations.analyzer.classes.JavaxAnnotationSecurityRunAs; 36 import org.objectweb.easybeans.deployment.annotations.analyzer.classes.JavaxEjbApplicationExceptionVisitor; 37 import org.objectweb.easybeans.deployment.annotations.analyzer.classes.JavaxEjbEJBsVisitor; 38 import org.objectweb.easybeans.deployment.annotations.analyzer.classes.JavaxEjbLocalHomeVisitor; 39 import org.objectweb.easybeans.deployment.annotations.analyzer.classes.JavaxEjbLocalVisitor; 40 import org.objectweb.easybeans.deployment.annotations.analyzer.classes.JavaxEjbMessageDrivenVisitor; 41 import org.objectweb.easybeans.deployment.annotations.analyzer.classes.JavaxEjbRemoteHomeVisitor; 42 import org.objectweb.easybeans.deployment.annotations.analyzer.classes.JavaxEjbRemoteVisitor; 43 import org.objectweb.easybeans.deployment.annotations.analyzer.classes.JavaxEjbStatefulVisitor; 44 import org.objectweb.easybeans.deployment.annotations.analyzer.classes.JavaxEjbStatelessVisitor; 45 import org.objectweb.easybeans.deployment.annotations.analyzer.classes.JavaxEjbTransactionManagementVisitor; 46 import org.objectweb.easybeans.deployment.annotations.analyzer.classes.JavaxPersistencePersistenceContextsVisitor; 47 import org.objectweb.easybeans.deployment.annotations.analyzer.classes.JavaxPersistencePersistenceUnitsVisitor; 48 import org.objectweb.easybeans.deployment.annotations.metadata.ClassAnnotationMetadata; 49 import org.objectweb.easybeans.deployment.annotations.metadata.EjbJarAnnotationMetadata; 50 51 55 public class ScanClassVisitor extends ScanCommonVisitor<ClassAnnotationMetadata> implements ClassVisitor { 56 57 61 private ClassAnnotationMetadata classAnnotationMetadata = null; 62 63 66 private EjbJarAnnotationMetadata ejbJarAnnotationMetadata = null; 67 68 73 public ScanClassVisitor(final EjbJarAnnotationMetadata ejbJarAnnotationMetadata) { 74 this.ejbJarAnnotationMetadata = ejbJarAnnotationMetadata; 75 } 76 77 88 private void init(final String className, final String superName, final String [] interfaces) { 89 classAnnotationMetadata = new ClassAnnotationMetadata(className, ejbJarAnnotationMetadata); 90 classAnnotationMetadata.setSuperName(superName); 91 classAnnotationMetadata.setInterfaces(interfaces); 92 initVisitors(); 93 } 94 95 98 protected void initVisitors() { 99 super.initVisitors(classAnnotationMetadata); 100 getAnnotationVisitors().put(JavaxEjbLocalVisitor.TYPE, new JavaxEjbLocalVisitor(classAnnotationMetadata)); 102 103 getAnnotationVisitors().put(JavaxEjbRemoteVisitor.TYPE, new JavaxEjbRemoteVisitor(classAnnotationMetadata)); 105 106 getAnnotationVisitors().put(JavaxEjbStatelessVisitor.TYPE, 108 new JavaxEjbStatelessVisitor(classAnnotationMetadata)); 109 110 getAnnotationVisitors().put(JavaxEjbStatefulVisitor.TYPE, new JavaxEjbStatefulVisitor(classAnnotationMetadata)); 112 113 getAnnotationVisitors().put(JavaxEjbMessageDrivenVisitor.TYPE, new JavaxEjbMessageDrivenVisitor( 115 classAnnotationMetadata)); 116 117 getAnnotationVisitors().put(JavaxEjbLocalHomeVisitor.TYPE, 119 new JavaxEjbLocalHomeVisitor(classAnnotationMetadata)); 120 121 getAnnotationVisitors().put(JavaxEjbRemoteHomeVisitor.TYPE, new JavaxEjbRemoteHomeVisitor( 123 classAnnotationMetadata)); 124 125 getAnnotationVisitors().put(JavaxEjbTransactionManagementVisitor.TYPE, 127 new JavaxEjbTransactionManagementVisitor(classAnnotationMetadata)); 128 129 getAnnotationVisitors().put(JavaxEjbTransactionAttributeVisitor.TYPE, 131 new JavaxEjbTransactionAttributeVisitor<ClassAnnotationMetadata>(classAnnotationMetadata)); 132 133 getAnnotationVisitors().put(JavaxInterceptorInterceptorsVisitor.TYPE, 135 new JavaxInterceptorInterceptorsVisitor<ClassAnnotationMetadata>(classAnnotationMetadata)); 136 137 getAnnotationVisitors().put(JavaxEjbApplicationExceptionVisitor.TYPE, new JavaxEjbApplicationExceptionVisitor( 139 classAnnotationMetadata)); 140 141 getAnnotationVisitors().put(JavaxEjbEJBsVisitor.TYPE, 143 new JavaxEjbEJBsVisitor(classAnnotationMetadata)); 144 145 getAnnotationVisitors().put(JavaxAnnotationResourcesVisitor.TYPE, 147 new JavaxAnnotationResourcesVisitor(classAnnotationMetadata)); 148 149 getAnnotationVisitors().put(JavaxPersistencePersistenceContextsVisitor.TYPE, 151 new JavaxPersistencePersistenceContextsVisitor(classAnnotationMetadata)); 152 153 getAnnotationVisitors().put(JavaxPersistencePersistenceUnitsVisitor.TYPE, 155 new JavaxPersistencePersistenceUnitsVisitor(classAnnotationMetadata)); 156 157 getAnnotationVisitors().put(JavaxAnnotationSecurityDeclareRolesVisitor.TYPE, 159 new JavaxAnnotationSecurityDeclareRolesVisitor(classAnnotationMetadata)); 160 161 getAnnotationVisitors().put(JavaxAnnotationSecurityRolesAllowedVisitor.TYPE, 163 new JavaxAnnotationSecurityRolesAllowedVisitor<ClassAnnotationMetadata>(classAnnotationMetadata)); 164 165 getAnnotationVisitors().put(JavaxAnnotationSecurityPermitAllVisitor.TYPE, 167 new JavaxAnnotationSecurityPermitAllVisitor<ClassAnnotationMetadata>(classAnnotationMetadata)); 168 169 getAnnotationVisitors().put(JavaxAnnotationSecurityRunAs.TYPE, 171 new JavaxAnnotationSecurityRunAs(classAnnotationMetadata)); 172 173 } 174 175 193 @Override 194 public void visit(final int version, 195 final int access, 196 final String name, 197 final String signature, 198 final String superName, 199 final String [] interfaces) { 200 init(name, superName, interfaces); 201 } 202 203 204 205 224 @Override 225 public MethodVisitor visitMethod(final int access, final String name, final String desc, final String signature, 226 final String [] exceptions) { 227 JMethod jMethod = new JMethod(access, name, desc, signature, exceptions); 228 return new ScanMethodVisitor(jMethod, classAnnotationMetadata); 229 } 230 231 236 @Override 237 public void visitEnd() { 238 ejbJarAnnotationMetadata.addClassAnnotationMetadata(classAnnotationMetadata); 239 } 240 241 263 @Override 264 public FieldVisitor visitField(final int access, final String name, final String desc, final String signature, 265 final Object value) { 266 JField jField = new JField(access, name, desc, signature, value); 267 return new ScanFieldVisitor(jField, classAnnotationMetadata); 268 } 269 } 270 | Popular Tags |