Interface ConfiguredPluginClassLoader
- All Superinterfaces:
AutoCloseable
,Closeable
- All Known Implementing Classes:
PluginClassLoader
The configured plugin class loader represents an internal abstraction over the classloaders used by the server
to load and access a plugins classes during runtime.
It implements Closeable
to define the ability to shutdown and close the classloader that implements this
interface.
-
Method Summary
Modifier and TypeMethodDescriptionProvides the configuration of the plugin that this plugin classloader provides type access to.getGroup()
Get the plugin classloader group that is used by the underlying classloaderGets the plugin held by this class loader.void
init
(JavaPlugin plugin) Initializes both this configured plugin class loader and the java plugin passed to link to each other.Class
<?> Attempts to load a class from this plugin class loader using the passed fully qualified name.
-
Method Details
-
getConfiguration
PluginMeta getConfiguration()Provides the configuration of the plugin that this plugin classloader provides type access to.- Returns:
- the plugin meta instance, holding all meta information about the plugin instance.
-
loadClass
Class<?> loadClass(String name, boolean resolve, boolean checkGlobal, boolean checkLibraries) throws ClassNotFoundException Attempts to load a class from this plugin class loader using the passed fully qualified name. This lookup logic can be configured through the following parameters to define how wide or how narrow the class lookup should be.- Parameters:
name
- the fully qualified name of the class to loadresolve
- whether the class should be resolved if needed or notcheckGlobal
- whether this lookup should check transitive dependencies, including either the legacy spigot global class loader or the paperPluginClassLoaderGroup
checkLibraries
- whether the defined libraries should be checked for the class or not- Returns:
- the class found at the fully qualified class name passed under the passed restrictions
- Throws:
ClassNotFoundException
- if the class could not be found considering the passed restrictions- See Also:
-
init
Initializes both this configured plugin class loader and the java plugin passed to link to each other. This logic is to be called exactly once when the initial setup between the class loader and the instantiatedJavaPlugin
is loaded.- Parameters:
plugin
- theJavaPlugin
that should be interlinked with this class loader.
-
getPlugin
@Nullable JavaPlugin getPlugin()Gets the plugin held by this class loader.- Returns:
- the plugin or null if it doesn't exist yet
-
getGroup
@Nullable PluginClassLoaderGroup getGroup()Get the plugin classloader group that is used by the underlying classloader- Returns:
- classloader
-