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
public class OwnResFirstClassLoader extends URLClassLoader
AnURLClassLoaderthat 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
Constructors Constructor Description OwnResFirstClassLoader(URL[] urls, ClassLoader parent)Constructs a new classloader for the designated URLs.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description URLgetResource(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, newInstance
-
Methods inherited from class java.security.SecureClassLoader
defineClass, defineClass
-
Methods 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 Detail
-
OwnResFirstClassLoader
public OwnResFirstClassLoader(URL[] urls, ClassLoader parent)
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:
SecurityManager.checkCreateClassLoader()
-
-
Method Detail
-
getResource
public URL getResource(String name)
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
-
-