1 22 package org.jboss.beans.metadata.plugins; 23 24 import java.lang.annotation.Annotation ; 25 import java.util.Iterator ; 26 27 import org.jboss.annotation.factory.AnnotationCreator; 28 import org.jboss.annotation.factory.ast.TokenMgrError; 29 import org.jboss.beans.metadata.spi.AnnotationMetaData; 30 import org.jboss.beans.metadata.spi.MetaDataVisitor; 31 import org.jboss.beans.metadata.spi.MetaDataVisitorNode; 32 import org.jboss.util.JBossObject; 33 import org.jboss.util.JBossStringBuilder; 34 35 41 public class AbstractAnnotationMetaData extends JBossObject implements AnnotationMetaData 42 { 43 public String annotation; 44 45 protected Annotation ann; 46 47 50 public AbstractAnnotationMetaData() 51 { 52 super(); 53 } 54 55 public String getAnnotation() 56 { 57 return annotation; 58 } 59 60 public void setAnnotation(String annotation) 61 { 62 this.annotation = annotation; 63 } 64 65 public Annotation getAnnotationInstance() 66 { 67 try 68 { 69 ann = (Annotation )AnnotationCreator.createAnnotation(annotation, Thread.currentThread().getContextClassLoader()); 71 } 72 catch (Exception e) 73 { 74 throw new RuntimeException ("Error creating annotation for " + annotation, e); 75 } 76 catch(TokenMgrError e) 77 { 78 throw new RuntimeException ("Error creating annotation for " + annotation, e); 79 } 80 81 return ann; 82 } 83 84 public void initialVisit(MetaDataVisitor visitor) 85 { 86 visitor.initialVisit(this); 87 } 88 89 public void describeVisit(MetaDataVisitor vistor) 90 { 91 vistor.describeVisit(this); 92 } 93 94 public Iterator <? extends MetaDataVisitorNode> getChildren() 95 { 96 return null; 97 } 98 99 public void toString(JBossStringBuilder buffer) 100 { 101 buffer.append("expr=").append(ann); 102 } 103 104 public void toShortString(JBossStringBuilder buffer) 105 { 106 buffer.append(ann); 107 } 108 } 109 | Popular Tags |