1 22 package org.jboss.aop.metadata; 23 24 import javassist.CtConstructor; 25 import javassist.NotFoundException; 26 import org.jboss.aop.util.XmlHelper; 27 import org.w3c.dom.Element ; 28 29 import java.lang.reflect.Constructor ; 30 import java.util.Iterator ; 31 50 public class ConstructorConfig 51 { 52 String signature = null; 53 public ConstructorConfig() 55 { 56 } 57 58 60 public boolean patternMatches(Constructor constructor) 61 { 62 if (signature.equals("*")) 64 { 65 return true; 66 } 67 68 String sig = MethodConfig.getSignature(constructor.getParameterTypes()); 69 return sig.equals(signature); 70 } 71 72 public boolean patternMatches(CtConstructor constructor) throws NotFoundException 73 { 74 if (signature.equals("*")) 76 { 77 return true; 78 } 79 80 String sig = MethodConfig.getSignature(constructor.getParameterTypes()); 81 return sig.equals(signature); 82 } 83 84 87 public void importXml(Element element) 88 throws Exception 89 { 90 Element paramsElement = XmlHelper.getOptionalChild(element, "constructor-params"); 91 if (paramsElement == null) 92 { 93 String content = XmlHelper.getElementContent(element); 94 if (content == null || !content.equals("*")) throw new RuntimeException ("Empty <constructor> element must have at least an empty <constructor-params> element"); 95 signature = "*"; 96 return; 97 } 98 signature = "("; 99 Iterator paramsIterator = XmlHelper.getChildrenByTagName(paramsElement, 100 "constructor-param"); 101 while (paramsIterator.hasNext()) 102 { 103 signature += XmlHelper.getElementContent((Element )paramsIterator.next()).trim(); 104 signature += " "; 105 } 106 signature += ")"; 107 } 108 109 } 110 | Popular Tags |