Class ModuleURLClassLoader
java.lang.Object
java.lang.ClassLoader
java.security.SecureClassLoader
java.net.URLClassLoader
eu.cloudnetservice.driver.impl.module.ModuleURLClassLoader
- All Implemented Interfaces:
eu.cloudnetservice.driver.inject.InjectionLayerHolder<Injector>, Closeable, AutoCloseable
public class ModuleURLClassLoader
extends URLClassLoader
implements eu.cloudnetservice.driver.inject.InjectionLayerHolder<Injector>
This module url class loader is a unique url class loader for each module. Loading a class using this ClassLoader
ensures that all other modules have access to the loaded class too.
- Since:
- 4.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final LockAll loaders which were created and of which the associated module is still loaded.protected final eu.cloudnetservice.driver.inject.InjectionLayer<Injector> protected static final Set<ModuleURLClassLoader> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Tries to load a class by the provided name.voidRegisters this loader to all loaders.Methods inherited from class URLClassLoader
addURL, definePackage, findClass, findResource, findResources, getPermissions, getResourceAsStream, getURLs, newInstance, newInstanceMethods inherited from class SecureClassLoader
defineClass, defineClassMethods inherited from class ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
Field Details
-
CLASS_LOADING_LOCK
All loaders which were created and of which the associated module is still loaded. -
LOADERS
-
injectionLayer
-
-
Constructor Details
-
ModuleURLClassLoader
public ModuleURLClassLoader(@NonNull @NonNull URL moduleFileUrl, @NonNull @NonNull Set<URL> moduleDependencyUrls, @NonNull @NonNull eu.cloudnetservice.driver.inject.InjectionLayer<Injector> injectionLayer) Creates an instance of this FinalizeURLClassLoader.- Parameters:
moduleFileUrl- the module file to which this loader is associated.moduleDependencyUrls- all dependencies which were loaded for the module.injectionLayer- the injection layer for the module associated with this loader.- Throws:
NullPointerException- if moduleFileUrl or moduleDependencyUrls is null.
-
-
Method Details
-
registerGlobally
public void registerGlobally()Registers this loader to all loaders. This causes all other instances of this class to search for classes in this loader too. -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classURLClassLoader- Throws:
IOException
-
loadClass
@NonNull protected @NonNull Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException - Overrides:
loadClassin classClassLoader- Throws:
ClassNotFoundException
-
injectionLayer
-
loadClass
@NonNull protected @NonNull Class<?> loadClass(String name, boolean resolve, boolean global) throws ClassNotFoundException Tries to load a class by the provided name.- Parameters:
name- the name of the class to load.resolve- if the class should be resolved.global- if all loaders registered inLOADERSshould be checked.- Returns:
- The resulting Class object
- Throws:
ClassNotFoundException- if the class could not be found
-