1 25 26 package org.objectweb.easybeans.deployment.annotations.analyzer; 27 28 import javax.persistence.PersistenceContextType; 29 30 import org.objectweb.easybeans.deployment.annotations.impl.JavaxPersistenceContext; 31 import org.objectweb.easybeans.deployment.annotations.metadata.interfaces.IPersistenceContext; 32 33 39 public class JavaxPersistencePersistenceContextVisitor<T extends IPersistenceContext> extends AbsAnnotationVisitor<T> implements 40 AnnotationType { 41 42 45 public static final String TYPE = "Ljavax/persistence/PersistenceContext;"; 46 47 50 private static final String NAME = "name"; 51 52 53 56 private static final String UNIT_NAME = "unitName"; 57 58 61 private static final String PERSISTENCECONTEXT_TYPE = "type"; 62 63 66 private static final String PERSISTENCECONTEXT_TTRANSACTION_TYPE = "TRANSACTION"; 67 68 69 72 private JavaxPersistenceContext javaxPersistenceContext = null; 73 74 78 public JavaxPersistencePersistenceContextVisitor(final T annotationMetadata) { 79 super(annotationMetadata); 80 javaxPersistenceContext = new JavaxPersistenceContext(); 81 } 82 83 91 @Override 92 public void visit(final String name, final Object value) { 93 if (UNIT_NAME.equals(name)) { 94 javaxPersistenceContext.setUnitName((String ) value); 95 } else if (NAME.equals(name)) { 96 javaxPersistenceContext.setName((String ) value); 97 } 98 } 99 100 106 @Override 107 public void visitEnum(final String name, final String desc, final String value) { 108 if (name.equals(PERSISTENCECONTEXT_TYPE)) { 109 if (PERSISTENCECONTEXT_TTRANSACTION_TYPE.equals(value)) { 110 javaxPersistenceContext.setType(PersistenceContextType.TRANSACTION); 111 } else { 112 javaxPersistenceContext.setType(PersistenceContextType.EXTENDED); 113 } 114 115 } 116 } 117 118 119 122 protected JavaxPersistenceContext getJavaxPersistenceContext() { 123 return javaxPersistenceContext; 124 } 125 126 130 protected void setJavaxPersistenceContext(final JavaxPersistenceContext javaxPersistenceContext) { 131 this.javaxPersistenceContext = javaxPersistenceContext; 132 } 133 134 138 @Override 139 public void visitEnd() { 140 getAnnotationMetadata().setJavaxPersistenceContext(javaxPersistenceContext); 142 } 143 144 147 public String getType() { 148 return TYPE; 149 } 150 151 } 152 | Popular Tags |