Package eu.cloudnetservice.driver.module
Class ModuleURLClassLoader
java.lang.Object
java.lang.ClassLoader
java.security.SecureClassLoader
java.net.URLClassLoader
eu.cloudnetservice.driver.module.ModuleURLClassLoader
- All Implemented Interfaces:
InjectionLayerHolder<dev.derklaro.aerogel.SpecifiedInjector>,Closeable,AutoCloseable
@Internal
public class ModuleURLClassLoader
extends URLClassLoader
implements InjectionLayerHolder<dev.derklaro.aerogel.SpecifiedInjector>
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 InjectionLayer<dev.derklaro.aerogel.SpecifiedInjector>protected static final Set<ModuleURLClassLoader> -
Constructor Summary
ConstructorsConstructorDescriptionModuleURLClassLoader(@NonNull URL moduleFileUrl, @NonNull Set<URL> moduleDependencyUrls, @NonNull InjectionLayer<dev.derklaro.aerogel.SpecifiedInjector> injectionLayer) Creates an instance of this FinalizeURLClassLoader. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()@NonNull InjectionLayer<dev.derklaro.aerogel.SpecifiedInjector>Get the injection layer associated with this holder.Tries to load a class by the provided name.voidRegisters this loader to all loaders.Methods inherited from class java.net.URLClassLoader
addURL, 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, 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 InjectionLayer<dev.derklaro.aerogel.SpecifiedInjector> 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
Get the injection layer associated with this holder.- Specified by:
injectionLayerin interfaceInjectionLayerHolder<dev.derklaro.aerogel.SpecifiedInjector>- Returns:
- the injection layer of this holder.
-
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
-