1 22 package org.jboss.aop.standalone; 23 24 import org.jboss.aop.Advisor; 25 import org.jboss.aop.AspectManager; 26 27 import java.util.HashMap ; 28 import java.util.Iterator ; 29 import java.util.Map ; 30 import java.util.StringTokenizer ; 31 32 38 public class Package implements java.io.Serializable 39 { 40 static final long serialVersionUID = 6188655039267365373L; 41 public HashMap advisors = new HashMap (); 42 public HashMap packages = new HashMap (); 43 public String name; 44 45 public Package(String name) 46 { 47 this.name = name; 48 } 49 50 static void parse(Class clazz, Package root) 51 { 52 Advisor advisor = AspectManager.instance().findAdvisor(clazz); 53 StringTokenizer tokenizer = new StringTokenizer (clazz.getName(), "."); 54 while (tokenizer.hasMoreTokens()) 55 { 56 String pkgName = tokenizer.nextToken(); 57 if (tokenizer.hasMoreTokens()) 58 { 59 Package subpkg = (Package ) root.packages.get(pkgName); 60 if (subpkg == null) 61 { 62 subpkg = new Package (pkgName); 63 root.packages.put(pkgName, subpkg); 64 } 65 root = subpkg; 66 } 67 else 68 { 69 root.advisors.put(pkgName, advisor); 70 } 71 } 72 } 73 74 public static Package aopClassMap() 75 { 76 Map advisors = AspectManager.instance().getAdvisors(); 77 Iterator it = advisors.keySet().iterator(); 78 Package root = new Package ("classes"); 79 while (it.hasNext()) 80 { 81 Class clazz = (Class ) it.next(); 82 parse(clazz, root); 83 } 84 return root; 85 } 86 } 87 | Popular Tags |