java.lang.Object
net.foxgenesis.watame.plugin.UntrustedPluginLoader<T>
- All Implemented Interfaces:
AutoCloseable
-
Constructor Summary
ConstructorsConstructorDescriptionUntrustedPluginLoader(Class<T> pluginClass) UntrustedPluginLoader(Class<T> pluginClass, File folder) Create a newUntrustedPluginLoaderinstance and set the directory to use.UntrustedPluginLoader(Class<T> pluginClass, File folder, boolean mkdirs) Create a newUntrustedPluginLoaderinstance and set the directory to use. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Get the class ofUntrustedPluginLoader.Get the plugin folder currently selected.Get all plugins of typeUntrustedPluginLoaderin the selected folder.getPlugins(Function<ServiceLoader.Provider<T>, T> providerMap) Get all plugins of typeUntrustedPluginLoaderin the selected folder.voidsetPluginDirectory(File folder, boolean mkdirs) Set the plugin folder to use during class search.
-
Constructor Details
-
UntrustedPluginLoader
-
UntrustedPluginLoader
Create a newUntrustedPluginLoaderinstance and set the directory to use.This constructor is effectively equivalent to:
new PluginLoader(folder, false)
- Parameters:
folder- - TheFileto search for plugins in.
-
UntrustedPluginLoader
Create a newUntrustedPluginLoaderinstance and set the directory to use.- Parameters:
folder- - TheFileto search for plugins in.mkdirs- - Iffolderdoes not exist, should a new one be made
-
-
Method Details
-
getPlugins
Get all plugins of typeUntrustedPluginLoaderin the selected folder.This method is effectively equivalent to:
getPlugins(Provider::get)
- Returns:
- A
CollectionofUntrustedPluginLoader - Throws:
ServiceConfigurationError- if the service type is not accessible to the caller or the caller is in an explicit module and its module descriptor does not declare that it uses service- See Also:
-
getPlugins
Get all plugins of typeUntrustedPluginLoaderin the selected folder.- Parameters:
providerMap- -Functionto map aServiceLoader.ProvidertoUntrustedPluginLoader- Returns:
- A
CollectionofUntrustedPluginLoader - Throws:
ServiceConfigurationError- if the service type is not accessible to the caller or the caller is in an explicit module and its module descriptor does not declare that it uses service- See Also:
-
setPluginDirectory
Set the plugin folder to use during class search.- Parameters:
folder- - TheFileto search inmkdirs- - Iffolderdoes not exist, should a new directory be made- Throws:
NullPointerException- Thrown iffolderisnull.IllegalArgumentException- Thrown whenfolderdoes not exist andmkdirsisfalseor,folderis not a file directory.
-
getPluginDirectory
Get the plugin folder currently selected.- Returns:
- Returns the
Fileselected as the plugin directory
-
getPluginClass
Get the class ofUntrustedPluginLoader.- Returns:
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-