1 22 package org.jboss.aop.annotation.factory.duplicate; 23 24 import java.lang.reflect.Method ; 25 import java.security.AccessController ; 26 import java.security.PrivilegedAction ; 27 import java.util.ArrayList ; 28 import java.util.Map ; 29 30 37 public class SimpleAnnotationValidator implements AnnotationValidator 38 { 39 40 public void validate(Map map, Class annotation) 41 { 42 ArrayList notAssignedAttributes = null; 43 Method [] methods = getDeclaredMethods(annotation); 44 for (int i = 0 ; i < methods.length ; i++) 45 { 46 if (map.get(methods[i].getName()) == null) 47 { 48 if (notAssignedAttributes == null) 49 { 50 notAssignedAttributes = new ArrayList (); 51 } 52 notAssignedAttributes.add(methods[i].getName()); 53 } 54 } 55 56 if (notAssignedAttributes != null) 57 { 58 throw new AnnotationValidationException("Unable to fill in default attributes for " + annotation + " " + notAssignedAttributes); 59 } 60 } 61 62 private Method [] getDeclaredMethods(final Class clazz) 63 { 64 return (Method [])AccessController.doPrivileged(new PrivilegedAction () { 65 public Object run() 66 { 67 return clazz.getDeclaredMethods(); 68 }; 69 }); 70 } 71 72 } 73 | Popular Tags |