Class PluginManager
Plugin
s.- Since:
- 2.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Allow loading plugins that are not contained within a single file but within a directory.static final int
Try to load any files, not only files ending with.jar
.static final int
Exit the method when an error occurs while loading a plugin, rethrowing the caught exception.static final int
Search for additional plugins in subdirectories. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioniterator()
int
loadFromDirectory
(String path, int flags) Loads plugins from the given directory.int
loadFromDirectory
(Path path, int flags) Searches for plugins in the given directory and loads them usingloadPlugin(Path)
.int
loadFromJar
(Path jarFilePath, String innerPath, int flags) Searches for plugins in the JAR file at the given path, by attempting to load any nested JAR files, whose relative path in the given JAR file start with innerPath.int
loadFromPath
(String path, int flags) Searches for plugins at the given path.void
loadPlugin
(Path path) Loads and initializes the plugin at path and registers it with thisPluginManager
instance.int
Returns the number of plugins registered in thisPluginManager
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
EXIT_ON_ERROR
public static final int EXIT_ON_ERRORExit the method when an error occurs while loading a plugin, rethrowing the caught exception.- See Also:
-
ALLOW_NONJAR
public static final int ALLOW_NONJARTry to load any files, not only files ending with.jar
.- See Also:
-
RECURSIVE
public static final int RECURSIVESearch for additional plugins in subdirectories.- See Also:
-
ALLOW_DIRS
public static final int ALLOW_DIRSAllow loading plugins that are not contained within a single file but within a directory. This flag is not affected byALLOW_NONJAR
.- See Also:
-
-
Constructor Details
-
PluginManager
public PluginManager()
-
-
Method Details
-
loadFromDirectory
Loads plugins from the given directory. SeeloadFromDirectory(Path, int)
.- Parameters:
path
- The directory to load plugins fromflags
- Bit field of flags- Returns:
- The number of plugins loaded
- Throws:
IOException
- If an IO error occurs
-
loadFromDirectory
Searches for plugins in the given directory and loads them usingloadPlugin(Path)
.The search behavior may be configured using the flags parameter. This parameter is a bit field of
EXIT_ON_ERROR
,ALLOW_NONJAR
,RECURSIVE
andALLOW_DIRS
.RECURSIVE
andALLOW_DIRS
are mutually exclusive. If both are specified, the function behaves as if onlyRECURSIVE
were set.- Parameters:
path
- The directory to load plugins fromflags
- Bit field of flags- Returns:
- The number of plugins loaded
- Throws:
IOException
- If an IO error occurs
-
loadFromJar
Searches for plugins in the JAR file at the given path, by attempting to load any nested JAR files, whose relative path in the given JAR file start with innerPath.The search behavior may be configured using the flags parameter. This parameter is a bit field of
EXIT_ON_ERROR
andALLOW_NONJAR
.- Parameters:
jarFilePath
- The path of the wrapping JAR fileinnerPath
- The relative path prefix in the JAR fileflags
- Bit field of flags- Returns:
- The number of plugins loaded
- Throws:
IOException
- If an IO error occurs- Since:
- 2.8
-
loadFromPath
Searches for plugins at the given path.If the given path contains the separator
!/
, the path is assumed to point inside a JAR file, with the format<path to JAR file>!/<directory inside JAR file>
, andloadFromJar(Path, String, int)
is called. Otherwise, the path is passed unchanged toloadFromDirectory(String, int)
.- Parameters:
path
- The pathflags
- Bit field of flags- Returns:
- The number of plugins loaded
- Throws:
IOException
- If an IO error occurs- Since:
- 2.8
-
loadPlugin
Loads and initializes the plugin at path and registers it with thisPluginManager
instance.If the given path is a directory, the plugin is loaded as a directory plugin, otherwise, it is loaded as a JAR plugin.
- Parameters:
path
- The path of the plugin- Throws:
IOException
- If an IO error occurs
-
pluginCount
public int pluginCount()Returns the number of plugins registered in thisPluginManager
.- Returns:
- The number of plugins
-
iterator
-