Package org.pf4j

Class DependencyResolver


  • public class DependencyResolver
    extends java.lang.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 Detail

      • log

        private static final org.slf4j.Logger log
      • dependenciesGraph

        private DirectedGraph<java.lang.String> dependenciesGraph
      • dependentsGraph

        private DirectedGraph<java.lang.String> dependentsGraph
      • resolved

        private boolean resolved
    • Constructor Detail

      • DependencyResolver

        public DependencyResolver​(VersionManager versionManager)
    • Method Detail

      • getDependencies

        public java.util.List<java.lang.String> getDependencies​(java.lang.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 java.util.List<java.lang.String> getDependents​(java.lang.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​(java.lang.String requiredVersion,
                                                 java.lang.String existingVersion)
        Check if an existing version of dependency is compatible with the required version (from plugin descriptor).
        Parameters:
        requiredVersion -
        existingVersion -
        Returns:
      • checkResolved

        private void checkResolved()
      • getDependencyVersionSupport

        private java.lang.String getDependencyVersionSupport​(PluginDescriptor dependent,
                                                             java.lang.String dependencyId)