Class LocalModuleFinder

java.lang.Object
org.jboss.modules.LocalModuleFinder
All Implemented Interfaces:
AutoCloseable, IterableModuleFinder, ModuleFinder

public final class LocalModuleFinder extends Object implements IterableModuleFinder, AutoCloseable
A module finder which locates module specifications which are stored in a local module repository on the filesystem, which uses module.xml descriptors.
Author:
David M. Lloyd, Richard Opalka
  • Constructor Details

    • LocalModuleFinder

      public LocalModuleFinder(File[] repoRoots, PathFilter pathFilter)
      Construct a new instance.
      Parameters:
      repoRoots - the repository roots to use
      pathFilter - the path filter to use
    • LocalModuleFinder

      public LocalModuleFinder(File[] repoRoots)
      Construct a new instance.
      Parameters:
      repoRoots - the repository roots to use
    • LocalModuleFinder

      public LocalModuleFinder()
      Construct a new instance, using the module.path system property or the JAVA_MODULEPATH environment variable to get the list of module repository roots.

      This is equivalent to a call to LocalModuleFinder(true).

    • LocalModuleFinder

      public LocalModuleFinder(boolean supportLayersAndAddOns)
      Construct a new instance, using the module.path system property or the JAVA_MODULEPATH environment variable to get the list of module repository roots.
      Parameters:
      supportLayersAndAddOns - true if the identified module repository roots should be checked for an internal structure of child "layer" and "add-on" directories that may also be treated as module roots lower in precedence than the parent root. Any "layers" subdirectories whose names are specified in a layers.conf file found in the module repository root will be added in the precedence of order specified in the layers.conf file; all "add-on" subdirectories will be added at a lower precedence than all "layers" and with no guaranteed precedence order between them. If false no check for "layer" and "add-on" directories will be performed.
  • Method Details

    • findModule

      public ModuleSpec findModule(String name, ModuleLoader delegateLoader) throws ModuleLoadException
      Description copied from interface: ModuleFinder
      Find a module specification for the given name.
      Specified by:
      findModule in interface ModuleFinder
      Parameters:
      name - the module name
      delegateLoader - the module loader from which dependencies should be resolved
      Returns:
      the module specification, or null if no specification is found for this identifier
      Throws:
      ModuleLoadException
    • parseModuleXmlFile

      public static ModuleSpec parseModuleXmlFile(String name, ModuleLoader delegateLoader, File... roots) throws IOException, ModuleLoadException
      Parse a module.xml file and return the corresponding module specification.
      Parameters:
      name - the name of the module to load
      delegateLoader - the delegate module loader to use for module specifications
      roots - the repository root paths to search
      Returns:
      the module specification
      Throws:
      IOException - if reading the module file failed
      ModuleLoadException - if creating the module specification failed (e.g. due to a parse error)
    • iterateModules

      public Iterator<String> iterateModules(String baseName, boolean recursive, ModuleLoader delegateLoader)
      Description copied from interface: IterableModuleFinder
      Iterate the modules which can be located via this module finder.
      Specified by:
      iterateModules in interface IterableModuleFinder
      Parameters:
      baseName - the identifier to start with, or null to iterate all modules; ignored if this module loader does not have a concept of nested modules
      recursive - true to find recursively nested modules, false to only find immediately nested modules; ignored if this module finder does not have a concept of nested modules
      delegateLoader - the delegate loader to query for dependency resolution
      Returns:
      an iterator for the modules in this module finder
    • toString

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

      public void close()
      Close this module loader and release all backing files. Note that subsequent load attempts will fail with an error after this method is called.
      Specified by:
      close in interface AutoCloseable