Package org.pf4j
Class DependencyResolver
java.lang.Object
org.pf4j.DependencyResolver
This class builds a dependency graph for a list of plugins (descriptors).
The entry point is the
resolve(List)
method, method that returns a DependencyResolver.Result
object.
The Result
class contains nice information about the result of resolve operation (if it's a cyclic dependency,
they are not found dependencies, they are dependencies with wrong version).
This class is very useful for if-else scenarios.
Only some attributes (pluginId, dependencies and pluginVersion) from PluginDescriptor
are used in
the process of resolve
operation.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
It will be thrown if a cyclic dependency is detected.static class
Indicates that the dependencies required were not found.static class
Indicates that some dependencies have wrong version.static class
static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate DirectedGraph
<String> private DirectedGraph
<String> private static final org.slf4j.Logger
private boolean
private VersionManager
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addPlugin
(PluginDescriptor descriptor) protected boolean
checkDependencyVersion
(String requiredVersion, String existingVersion) Check if an existing version of dependency is compatible with the required version (from plugin descriptor).private void
getDependencies
(String pluginId) Retrieves the plugins ids that the given plugin id directly depends on.private String
getDependencyVersionSupport
(PluginDescriptor dependent, String dependencyId) getDependents
(String pluginId) Retrieves the plugins ids that the given content is a direct dependency of.resolve
(List<PluginDescriptor> plugins)
-
Field Details
-
log
private static final org.slf4j.Logger log -
versionManager
-
dependenciesGraph
-
dependentsGraph
-
resolved
private boolean resolved
-
-
Constructor Details
-
DependencyResolver
-
-
Method Details
-
resolve
-
getDependencies
Retrieves the plugins ids that the given plugin id directly depends on.- Parameters:
pluginId
- the unique plugin identifier, specified in its metadata- Returns:
-
getDependents
Retrieves the plugins ids that the given content is a direct dependency of.- Parameters:
pluginId
- the unique plugin identifier, specified in its metadata- Returns:
-
checkDependencyVersion
Check if an existing version of dependency is compatible with the required version (from plugin descriptor).- Parameters:
requiredVersion
-existingVersion
-- Returns:
-
addPlugin
-
checkResolved
private void checkResolved() -
getDependencyVersionSupport
-