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.JavaxPersistencePersistenceContextVisitor; 32 import org.objectweb.easybeans.deployment.annotations.impl.JavaxPersistenceContext; 33 import org.objectweb.easybeans.deployment.annotations.metadata.ClassAnnotationMetadata; 34 35 40 public class JavaxPersistencePersistenceContextsVisitor extends 41 JavaxPersistencePersistenceContextVisitor<ClassAnnotationMetadata> { 42 43 46 public static final String TYPE = "Ljavax/persistence/PersistenceContexts;"; 47 48 51 private List <JavaxPersistenceContext> javaxPersistenceContexts = null; 52 53 56 private boolean isAdded = false; 57 58 62 public JavaxPersistencePersistenceContextsVisitor(final ClassAnnotationMetadata annotationMetadata) { 63 super(annotationMetadata); 64 javaxPersistenceContexts = new ArrayList <JavaxPersistenceContext>(); 65 } 66 67 75 @Override 76 public void visit(final String name, final Object value) { 77 if (javaxPersistenceContexts.size() > 0 && isAdded) { 80 setJavaxPersistenceContext(new JavaxPersistenceContext()); 81 isAdded = false; 82 } 83 84 super.visit(name, value); 86 } 87 88 92 @Override 93 public void visitEnd() { 94 if (!isAdded) { 96 javaxPersistenceContexts.add(getJavaxPersistenceContext()); 97 isAdded = true; 98 } 99 100 getAnnotationMetadata().setJavaxPersistencePersistenceContexts(javaxPersistenceContexts); 102 } 103 104 107 @Override 108 public String getType() { 109 return TYPE; 110 } 111 112 } 113 | Popular Tags |