Class RepoManager

    • Field Detail

      • DEFAULT_EXPIRATION_PERIOD_MS

        public static final long DEFAULT_EXPIRATION_PERIOD_MS
        After loading the repository, this is the amount of time that must pass before we consider it to be stale and need to be reloaded.
    • Constructor Detail

      • RepoManager

        public RepoManager()
    • Method Detail

      • create

        @NonNull
        public static RepoManager create()
        Returns:
        A new RepoManager.
      • registerSchemaModule

        public abstract void registerSchemaModule​(@NonNull
                                                  SchemaModule<?> module)
        Register an SchemaModule that can be used when parsing XML for this repo.
      • getSchemaModules

        @NonNull
        public abstract java.util.List<SchemaModule<?>> getSchemaModules()
        Gets the currently-registered SchemaModules. This probably shouldn't be used except by code within the RepoManager or unit tests.
      • getCommonModule

        @NonNull
        public static SchemaModule<CommonFactory> getCommonModule()
        Gets the core SchemaModule created by the RepoManager itself. Contains the base definition of repository, package, revision, etc.
      • getGenericModule

        @NonNull
        public static SchemaModule<GenericFactory> getGenericModule()
        Gets the SchemaModule created by the RepoManager that includes the trivial generic typeDetails type.
      • setLocalPath

        public abstract void setLocalPath​(@Nullable
                                          java.nio.file.Path path)
        Sets the path to the local repository root.
      • getLocalPath

        @Nullable
        public abstract java.nio.file.Path getLocalPath()
        Gets the path to the local repository root. This probably shouldn't be needed except by the repository manager and unit tests.
      • load

        public abstract void load​(long cacheExpirationMs,
                                  @Nullable
                                  java.util.List<RepoManager.RepoLoadedListener> onLocalComplete,
                                  @Nullable
                                  java.util.List<RepoManager.RepoLoadedListener> onSuccess,
                                  @Nullable
                                  java.util.List<java.lang.Runnable> onError,
                                  @NonNull
                                  ProgressRunner runner,
                                  @Nullable
                                  Downloader downloader,
                                  @Nullable
                                  SettingsController settings)
        Loads the local and remote repositories asynchronously.
        Parameters:
        cacheExpirationMs - How long must have passed since the last load for us to reload. Specify 0 to reload immediately.
        onLocalComplete - When loading, the local repo load happens first, and should be relatively fast. When complete, the onLocalComplete RepoManager.RepoLoadedListeners are run. Will be called with a RepositoryPackages that contains only the local packages.
        onSuccess - Callbacks that are run when the entire load (local and remote) has completed successfully. Called with an RepositoryPackages containing both the local and remote packages.
        onError - Callbacks that are run when there's an error at some point during the load.
        runner - The ProgressRunner to use for any tasks started during the load, including running the callbacks.
        downloader - The Downloader to use for downloading remote files, including any remote list of repo sources and the remote repositories themselves.
        settings - The settings to use during the load, including for example proxy settings used when fetching remote files.

        TODO: throw exception if cancelled

      • loadSynchronously

        @Slow
        public abstract void loadSynchronously​(long cacheExpirationMs,
                                               @Nullable
                                               java.util.List<RepoManager.RepoLoadedListener> onLocalComplete,
                                               @Nullable
                                               java.util.List<RepoManager.RepoLoadedListener> onSuccess,
                                               @Nullable
                                               java.util.List<java.lang.Runnable> onError,
                                               @NonNull
                                               ProgressRunner runner,
                                               @Nullable
                                               Downloader downloader,
                                               @Nullable
                                               SettingsController settings)
        Loads the local and remote repositories synchronously. In callbacks, be careful of invoking tasks synchronously on other threads (e.g. the swing ui thread), since they might also be used by the {@link ProgressRunner) passed in.
        Parameters:
        cacheExpirationMs - How long must have passed since the last load for us to reload. Specify 0 to reload immediately.
        onLocalComplete - When loading, the local repo load happens first, and should be relatively fast. When complete, the onLocalComplete RepoManager.RepoLoadedListeners are run. Will be called with a RepositoryPackages that contains only the local packages.
        onSuccess - Callbacks that are run when the entire load (local and remote) has completed successfully. Called with an RepositoryPackages containing both the local and remote packages.
        onError - Callbacks that are run when there's an error at some point during the load.
        runner - The ProgressRunner to use for any tasks started during the load, including running the callbacks.
        downloader - The Downloader to use for downloading remote files, including any remote list of repo sources and the remote repositories themselves.
        settings - The settings to use during the load, including for example proxy settings used when fetching remote files. TODO: throw exception if cancelled
      • loadSynchronously

        @Slow
        public final boolean loadSynchronously​(long cacheExpirationMs,
                                               @NonNull
                                               ProgressIndicator progress,
                                               @Nullable
                                               Downloader downloader,
                                               @Nullable
                                               SettingsController settings)
        Loads the local and remote repositories synchronously.
        Parameters:
        cacheExpirationMs - How long must have passed since the last load for us to reload. Specify 0 to reload immediately.
        progress - The ProgressIndicator to use for showing progress and logging.
        downloader - The Downloader to use for downloading remote files, including any remote list of repo sources and the remote repositories themselves.
        settings - The settings to use during the load, including for example proxy settings used when fetching remote files.
        Returns:
        true if the load was successful (including if cached results were returned), false otherwise.
      • reloadLocalIfNeeded

        public abstract boolean reloadLocalIfNeeded​(@NonNull
                                                    ProgressIndicator progress)
        Check to see if there have been any changes to the local repo since the last load. This includes scanning the local repo for packages, but does not involve any reading or parsing of package metadata files. If there have been any changes, or if the cache is older than the default timeout, the local packages will be reloaded.
        Returns:
        true if the load was successful, false otherwise}.
      • getResourceResolver

        @Nullable
        public abstract org.w3c.dom.ls.LSResourceResolver getResourceResolver​(@NonNull
                                                                              ProgressIndicator progress)
        Gets an LSResourceResolver that can find the XSDs for all versions of the currently-registered SchemaModules by namespace. Returns null if there is an error.
      • addLocalChangeListener

        public abstract void addLocalChangeListener​(@NonNull
                                                    RepoManager.RepoLoadedListener listener)
        Registers a listener that will be called whenever the local packages are reloaded and have changed. The RepositoryPackages instance passed to the callback will contain only the local packages.
      • addRemoteChangeListener

        public abstract void addRemoteChangeListener​(@NonNull
                                                     RepoManager.RepoLoadedListener listener)
        Register a listener that will be called whenever the remote packages are reloaded and have changed. The RepositoryPackages instance will contain the remote and local packages.
      • installBeginning

        public abstract void installBeginning​(@NonNull
                                              RepoPackage repoPackage,
                                              @NonNull
                                              PackageOperation installer)
        Record that the given package is in the process of being installed by the given installer.
      • installEnded

        public abstract void installEnded​(@NonNull
                                          RepoPackage repoPackage)
        Record that the given package is no longer in the process of being installed (that is, install completed either successfully or unsuccessfully).
      • getInProgressInstallOperation

        @Nullable
        public abstract PackageOperation getInProgressInstallOperation​(@NonNull
                                                                       RepoPackage remotePackage)
        Gets the previously-registered installer that is currently installing the given package, or null if there is none.