1 25 26 package org.objectweb.easybeans.deployment.annotations.analyzer.classes; 27 28 import java.util.ArrayList ; 29 import java.util.List ; 30 31 import org.objectweb.easybeans.deployment.annotations.analyzer.JavaxPersistencePersistenceUnitVisitor; 32 import org.objectweb.easybeans.deployment.annotations.impl.JavaxPersistenceUnit; 33 import org.objectweb.easybeans.deployment.annotations.metadata.ClassAnnotationMetadata; 34 35 40 public class JavaxPersistencePersistenceUnitsVisitor extends 41 JavaxPersistencePersistenceUnitVisitor<ClassAnnotationMetadata> { 42 43 46 public static final String TYPE = "Ljavax/persistence/PersistenceUnits;"; 47 48 51 private List <JavaxPersistenceUnit> javaxPersistenceUnits = null; 52 53 56 private boolean isAdded = false; 57 58 62 public JavaxPersistencePersistenceUnitsVisitor(final ClassAnnotationMetadata annotationMetadata) { 63 super(annotationMetadata); 64 javaxPersistenceUnits = new ArrayList <JavaxPersistenceUnit>(); 65 } 66 67 75 @Override 76 public void visit(final String name, final Object value) { 77 if (javaxPersistenceUnits.size() > 0 && isAdded) { 80 setjavaxPersistenceUnit(new JavaxPersistenceUnit()); 81 isAdded = false; 82 } 83 84 super.visit(name, value); 86 } 87 88 92 @Override 93 public void visitEnd() { 94 if (!isAdded) { 96 javaxPersistenceUnits.add(getJavaxPersistenceUnit()); 97 isAdded = true; 98 } 99 100 getAnnotationMetadata().setJavaxPersistencePersistenceUnits(javaxPersistenceUnits); 102 } 103 104 107 @Override 108 public String getType() { 109 return TYPE; 110 } 111 112 } 113 | Popular Tags |