Package org.pf4j

Class DependencyResolver

java.lang.Object
org.pf4j.DependencyResolver

public class DependencyResolver extends Object
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.
  • Field Details

    • log

      private static final org.slf4j.Logger log
    • versionManager

      private VersionManager versionManager
    • dependenciesGraph

      private DirectedGraph<String> dependenciesGraph
    • dependentsGraph

      private DirectedGraph<String> dependentsGraph
    • resolved

      private boolean resolved
  • Constructor Details

    • DependencyResolver

      public DependencyResolver(VersionManager versionManager)
  • Method Details

    • resolve

      public DependencyResolver.Result resolve(List<PluginDescriptor> plugins)
    • getDependencies

      public List<String> getDependencies(String pluginId)
      Retrieves the plugins ids that the given plugin id directly depends on.
      Parameters:
      pluginId - the unique plugin identifier, specified in its metadata
      Returns:
    • getDependents

      public List<String> getDependents(String pluginId)
      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

      protected boolean checkDependencyVersion(String requiredVersion, String existingVersion)
      Check if an existing version of dependency is compatible with the required version (from plugin descriptor).
      Parameters:
      requiredVersion -
      existingVersion -
      Returns:
    • addPlugin

      private void addPlugin(PluginDescriptor descriptor)
    • checkResolved

      private void checkResolved()
    • getDependencyVersionSupport

      private String getDependencyVersionSupport(PluginDescriptor dependent, String dependencyId)