Class LocalRepoLoaderImpl

  • All Implemented Interfaces:
    LocalRepoLoader

    public final class LocalRepoLoaderImpl
    extends java.lang.Object
    implements LocalRepoLoader
    A utility class that finds LocalPackages under a given path based on package.xml files.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String PACKAGE_XML_FN
      The name of the package metadata file we can read.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Map<java.lang.String,​LocalPackage> getPackages​(ProgressIndicator progress)
      Gets our packages, loading them if necessary.
      boolean needsUpdate​(long lastLocalRefreshMs, boolean deepCheck)
      Checks whether it looks like we need to be reloaded.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • PACKAGE_XML_FN

        public static final java.lang.String PACKAGE_XML_FN
        The name of the package metadata file we can read.
        See Also:
        Constant Field Values
    • Constructor Detail

      • LocalRepoLoaderImpl

        public LocalRepoLoaderImpl​(@NonNull
                                   java.nio.file.Path root,
                                   @NonNull
                                   RepoManager manager,
                                   @Nullable
                                   FallbackLocalRepoLoader fallback)
        Constructor. Probably should only be used within repository framework.
        Parameters:
        root - The root directory under which we'll look for packages.
        manager - A RepoManager, notably containing the SchemaModules we'll use for reading and writing LocalPackages
        fallback - The FallbackLocalRepoLoader we'll use if we can't find a package in a directory.
    • Method Detail

      • needsUpdate

        public boolean needsUpdate​(long lastLocalRefreshMs,
                                   boolean deepCheck)
        Checks whether it looks like we need to be reloaded. If deepCheck is false, we just check whether .knownPackages has been updated more recently than lastLocalRefreshMs. If deepCheck is true, we check whether the hash in .knownPackages accurately reflects the currently-installed packages (traversing the SDK directory tree to do so).
        Specified by:
        needsUpdate in interface LocalRepoLoader
        Parameters:
        lastLocalRefreshMs - The last time a load was done
        deepCheck - How vigorously to check. If false, the check should be quite fast. If true it should still be reasonably fast, but less so.
        Returns:
        true if a reload is needed, false otherwise.