1 22 package org.jboss.annotation.factory.javassist; 23 24 import java.lang.reflect.InvocationHandler ; 25 import java.util.Map ; 26 27 34 public class AnnotationProxy extends org.jboss.annotation.factory.AnnotationProxy implements InvocationHandler 35 { 36 public AnnotationProxy(Class annotationType, Map valueMap) 37 { 38 super(annotationType, valueMap); 39 } 40 41 public static Object createProxy(javassist.bytecode.annotation.Annotation info) throws Exception 42 { 43 Class annotation = Thread.currentThread().getContextClassLoader().loadClass(info.getTypeName()); 44 return createProxy(info, annotation); 45 } 46 47 public static Object createProxy(javassist.bytecode.annotation.Annotation info, Class annotation) throws Exception 48 { 49 Map <String , Object > map = ProxyMapCreator.createProxyMap(annotation, info); 50 DefaultValueAnnotationValidator reader = new DefaultValueAnnotationValidator(); 51 reader.validate(map, annotation); 52 AnnotationProxy proxyHandler = new AnnotationProxy(annotation, map); 53 return java.lang.reflect.Proxy.newProxyInstance(annotation.getClassLoader(), new Class []{annotation}, proxyHandler); 54 } 55 56 } 57 | Popular Tags |