Class ModuleSorter

java.lang.Object
org.tentackle.common.ModuleSorter

public final class ModuleSorter extends Object
A dependency sorter for jigsaw modules.
Author:
harald
  • Field Details

    • INSTANCE

      public static final ModuleSorter INSTANCE
      The singleton.
  • Constructor Details

    • ModuleSorter

      public ModuleSorter()
      Creates a module sorter and loads the module hierarchy.

      Finds all named modules providing a ModuleHook via module-info and sorts them according to their dependencies.

  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getModuleInfos

      public List<ModuleInfo> getModuleInfos()
      Gets the modules infos ordered by dependency.
      Modules at the top of the dependency hierarchy come last, modules without further dependencies come first.
      Returns:
      the module infos
    • getModuleInfo

      public ModuleInfo getModuleInfo(String name)
      Gets the module info for a module name.
      Parameters:
      name - the module name
      Returns:
      the module info, null if no such (application) module or module has no ModuleHook.
    • getModuleInfo

      public ModuleInfo getModuleInfo(URL url)
      Gets the module info for a given URL.
      Parameters:
      url - the resource url
      Returns:
      the module info, null if application not modularized, not from a module or module does not provide a ModuleHook.
    • sort

      public Collection<URL> sort(Enumeration<URL> urls, String serviceName)
      Sorts an enumeration of urls according to the module hierarchy.
      The highest module ordinal comes first.
      Parameters:
      urls - the urls, usually from ClassLoader.getResources
      serviceName - the service name
      Returns:
      the sorted urls