/** * Check whether this CachedIntrospectionResults class is configured * to accept the given ClassLoader. * @param classLoader the ClassLoader to check * @return whether the given ClassLoader is accepted * @see #acceptClassLoader */ private static boolean isClassLoaderAccepted(ClassLoader classLoader) { for (ClassLoader acceptedLoader : acceptedClassLoaders) { if (isUnderneathClassLoader(classLoader, acceptedLoader)) { return true; } } return false; }
/** * Check whether this CachedIntrospectionResults class is configured * to accept the given ClassLoader. * @param classLoader the ClassLoader to check * @return whether the given ClassLoader is accepted * @see #acceptClassLoader */ private static boolean isClassLoaderAccepted(ClassLoader classLoader) { for (ClassLoader acceptedLoader : acceptedClassLoaders) { if (isUnderneathClassLoader(classLoader, acceptedLoader)) { return true; } } return false; }
/** * Clear the introspection cache for the given ClassLoader, removing the * introspection results for all classes underneath that ClassLoader, and * removing the ClassLoader (and its children) from the acceptance list. * @param classLoader the ClassLoader to clear the cache for */ public static void clearClassLoader(@Nullable ClassLoader classLoader) { acceptedClassLoaders.removeIf(registeredLoader -> isUnderneathClassLoader(registeredLoader, classLoader)); strongClassCache.keySet().removeIf(beanClass -> isUnderneathClassLoader(beanClass.getClassLoader(), classLoader)); softClassCache.keySet().removeIf(beanClass -> isUnderneathClassLoader(beanClass.getClassLoader(), classLoader)); }
/** * Clear the introspection cache for the given ClassLoader, removing the * introspection results for all classes underneath that ClassLoader, and * removing the ClassLoader (and its children) from the acceptance list. * @param classLoader the ClassLoader to clear the cache for */ public static void clearClassLoader(@Nullable ClassLoader classLoader) { acceptedClassLoaders.removeIf(registeredLoader -> isUnderneathClassLoader(registeredLoader, classLoader)); strongClassCache.keySet().removeIf(beanClass -> isUnderneathClassLoader(beanClass.getClassLoader(), classLoader)); softClassCache.keySet().removeIf(beanClass -> isUnderneathClassLoader(beanClass.getClassLoader(), classLoader)); }
/** * Check whether this CachedIntrospectionResults class is configured * to accept the given ClassLoader. * @param classLoader the ClassLoader to check * @return whether the given ClassLoader is accepted * @see #acceptClassLoader */ private static boolean isClassLoaderAccepted(ClassLoader classLoader) { // Iterate over array copy in order to avoid synchronization for the entire // ClassLoader check (avoiding a synchronized acceptedClassLoaders Iterator). ClassLoader[] acceptedLoaderArray = acceptedClassLoaders.toArray(new ClassLoader[acceptedClassLoaders.size()]); for (ClassLoader registeredLoader : acceptedLoaderArray) { if (isUnderneathClassLoader(classLoader, registeredLoader)) { return true; } } return false; }
/** * Clear the introspection cache for the given ClassLoader, removing the * introspection results for all classes underneath that ClassLoader, * and deregistering the ClassLoader (and any of its children) from the * acceptance list. * @param classLoader the ClassLoader to clear the cache for */ public static void clearClassLoader(ClassLoader classLoader) { if (classLoader == null) { return; } synchronized (classCache) { for (Iterator<Class> it = classCache.keySet().iterator(); it.hasNext();) { Class beanClass = it.next(); if (isUnderneathClassLoader(beanClass.getClassLoader(), classLoader)) { it.remove(); } } } synchronized (acceptedClassLoaders) { for (Iterator<ClassLoader> it = acceptedClassLoaders.iterator(); it.hasNext();) { ClassLoader registeredLoader = it.next(); if (isUnderneathClassLoader(registeredLoader, classLoader)) { it.remove(); } } } }
/** * Clear the introspection cache for the given ClassLoader, removing the * introspection results for all classes underneath that ClassLoader, and * removing the ClassLoader (and its children) from the acceptance list. * @param classLoader the ClassLoader to clear the cache for */ public static void clearClassLoader(ClassLoader classLoader) { for (Iterator<ClassLoader> it = acceptedClassLoaders.iterator(); it.hasNext();) { ClassLoader registeredLoader = it.next(); if (isUnderneathClassLoader(registeredLoader, classLoader)) { it.remove(); } } for (Iterator<Class<?>> it = strongClassCache.keySet().iterator(); it.hasNext();) { Class<?> beanClass = it.next(); if (isUnderneathClassLoader(beanClass.getClassLoader(), classLoader)) { it.remove(); } } for (Iterator<Class<?>> it = softClassCache.keySet().iterator(); it.hasNext();) { Class<?> beanClass = it.next(); if (isUnderneathClassLoader(beanClass.getClassLoader(), classLoader)) { it.remove(); } } }