public static TypeRegistry getTypeRegistryFor ( ClassLoader classloader ) { if ( classloader == null ) { return null ; } //WeakReference<TypeRegistry> existingRegistryRef = loaderToRegistryMap.get(classloader); TypeRegistry existingRegistry = loaderToRegistryMap . get ( classloader ) ; //existingRegistryRef==null?null:existingRegistryRef.get(); if ( existingRegistry != null ) { return existingRegistry ; } if ( GlobalConfiguration . isRuntimeLogging && log . isLoggable ( Level . INFO ) ) { if ( excludedLoaderInstances . contains ( classloader . toString ( ) ) ) { return null ; } } String classloaderName = classloader . getClass ( ) . getName ( ) ; if ( classloaderName . equals ( "sun.reflect.DelegatingClassLoader" ) ) { return null ; } for ( String excluded : excludedLoaders ) { if ( classloaderName . startsWith ( excluded ) ) { if ( GlobalConfiguration . isRuntimeLogging && log . isLoggable ( Level . FINEST ) ) { log . info ( "Classloader " + classloaderName + " has been deliberately excluded" ) ; } excludedLoaderInstances . add ( classloader . toString ( ) ) ; return null ; } } // if (GlobalConfiguration.limit) { // // only allow for certain loaders! // boolean isOK = false; // if (classloaderName.equals("org.apache.catalina.loader.StandardClassLoader")) { // isOK = true; // } else if (classloaderName.equals("com.springsource.insight.collection.tcserver.ltw.TomcatWeavingInsightClassLoader")) { // isOK = true; // } else if (classloaderName.equals("org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader")) { // isOK = true; // } else if (classloaderName.equals("org.apache.catalina.loader.WebappClassLoader")) { // isOK = true; // } // if (!isOK) { // return null; // } // } try { Class . forName ( "org.springsource.loaded.ri.ReflectiveInterceptor" , false , classloader ) ; } catch ( ClassNotFoundException ex ) { if ( GlobalConfiguration . isRuntimeLogging && log . isLoggable ( Level . INFO ) ) { log . info ( "No TypeRegistry (can't load ReflectiveInterceptor) for loader " + classloader ) ; } return null ; } if ( GlobalConfiguration . isRuntimeLogging && log . isLoggable ( Level . INFO ) ) { log . info ( "TypeRegistry.getRegistryFor(): creating new TypeRegistry for loader " + classloader ) ; } TypeRegistry tr = new TypeRegistry ( classloader ) ; // if (GlobalConfiguration.isRuntimeLogging) { // Utils.log(100, "TypeRegistry.getTypeRegistryFor(classloader=" + classloader + ") returning " + tr); // } return tr ; }
Factory access method for obtaining TypeRegistry instances . Returns a TypeRegistry for the specified classloader .