Class PluginManager
Plugins.- Since:
- 2.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intAllow loading plugins that are not contained within a single file but within a directory.static final intTry to load any files, not only files ending with.jar.static final intExit the method when an error occurs while loading a plugin, rethrowing the caught exception.static final intSearch for additional plugins in subdirectories. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioniterator()intloadFromDirectory(String path, int flags) Loads plugins from the given directory.intloadFromDirectory(Path path, int flags) Searches for plugins in the given directory and loads them usingloadPlugin(Path).intloadFromJar(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.intloadFromPath(String path, int flags) Searches for plugins at the given path.voidloadPlugin(Path path) Loads and initializes the plugin at path and registers it with thisPluginManagerinstance.intReturns the number of plugins registered in thisPluginManager.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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,RECURSIVEandALLOW_DIRS.RECURSIVEandALLOW_DIRSare mutually exclusive. If both are specified, the function behaves as if onlyRECURSIVEwere 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_ERRORandALLOW_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 thisPluginManagerinstance.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
-