1 22 package org.jboss.mx.loading; 23 24 import java.net.MalformedURLException ; 25 import java.net.URL ; 26 import java.net.URLClassLoader ; 27 import java.util.ArrayList ; 28 import java.util.HashMap ; 29 import java.util.HashSet ; 30 import java.util.Iterator ; 31 import java.util.List ; 32 import java.util.Enumeration ; 33 import java.util.Map ; 34 import java.util.Set ; 35 import java.util.TreeSet ; 36 import java.io.IOException ; 37 38 import javax.management.ListenerNotFoundException ; 39 import javax.management.MBeanNotificationInfo ; 40 import javax.management.Notification ; 41 import javax.management.NotificationBroadcaster ; 42 import javax.management.NotificationFilter ; 43 import javax.management.NotificationListener ; 44 import javax.management.MBeanRegistration ; 45 import javax.management.ObjectName ; 46 import javax.management.MBeanServer ; 47 import javax.management.loading.MLet ; 48 49 import org.jboss.logging.Logger; 50 import org.jboss.mx.util.JBossNotificationBroadcasterSupport; 51 import org.jboss.util.Classes; 52 53 import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap; 54 import EDU.oswego.cs.dl.util.concurrent.CopyOnWriteArraySet; 55 56 68 public class UnifiedLoaderRepository3 extends LoaderRepository 69 implements MBeanRegistration , NotificationBroadcaster , 70 UnifiedLoaderRepository3MBean 71 { 72 private static final Logger log = Logger.getLogger(UnifiedLoaderRepository3.class); 74 76 private static int addedCount; 77 78 80 83 private CopyOnWriteArraySet classLoaders = new CopyOnWriteArraySet(); 84 88 private HashSet dynamicClassLoaders = new HashSet (); 89 94 private HashMap nonUCLClassLoader = new HashMap (); 95 96 101 private HashSet classLoaderURLs = new HashSet (); 102 103 106 private ConcurrentReaderHashMap classes = new ConcurrentReaderHashMap(); 107 108 112 private HashMap loaderToClassesMap = new HashMap (); 113 114 118 private HashMap loaderToResourcesMap = new HashMap (); 119 120 124 private HashMap globalResources = new HashMap (); 125 126 130 private ConcurrentReaderHashMap packagesMap = new ConcurrentReaderHashMap(); 131 132 136 private HashMap <RepositoryClassLoader, List <String >> loaderToPackagesMap = new HashMap <RepositoryClassLoader, List <String >>(); 137 138 141 private long sequenceNumber = 0; 142 143 146 private final JBossNotificationBroadcasterSupport broadcaster = new JBossNotificationBroadcasterSupport(); 147 148 151 private MBeanNotificationInfo [] info; 152 153 154 156 public RepositoryClassLoader newClassLoader(final URL url, boolean addToRepository) 157 throws Exception 158 { 159 UnifiedClassLoader3 ucl = new UnifiedClassLoader3(url, null, this); 160 if (addToRepository) 161 this.registerClassLoader(ucl); 162 return ucl; 163 } 164 165 public RepositoryClassLoader newClassLoader(final URL url, final URL origURL, boolean addToRepository) 166 throws Exception 167 { 168 UnifiedClassLoader3 ucl = new UnifiedClassLoader3(url, origURL, this); 169 if (addToRepository) 170 this.registerClassLoader(ucl); 171 return ucl; 172 } 173 174 public int getCacheSize() 175 { 176 return classes.size(); 177 } 178 179 public int getClassLoadersSize() 180 { 181 return classLoaders.size(); 182 } 183 184 public void flush() 185 { 186 synchronized (classes) 187 { 188 classes.clear(); 189 } 190 } 191 192 public Class getCachedClass(String classname) 193 { 194 return (Class ) classes.get(classname); 195 } 196 197 201 public Class loadClass(String name, boolean resolve, ClassLoader cl) throws ClassNotFoundException 202 { 203 RepositoryClassLoader rcl = getRepositoryClassLoader(cl, name); 204 return rcl.loadClass(name, resolve); 205 } 206 207 210 public Set getPackageClassLoaders(String className) 211 { 212 String pkgName = ClassLoaderUtils.getPackageName(className); 213 Set pkgSet = (Set ) packagesMap.get(pkgName); 214 if (dynamicClassLoaders.size() > 0) 215 { 216 if (pkgSet == null) 217 pkgSet = ClassLoaderUtils.newPackageSet(); 218 pkgSet.addAll(dynamicClassLoaders); 219 } 220 return pkgSet; 221 } 222 223 private String getResourcePackageName(String rsrcName) 224 { 225 int index = rsrcName.lastIndexOf('/'); 226 String pkgName = rsrcName; 227 if (index > 0) 228 pkgName = rsrcName.substring(0, index); 229 return pkgName.replace('/', '.'); 230 } 231 232 236 public Class loadClassFromCache(String name) 237 { 238 Class cls = null; 239 synchronized (classes) 240 { 241 cls = (Class ) classes.get(name); 242 } 243 return cls; 244 } 245 246 251 public void cacheLoadedClass(String name, Class cls, ClassLoader cl) 252 { 253 synchronized (classes) 254 { 255 Object prevClass = classes.put(name, cls); 257 if (log.isTraceEnabled()) 258 { 259 log.trace("cacheLoadedClass, classname: " + name + ", class: " + cls 260 + ", ucl: " + cl + ", prevClass: " + prevClass); 261 } 262 263 HashSet loadedClasses = (HashSet ) loaderToClassesMap.get(cl); 266 if (loadedClasses == null) 267 { 268 loadedClasses = new HashSet (); 269 loaderToClassesMap.put(cl, loadedClasses); 270 } 271 loadedClasses.add(name); 272 } 273 } 274 275 Class loadClassFromClassLoader(String name, boolean resolve, RepositoryClassLoader cl) 276 { 277 try 278 { 279 Class cls = cl.loadClassLocally(name, resolve); 280 cacheLoadedClass(name, cls, cl); 281 return cls; 282 } 283 catch (ClassNotFoundException x) 284 { 285 } 287 return null; 288 } 289 290 293 public URL getResource(String name, ClassLoader cl) 294 { 295 URL resource = getResourceFromCache(name, cl); 298 299 if (resource != null) 301 return resource; 302 303 resource = getResourceFromClassLoader(name, cl); 305 306 if (resource != null) 308 return resource; 309 310 resource = getResourceFromGlobalCache(name); 312 313 if (resource != null) 315 return resource; 316 317 resource = getResourceFromRepository(name, cl); 319 320 if (resource != null) 322 return resource; 323 324 return null; 326 } 327 328 335 public void getResources(String name, ClassLoader cl, List urls) 336 { 337 Iterator iter = classLoaders.iterator(); 339 while (iter.hasNext() == true) 340 { 341 ClassLoader nextCL = (ClassLoader ) iter.next(); 342 if (nextCL instanceof RepositoryClassLoader) 343 { 344 RepositoryClassLoader ucl = (RepositoryClassLoader) nextCL; 345 try 346 { 347 Enumeration resURLs = ucl.findResourcesLocally(name); 348 while (resURLs.hasMoreElements()) 349 { 350 Object res = resURLs.nextElement(); 351 urls.add(res); 352 } 353 } 354 catch (IOException ignore) 355 { 356 } 357 } 358 } 359 } 360 361 369 private URL getResourceFromCache(String name, ClassLoader cl) 370 { 371 URL resource = null; 372 synchronized (loaderToResourcesMap) 373 { 374 if (loaderToResourcesMap.containsKey(cl)) 375 { 376 HashMap resources = (HashMap ) loaderToResourcesMap.get(cl); 377 resource = (URL ) resources.get(name); 378 } 379 } 380 return resource; 381 } 382 383 private URL getResourceFromClassLoader(String name, ClassLoader cl) 384 { 385 URL resource = null; 386 if (cl instanceof RepositoryClassLoader) 387 { 388 RepositoryClassLoader ucl = (RepositoryClassLoader) cl; 389 resource = ucl.getResourceLocally(name); 390 cacheLoadedResource(name, resource, cl); 391 } 392 return resource; 393 } 394 395 400 protected URL getResourceFromGlobalCache(String name) 401 { 402 ResourceInfo ri = null; 403 synchronized (loaderToResourcesMap) 404 { 405 ri = (ResourceInfo) globalResources.get(name); 406 } 407 URL resource = null; 408 if (ri != null) 409 resource = ri.url; 410 return resource; 411 } 412 413 protected URL getResourceFromRepository(String name, ClassLoader cl) 414 { 415 String pkgName = getResourcePackageName(name); 417 Iterator i = null; 418 Set pkgSet = (Set ) this.packagesMap.get(pkgName); 419 if (pkgSet != null) 420 { 421 i = pkgSet.iterator(); 422 } 423 if (i == null) 424 { 425 i = classLoaders.iterator(); 427 } 428 429 URL url = null; 430 while (i.hasNext() == true) 431 { 432 ClassLoader classloader = (ClassLoader ) i.next(); 433 if (classloader.equals(cl)) 434 { 435 continue; 436 } 437 438 if (classloader instanceof RepositoryClassLoader) 439 { 440 url = ((RepositoryClassLoader) classloader).getResourceLocally(name); 441 if (url != null) 442 { 443 cacheLoadedResource(name, url, classloader); 444 cacheGlobalResource(name, url, classloader); 445 break; 446 } 447 else 448 { 449 } 451 } 452 } 453 return url; 454 } 455 456 461 private void cacheLoadedResource(String name, URL url, ClassLoader cl) 462 { 463 synchronized (loaderToResourcesMap) 466 { 467 HashMap resources = (HashMap ) loaderToResourcesMap.get(cl); 468 if (resources == null) 469 { 470 resources = new HashMap (); 471 loaderToResourcesMap.put(cl, resources); 472 } 473 resources.put(name, url); 474 } 475 } 476 477 482 private void cacheGlobalResource(String name, URL url, ClassLoader cl) 483 { 484 synchronized (loaderToResourcesMap) 485 { 486 globalResources.put(name, new ResourceInfo(url, cl)); 487 } 488 } 489 490 494 public URL [] getURLs() 495 { 496 HashSet classpath = new HashSet (); 497 Set tmp = classLoaders; 498 for (Iterator iter = tmp.iterator(); iter.hasNext();) 499 { 500 Object obj = iter.next(); 501 if (obj instanceof RepositoryClassLoader) 502 { 503 RepositoryClassLoader cl = (RepositoryClassLoader) obj; 504 URL [] urls = cl.getClasspath(); 505 int length = urls != null ? urls.length : 0; 506 for (int u = 0; u < length; u++) 507 { 508 URL path = urls[u]; 509 classpath.add(path); 510 } 511 } 512 } 514 URL [] cp = new URL [classpath.size()]; 515 classpath.toArray(cp); 516 return cp; 517 } 518 519 523 public String displayClassInfo(String className) 524 { 525 528 String classRsrcName = className.replace('.', '/') + ".class"; 529 530 int count = 0; 531 Class loadedClass = this.loadClassFromCache(className); 532 StringBuffer results = new StringBuffer (className + " Information\n"); 533 if (loadedClass != null) 534 { 535 results.append("Repository cache version:"); 536 Classes.displayClassInfo(loadedClass, results); 537 } 538 else 539 { 540 results.append("Not loaded in repository cache\n"); 541 } 542 Set tmp = classLoaders; 543 for (Iterator iter = tmp.iterator(); iter.hasNext();) 544 { 545 URLClassLoader cl = (URLClassLoader ) iter.next(); 546 URL classURL = cl.findResource(classRsrcName); 547 if (classURL != null) 548 { 549 results.append("\n\n### Instance" + count + " found in UCL: " + cl + "\n"); 550 count++; 551 } 552 } 553 554 ClassLoader tcl = Thread.currentThread().getContextClassLoader(); 556 URLClassLoader [] stack = ClassLoaderUtils.getClassLoaderStack(tcl); 557 for (int s = 0; s < stack.length; s++) 558 { 559 URLClassLoader cl = stack[s]; 560 URL classURL = cl.findResource(classRsrcName); 561 if (classURL != null) 562 { 563 results.append("\n\n### Instance" + count + " via UCL: " + cl + "\n"); 564 count++; 565 } 566 } 567 568 return results.toString(); 569 } 570 571 573 578 public Class loadClass(String className) throws ClassNotFoundException 579 { 580 ClassLoader scl = Thread.currentThread().getContextClassLoader(); 582 ClassLoader ucl = null; 583 if (classLoaders.size() > 0) 584 ucl = (ClassLoader ) this.classLoaders.iterator().next(); 585 try 586 { 587 if (ucl != null) 588 return loadClass(className, false, ucl); 589 } 590 catch (ClassNotFoundException ignore) 591 { 592 } 594 595 try 596 { 597 return scl.loadClass(className); 599 } 600 catch (ClassNotFoundException e) 601 { 602 } 604 605 Class clazz = getNativeClassForName(className); 607 if (clazz != null) return clazz; 608 609 throw new ClassNotFoundException (className); 610 } 611 612 621 public Class loadClassWithout(ClassLoader loader, String className) 622 throws ClassNotFoundException 623 { 624 throw new ClassNotFoundException ("NYI"); 625 } 626 627 638 public Class loadClassBefore(ClassLoader stop, String className) throws ClassNotFoundException 639 { 640 RepositoryClassLoader stopAt = getRepositoryClassLoader(stop, className); 641 return stopAt.loadClassBefore(className); 642 } 643 644 650 public RepositoryClassLoader getWrappingClassLoader(ClassLoader cl) 651 { 652 synchronized (classLoaders) 653 { 654 return (RepositoryClassLoader) nonUCLClassLoader.get(cl); 655 } 656 } 657 658 660 public void addClassLoader(ClassLoader loader) 661 { 662 if (loader instanceof RepositoryClassLoader) 664 addRepositoryClassLoader((RepositoryClassLoader) loader); 665 else if (loader instanceof MLet ) 666 { 667 addMLetClassLoader((MLet ) loader); 668 } 669 else if (loader instanceof URLClassLoader ) 670 { 671 addURLClassLoader((URLClassLoader ) loader); 672 } 673 else 674 { 675 log.warn("Tried to add non-URLClassLoader. Ignored"); 676 } } 678 679 public boolean addClassLoaderURL(ClassLoader cl, URL url) 680 { 681 RepositoryClassLoader ucl = (RepositoryClassLoader) cl; 682 boolean added = false; 683 synchronized (classLoaders) 684 { 685 String query = url.getQuery(); 687 if (query != null) 688 { 689 String ext = url.toExternalForm(); 690 String ext2 = ext.substring(0, ext.length() - query.length() - 1); 691 try 692 { 693 url = new URL (ext2); 694 } 695 catch (MalformedURLException e) 696 { 697 log.warn("Failed to strip query from: " + url, e); 698 } 699 } 700 701 if (classLoaderURLs.contains(url) == false) 703 { 704 updatePackageMap(ucl, url); 705 classLoaderURLs.add(url); 706 added = true; 707 if (query != null && query.indexOf("dynamic=true") >= 0) 709 dynamicClassLoaders.add(ucl); 710 } 711 } 712 return added; 713 } 714 715 719 private void addRepositoryClassLoader(RepositoryClassLoader cl) 720 { 721 cl.setRepository(this); 722 URL url = cl.getURL(); 724 boolean added = false; 725 synchronized (classLoaders) 726 { 727 boolean exists = false; 728 if (cl instanceof UnifiedClassLoader) 729 exists = classLoaderURLs.contains(url); 730 if (!exists) 732 { 733 if (url != null) 734 classLoaderURLs.add(url); 735 added = classLoaders.add(cl); 736 } 737 if (added) 738 { 739 log.debug("Adding " + cl); 740 addedCount++; 741 cl.setAddedOrder(addedCount); 742 updatePackageMap(cl); 743 } 744 else 745 { 746 log.debug("Skipping duplicate " + cl); 747 } 748 } 749 } 750 751 private void addMLetClassLoader(MLet loader) 752 { 753 MLetRepositoryClassLoader rcl = new MLetRepositoryClassLoader(loader); 754 synchronized (classLoaders) 755 { 756 nonUCLClassLoader.put(loader, rcl); 757 } 758 addRepositoryClassLoader(rcl); 759 } 760 761 private void addURLClassLoader(URLClassLoader loader) 762 { 763 URL [] urls = loader.getURLs(); 764 int count = urls != null && urls.length > 0 ? urls.length : 0; 765 URL origURL = count > 0 ? urls[0] : null; 766 UnifiedClassLoader3 ucl3 = new UnifiedClassLoader3(origURL, origURL, this); 767 addRepositoryClassLoader(ucl3); 768 synchronized (classLoaders) 769 { 770 nonUCLClassLoader.put(loader, ucl3); 771 } 772 for (int i = 1; i < count; i++) 773 { 774 this.addClassLoaderURL(ucl3, urls[i]); 775 } 776 } 777 778 781 private void updatePackageMap(RepositoryClassLoader cl) 782 { 783 try 784 { 785 URL url = cl.getURL(); 786 PackageMapper listener = new PackageMapper(cl); 787 ClassLoaderUtils.updatePackageMap(url, listener); 788 } 789 catch (Exception e) 790 { 791 if (log.isTraceEnabled()) 792 log.trace("Failed to update pkgs for cl=" + cl, e); 793 else 794 log.debug("Failed to update pkgs for cl=" + cl, e); 795 } 796 } 797 798 801 private void updatePackageMap(RepositoryClassLoader cl, URL url) 802 { 803 try 804 { 805 PackageMapper listener = new PackageMapper(cl); 806 ClassLoaderUtils.updatePackageMap(url, listener); 807 } 808 catch (Exception e) 809 { 810 if (log.isTraceEnabled()) 811 log.trace("Failed to update pkgs for cl=" + cl, e); 812 else 813 log.debug("Failed to update pkgs for cl=" + cl, e); 814 } 815 } 816 817 820 public void removeClassLoader(ClassLoader loader) 821 { 822 ArrayList removeNotifications = new ArrayList (); 823 ClassLoader cl = loader; 824 synchronized (classLoaders) 825 { 826 if ((loader instanceof RepositoryClassLoader) == false) 827 { 828 cl = (ClassLoader ) nonUCLClassLoader.remove(loader); 829 } 830 if (cl instanceof RepositoryClassLoader) 831 { 832 RepositoryClassLoader ucl = (RepositoryClassLoader) cl; 833 if (getTranslator() != null) 834 getTranslator().unregisterClassLoader(ucl); 835 URL [] urls = ucl.getClasspath(); 836 for (int u = 0; u < urls.length; u++) 837 classLoaderURLs.remove(urls[u]); 838 } 839 boolean dynamic = dynamicClassLoaders.remove(cl); 840 boolean removed = classLoaders.remove(cl); 841 log.debug("UnifiedLoaderRepository removed(" + removed + ") " + cl); 842 843 HashSet loadedClasses = null; 845 boolean hasLoadedClasses = false; 846 synchronized (classes) 847 { 848 hasLoadedClasses = loaderToClassesMap.containsKey(cl); 849 if (hasLoadedClasses) 850 loadedClasses = (HashSet ) loaderToClassesMap.remove(cl); 851 if (loadedClasses != null) 853 { 854 for (Iterator iter = loadedClasses.iterator(); iter.hasNext();) 856 { 857 String className = (String ) iter.next(); 858 Notification n = new Notification (CLASS_REMOVED, this, 859 getNextSequenceNumber(), className); 860 removeNotifications.add(n); 861 } 862 863 for (Iterator i = loadedClasses.iterator(); i.hasNext();) 865 { 866 String cls = (String ) i.next(); 867 this.classes.remove(cls); 868 } 869 } 870 } 871 872 synchronized (loaderToResourcesMap) 874 { 875 if (loaderToResourcesMap.containsKey(cl)) 876 { 877 HashMap resources = (HashMap ) loaderToResourcesMap.remove(cl); 878 879 if (resources != null) 881 { 882 for (Iterator i = resources.keySet().iterator(); i.hasNext();) 883 { 884 String name = (String ) i.next(); 885 ResourceInfo ri = (ResourceInfo) globalResources.get(name); 886 if (ri != null && ri.cl == cl) 887 globalResources.remove(name); 888 } 889 } 890 } 891 } 892 893 if (dynamic == false) 895 { 896 List <String > pkgNames = loaderToPackagesMap.remove(cl); 897 if( pkgNames != null ) 898 { 899 for(String pkgName : pkgNames) 900 { 901 Set pkgSet = (Set ) packagesMap.get(pkgName); 902 if (pkgSet != null) 903 { 904 pkgSet.remove(cl); 905 if (pkgSet.isEmpty()) 906 packagesMap.remove(pkgName); 907 } 908 } 909 } 910 } 911 else 912 { 913 loaderToPackagesMap.remove(cl); 915 for (Iterator i = packagesMap.entrySet().iterator(); i.hasNext();) 916 { 917 Map.Entry entry = (Map.Entry ) i.next(); 918 Set pkgSet = (Set ) entry.getValue(); 919 pkgSet.remove(cl); 920 if (pkgSet.isEmpty()) 921 i.remove(); 922 } 923 } 924 } 925 926 for (int n = 0; n < removeNotifications.size(); n++) 928 { 929 Notification msg = (Notification ) removeNotifications.get(n); 930 broadcaster.sendNotification(msg); 931 } 932 933 Notification msg = new Notification (CLASSLOADER_REMOVED, this, getNextSequenceNumber()); 934 msg.setUserData(cl); 935 broadcaster.sendNotification(msg); 936 } 937 938 947 public LoaderRepository registerClassLoader(RepositoryClassLoader ucl) 948 { 949 addClassLoader(ucl); 950 Notification msg = new Notification (CLASSLOADER_ADDED, this, getNextSequenceNumber()); 951 msg.setUserData(ucl); 952 broadcaster.sendNotification(msg); 953 954 return this; 955 } 956 957 960 public LoaderRepository getInstance() 961 { 962 return this; 963 } 964 965 967 975 public void addNotificationListener(NotificationListener listener, 976 NotificationFilter filter, Object handback) throws IllegalArgumentException 977 { 978 broadcaster.addNotificationListener(listener, filter, handback); 979 } 980 981 985 public MBeanNotificationInfo [] getNotificationInfo() 986 { 987 if (info == null) 988 { 989 info = new MBeanNotificationInfo []{ 990 new MBeanNotificationInfo (new String []{"CLASSLOADER_ADDED"}, 991 "javax.management.Notification", 992 "Notification that a classloader has been added to the extensible classloader"), 993 new MBeanNotificationInfo (new String []{"CLASS_REMOVED"}, 994 "javax.management.Notification", 995 "Notification that a class has been removed from the extensible classloader") 996 997 }; 998 } 999 return info; 1000 } 1001 1002 1008 public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException 1009 { 1010 broadcaster.removeNotificationListener(listener); 1011 } 1012 1013 public ObjectName preRegister(MBeanServer server, ObjectName name) 1015 throws Exception 1016 { 1017 return name; 1018 } 1019 1020 public void postRegister(Boolean registrationDone) 1021 { 1022 } 1023 1024 public void preDeregister() 1025 throws Exception 1026 { 1027 } 1028 1029 public void postDeregister() 1030 { 1031 log.debug("postDeregister, clearing all references"); 1032 classLoaders.clear(); 1033 dynamicClassLoaders.clear(); 1034 nonUCLClassLoader.clear(); 1035 classLoaderURLs.clear(); 1036 classes.clear(); 1037 loaderToClassesMap.clear(); 1038 loaderToResourcesMap.clear(); 1039 globalResources.clear(); 1040 packagesMap.clear(); 1041 loaderToPackagesMap.clear(); 1042 } 1043 1044 private synchronized long getNextSequenceNumber() 1045 { 1046 return sequenceNumber++; 1047 } 1048 1049 1050 private RepositoryClassLoader getRepositoryClassLoader(ClassLoader cl, String name) throws ClassNotFoundException 1051 { 1052 if (cl instanceof RepositoryClassLoader) 1053 return (RepositoryClassLoader) cl; 1054 else 1055 { 1056 RepositoryClassLoader rcl = getWrappingClassLoader(cl); 1057 if (rcl == null) 1058 throw new ClassNotFoundException ("Class not found " + name + " (Unknown classloader " + cl + ")"); 1059 return rcl; 1060 } 1061 } 1062 1063 private class PackageMapper implements ClassLoaderUtils.PkgNameListener 1064 { 1065 private RepositoryClassLoader loader; 1066 PackageMapper(RepositoryClassLoader loader) 1067 { 1068 this.loader = loader; 1069 } 1070 public void addPackage(String pkgName) 1071 { 1072 if( pkgName.startsWith("META-INF") || pkgName.startsWith("WEB-INF") ) 1074 return; 1075 1076 Set <RepositoryClassLoader> pkgSet = (Set <RepositoryClassLoader>) packagesMap.get(pkgName); 1077 if( pkgSet == null ) 1078 { 1079 pkgSet = ClassLoaderUtils.newPackageSet(); 1080 packagesMap.put(pkgName, pkgSet); 1081 } 1082 if( pkgSet.contains(loader) == false ) 1083 { 1084 pkgSet.add((RepositoryClassLoader)loader); 1085 List <String > loaderPkgNames = loaderToPackagesMap.get(loader); 1086 if( loaderPkgNames == null ) 1087 { 1088 loaderPkgNames = new ArrayList <String >(); 1089 loaderToPackagesMap.put((RepositoryClassLoader)loader, loaderPkgNames); 1090 } 1091 loaderPkgNames.add(pkgName); 1092 1093 if( pkgSet.size() > 1 ) 1095 { 1096 log.debug("Multiple class loaders found for pkg: "+pkgName); 1097 } 1098 if( log.isTraceEnabled() ) 1099 log.trace("Indexed pkg: "+pkgName+", UCL: "+loader); 1100 } 1101 } 1102 } 1103} 1104 | Popular Tags |