1 25 26 package org.objectweb.easybeans.deployment.annotations.analyzer; 27 28 import java.util.HashMap ; 29 import java.util.Map ; 30 31 import org.objectweb.asm.AnnotationVisitor; 32 import org.objectweb.asm.commons.EmptyVisitor; 33 import org.objectweb.easybeans.deployment.annotations.metadata.interfaces.ISharedMetadata; 34 35 41 public abstract class ScanCommonVisitor<T extends ISharedMetadata> extends EmptyVisitor { 42 43 46 private EmptyVisitor emptyVisitor = null; 47 48 52 private Map <String , AnnotationVisitor> annotationVisitors = null; 53 54 58 public ScanCommonVisitor() { 59 annotationVisitors = new HashMap <String , AnnotationVisitor>(); 60 } 61 62 66 protected void initVisitors(final T annotationMetadata) { 67 emptyVisitor = new EmptyVisitor(); 68 69 annotationVisitors.put(JavaxEjbEJBVisitor.TYPE, 71 new JavaxEjbEJBVisitor<T>(annotationMetadata)); 72 73 annotationVisitors.put(JavaxAnnotationResourceVisitor.TYPE, 75 new JavaxAnnotationResourceVisitor<T>(annotationMetadata)); 76 77 78 annotationVisitors.put(JavaxPersistencePersistenceContextVisitor.TYPE, 80 new JavaxPersistencePersistenceContextVisitor<T>(annotationMetadata)); 81 82 annotationVisitors.put(JavaxPersistencePersistenceUnitVisitor.TYPE, 84 new JavaxPersistencePersistenceUnitVisitor<T>(annotationMetadata)); 85 86 } 87 88 89 92 protected EmptyVisitor getEmptyVisitor() { 93 return emptyVisitor; 94 } 95 96 102 @Override 103 public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) { 104 AnnotationVisitor av = annotationVisitors.get(desc); 105 if (av != null) { 106 return av; 107 } 108 return emptyVisitor; 109 } 110 111 114 protected Map <String , AnnotationVisitor> getAnnotationVisitors() { 115 return annotationVisitors; 116 } 117 118 119 } 120 | Popular Tags |