1 25 26 package org.objectweb.easybeans.deployment.annotations.analyzer; 27 28 import static javax.annotation.Resource.AuthenticationType.APPLICATION; 29 import static javax.annotation.Resource.AuthenticationType.CONTAINER; 30 31 import org.objectweb.asm.Type; 32 33 import org.objectweb.easybeans.deployment.annotations.impl.JAnnotationResource; 34 import org.objectweb.easybeans.deployment.annotations.metadata.interfaces.IAnnotationResource; 35 36 42 public class JavaxAnnotationResourceVisitor<T extends IAnnotationResource> extends AbsAnnotationVisitor<T> implements 43 AnnotationType { 44 45 48 private static final String NAME = "name"; 49 50 53 private static final String CLASS_TYPE = "type"; 54 55 58 private static final String AUTHENTICATION_TYPE = "authenticationType"; 59 60 63 private static final String SHAREABLE = "shareable"; 64 65 68 private static final String DESCRIPTION = "description"; 69 70 73 private static final String MAPPED_NAME = "mappedName"; 74 75 78 public static final String TYPE = "Ljavax/annotation/Resource;"; 79 80 84 private JAnnotationResource jAnnotationResource = null; 85 86 90 public JavaxAnnotationResourceVisitor(final T annotationMetadata) { 91 super(annotationMetadata); 92 jAnnotationResource = new JAnnotationResource(); 93 } 94 95 103 @Override 104 public void visit(final String name, final Object value) { 105 if (name.equals(NAME)) { 106 jAnnotationResource.setName((String ) value); 107 } else if (name.equals(CLASS_TYPE)) { 108 Type type = (Type) value; 109 jAnnotationResource.setType(type.getClassName()); 110 } else if (name.equals(SHAREABLE)) { 111 jAnnotationResource.setShareable(((Boolean ) value).booleanValue()); 112 } else if (name.equals(DESCRIPTION)) { 113 jAnnotationResource.setDescription((String ) value); 114 } else if (name.equals(MAPPED_NAME)) { 115 jAnnotationResource.setMappedName((String ) value); 116 } 117 } 118 119 125 @Override 126 public void visitEnum(final String name, final String desc, final String value) { 127 if (name.equals(AUTHENTICATION_TYPE)) { 128 if (CONTAINER.name().equals(value)) { 129 jAnnotationResource.setAuthenticationType(CONTAINER); 130 } else if (APPLICATION.name().equals(value)) { 131 jAnnotationResource.setAuthenticationType(APPLICATION); 132 } 133 } 134 } 135 136 140 @Override 141 public void visitEnd() { 142 getAnnotationMetadata().setJAnnotationResource(jAnnotationResource); 144 } 145 146 149 public String getType() { 150 return TYPE; 151 } 152 153 157 protected JAnnotationResource getJAnnotationResource() { 158 return jAnnotationResource; 159 } 160 161 165 protected void setJAnnotationResource(final JAnnotationResource jAnnotationResource) { 166 this.jAnnotationResource = jAnnotationResource; 167 } 168 169 } 170 | Popular Tags |