Class OwnResFirstClassLoader
java.lang.Object
java.lang.ClassLoader
java.security.SecureClassLoader
java.net.URLClassLoader
de.aristaflow.adept2.base.registry.OwnResFirstClassLoader
- All Implemented Interfaces:
Closeable,AutoCloseable
An
URLClassLoader that tries to retrieve resources within the
own classpaths first before asking the parent classloader. Therefore the own
resources are preferred to the ones of the parent classloader.- Author:
- Ulrich Kreher
-
Constructor Summary
ConstructorsConstructorDescriptionOwnResFirstClassLoader(URL[] urls, ClassLoader parent) Constructs a new classloader for the designated URLs. -
Method Summary
Modifier and TypeMethodDescriptiongetResource(String name) Finds the designated resourcewithin the URLs of this classloader first.Methods inherited from class java.net.URLClassLoader
addURL, close, definePackage, findClass, findResource, findResources, getPermissions, getResourceAsStream, getURLs, newInstance, newInstanceMethods inherited from class java.security.SecureClassLoader
defineClass, defineClassMethods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
Constructor Details
-
OwnResFirstClassLoader
Constructs a new classloader for the designated URLs. This is similar to anURLClassLoaderexcept that resources are tried to retrieve from these URLs before delegating to the designated parent classloader.- Parameters:
urls- The URLs from which to load classes and resources.parent- The parent class loader for delegation.- See Also:
-
-
Method Details
-
getResource
Finds the designated resourcewithin the URLs of this classloader first. If it is not found, the normal behaviour (with parent delegation) will apply.- Overrides:
getResourcein classClassLoader
-