Package org.rapidcontext.app.plugin
Class PluginManager
java.lang.Object
org.rapidcontext.app.plugin.PluginManager
A plug-in manager. This singleton class contains the utility
functions for managing the plug-in loading and unloading.
- Version:
- 1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Simple extension of URLClassLoader to be able to add new URL:s after creation. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPluginManager
(File builtinDir, File pluginDir, AppStorage storage) Creates a new plug-in storage. -
Method Summary
Modifier and TypeMethodDescriptionInstalls a plug-in from the specified file.boolean
isAvailable
(String pluginId) Checks if the specified plug-in is currently available, i.e.boolean
Checks if the specified plug-in is built-in (or installed).void
Loads a plug-in.void
Uninstalls and removes a plug-in file.void
Unloads a plug-in.void
Unloads all plug-ins.
-
Field Details
-
SYSTEM_PLUGIN
The identifier of the system plug-in.- See Also:
-
LOCAL_PLUGIN
The identifier of the local plug-in.- See Also:
-
builtinDir
The built-in plug-in directory. This is the base directory from which built-in plug-ins are loaded. -
pluginDir
The plug-in directory. This is the base directory from which plug-ins are loaded. -
storage
The storage to use when loading and unloading plug-ins. -
classLoader
The plug-in class loader.
-
-
Constructor Details
-
PluginManager
Creates a new plug-in storage.- Parameters:
builtinDir
- the built-in plug-in directorypluginDir
- the base plug-in directorystorage
- the storage to use for plug-ins
-
-
Method Details
-
isAvailable
Checks if the specified plug-in is currently available, i.e. if it has been mounted to the plug-in storage.- Parameters:
pluginId
- the unique plug-in id- Returns:
- true if the plug-in was available, or false otherwise
-
isBuiltIn
Checks if the specified plug-in is built-in (or installed). Note any plug-ins located in the built-in plug-in directory will be considered built-in.- Parameters:
pluginId
- the unique plug-in id- Returns:
- true if the plug-in exists and is built-in, or false otherwise
-
install
Installs a plug-in from the specified file. If an existing plug-in with the same id already exists, it will be replaced without warning. Note that the new plug-in will NOT be loaded.- Parameters:
file
- the plug-in ZIP file- Returns:
- the unique plug-in id
- Throws:
PluginException
- if the plug-in couldn't be installed correctly
-
uninstall
Uninstalls and removes a plug-in file. If the plug-in is loaded or mounted, it will first be unloaded and the associated storage will be destroyed.- Parameters:
pluginId
- the unique plug-in id- Throws:
PluginException
- if the plug-in removal failed
-
load
Loads a plug-in. The plug-in file storage will be added to the root overlay and the plug-in configuration file will be used to initialize the plug-in Java class.- Parameters:
pluginId
- the unique plug-in id- Throws:
PluginException
- if the plug-in loading failed
-
unload
Unloads a plug-in. All plug-in classes will be destroyed and the plug-in file storage will be hidden from the root overlay.- Parameters:
pluginId
- the unique plug-in id- Throws:
PluginException
- if the plug-in unloading failed
-
unloadAll
public void unloadAll()Unloads all plug-ins. All plug-in classes will be destroyed and the plug-in file storages will be hidden from the root overlay. Note that the built-in plug-ins will be unaffected by this.
-