private ClassLoader getClassLoaderForInterfaces ( final ClassLoader loader , final Class < ? > [ ] interfaces ) { if ( canSeeAllInterfaces ( loader , interfaces ) ) { LOG . log ( Level . FINE , "current classloader " + loader + " can see all interface" ) ; return loader ; } String sortedNameFromInterfaceArray = getSortedNameFromInterfaceArray ( interfaces ) ; ClassLoader cachedLoader = proxyClassLoaderCache . getProxyClassLoader ( loader , interfaces ) ; if ( canSeeAllInterfaces ( cachedLoader , interfaces ) ) { LOG . log ( Level . FINE , "find required loader from ProxyClassLoader cache with key" + sortedNameFromInterfaceArray ) ; return cachedLoader ; } else { LOG . log ( Level . FINE , "find a loader from ProxyClassLoader cache with interfaces " + sortedNameFromInterfaceArray + " but can't see all interfaces" ) ; for ( Class < ? > currentInterface : interfaces ) { String ifName = currentInterface . getName ( ) ; if ( ! ifName . startsWith ( "org.apache.cxf" ) && ! ifName . startsWith ( "java" ) ) { // remove the stale ProxyClassLoader and recreate one proxyClassLoaderCache . removeStaleProxyClassLoader ( currentInterface ) ; cachedLoader = proxyClassLoaderCache . getProxyClassLoader ( loader , interfaces ) ; } } } return cachedLoader ; }
Return a classloader that can see all the given interfaces If the given loader can see all interfaces then it is used . If not then a combined classloader of all interface classloaders is returned .