1 25 26 package org.objectweb.easybeans.deployment.annotations.analyzer; 27 28 import org.objectweb.easybeans.deployment.annotations.impl.JavaxPersistenceUnit; 29 import org.objectweb.easybeans.deployment.annotations.metadata.interfaces.IPersistenceUnit; 30 31 37 public class JavaxPersistencePersistenceUnitVisitor<T extends IPersistenceUnit> extends AbsAnnotationVisitor<T> implements 38 AnnotationType { 39 40 43 public static final String TYPE = "Ljavax/persistence/PersistenceUnit;"; 44 45 48 private static final String NAME = "name"; 49 50 53 private static final String UNIT_NAME = "unitName"; 54 55 58 private JavaxPersistenceUnit javaxPersistenceUnit = null; 59 60 64 public JavaxPersistencePersistenceUnitVisitor(final T annotationMetadata) { 65 super(annotationMetadata); 66 javaxPersistenceUnit = new JavaxPersistenceUnit(); 67 } 68 69 77 @Override 78 public void visit(final String name, final Object value) { 79 if (NAME.equals(name)) { 80 javaxPersistenceUnit.setName((String ) value); 81 } else if (name.equals(UNIT_NAME)) { 82 javaxPersistenceUnit.setUnitName((String ) value); 83 } 84 } 85 86 89 protected JavaxPersistenceUnit getJavaxPersistenceUnit() { 90 return javaxPersistenceUnit; 91 } 92 93 97 protected void setjavaxPersistenceUnit(final JavaxPersistenceUnit javaxPersistenceUnit) { 98 this.javaxPersistenceUnit = javaxPersistenceUnit; 99 } 100 101 102 106 @Override 107 public void visitEnd() { 108 getAnnotationMetadata().setJavaxPersistenceUnit(javaxPersistenceUnit); 110 } 111 112 115 public String getType() { 116 return TYPE; 117 } 118 119 } 120 | Popular Tags |