public abstract class RepoManager
extends java.lang.Object
RepoManager:
SchemaModules used to parse the package.xml files and
remote repositories used by this repo using registerSchemaModule(SchemaModule)
setLocalPath(File).
FallbackLocalRepoLoader that can recognize and convert those packages using
setFallbackLocalRepoLoader(FallbackLocalRepoLoader).
RepositorySourceProviders to provide URLs for remotely-available packages.
FallbackRemoteRepoLoader that can read and convert them.
To load the local and remote packages, use load(long, List, List, List, ProgressRunner,
Downloader, SettingsController, boolean)
TODO: it would be nice if this could be redesigned such that load didn't need to be called
explicitly, or there was a better way to know if packages were or need to be loaded.
To use the loaded packages, get an RepositoryPackages object from getPackages().
| Modifier and Type | Class and Description |
|---|---|
protected static class |
RepoManager.DummyProgressRunner |
static interface |
RepoManager.RepoLoadedCallback
Callback for when repository load is completed/partially completed.
|
| Modifier and Type | Field and Description |
|---|---|
static 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 and Description |
|---|
RepoManager() |
| Modifier and Type | Method and Description |
|---|---|
static RepoManager |
create(FileOp fop) |
static SchemaModule<CommonFactory> |
getCommonModule()
Gets the core
SchemaModule created by the RepoManager itself. |
static SchemaModule<GenericFactory> |
getGenericModule()
Gets the
SchemaModule created by the RepoManager that includes the trivial generic
typeDetails type. |
abstract PackageOperation |
getInProgressInstallOperation(RepoPackage remotePackage)
Gets the previously-registered installer that is currently installing the given package, or
null if there is none. |
abstract java.io.File |
getLocalPath()
Gets the path to the local repository root.
|
abstract RepositoryPackages |
getPackages()
Gets the currently-loaded
RepositoryPackages. |
abstract org.w3c.dom.ls.LSResourceResolver |
getResourceResolver(ProgressIndicator progress)
Gets an
LSResourceResolver that can find the XSDs for all versions of the
currently-registered SchemaModules by namespace. |
abstract java.util.Set<SchemaModule<?>> |
getSchemaModules()
Gets the currently-registered
SchemaModules. |
abstract java.util.Set<RepositorySourceProvider> |
getSourceProviders()
Gets the currently registered
RepositorySourceProviders. |
abstract java.util.Set<RepositorySource> |
getSources(Downloader downloader,
ProgressIndicator progress,
boolean forceRefresh)
Gets the actual
RepositorySources from the registered RepositorySourceProviders. |
abstract void |
installBeginning(RepoPackage repoPackage,
PackageOperation installer)
Record that the given package is in the process of being installed by the given installer.
|
abstract void |
installEnded(RepoPackage repoPackage)
Record that the given package is no longer in the process of being installed (that is,
install completed either successfully or unsuccessfully).
|
abstract void |
load(long cacheExpirationMs,
java.util.List<RepoManager.RepoLoadedCallback> onLocalComplete,
java.util.List<RepoManager.RepoLoadedCallback> onSuccess,
java.util.List<java.lang.Runnable> onError,
ProgressRunner runner,
Downloader downloader,
SettingsController settings,
boolean sync)
Load the local and remote repositories.
|
boolean |
loadSynchronously(long cacheExpirationMs,
ProgressIndicator progress,
Downloader downloader,
SettingsController settings)
Load the local and remote repositories synchronously.
|
abstract void |
markInvalid()
Causes cached results to be considered expired.
|
abstract void |
markLocalCacheInvalid()
Causes the cached results of the local repositories to be considered expired.
|
abstract void |
registerLocalChangeListener(RepoManager.RepoLoadedCallback listener)
Registers a listener that will be called whenever the local packages are reloaded and have
changed.
|
abstract void |
registerRemoteChangeListener(RepoManager.RepoLoadedCallback listener)
Register a listener that will be called whenever the remote packages are reloaded and have
changed.
|
abstract void |
registerSchemaModule(SchemaModule module)
Register an
SchemaModule that can be used when parsing XML for this repo. |
abstract void |
registerSourceProvider(RepositorySourceProvider provider)
Adds a
RepositorySourceProvider from which to get RepositorySources from
which to download lists of available repository packages. |
abstract boolean |
reloadLocalIfNeeded(ProgressIndicator progress)
Check to see if there have been any changes to the local repo since the last load.
|
abstract void |
setFallbackLocalRepoLoader(FallbackLocalRepoLoader local)
Sets the
FallbackLocalRepoLoader to use when scanning the local repository for
packages. |
abstract void |
setFallbackRemoteRepoLoader(FallbackRemoteRepoLoader remote)
Sets the
FallbackRemoteRepoLoader to try when we encounter a remote xml file that the
RepoManger can't read. |
abstract void |
setLocalPath(java.io.File path)
Sets the path to the local repository root.
|
public static final long DEFAULT_EXPIRATION_PERIOD_MS
@NonNull public static RepoManager create(@NonNull FileOp fop)
fop - The FileOp to use for local filesystem operations. Probably FileOpUtils.create() unless part of a unit test.RepoManager.public abstract void registerSchemaModule(@NonNull
SchemaModule module)
SchemaModule that can be used when parsing XML for this repo.@NonNull public abstract java.util.Set<SchemaModule<?>> getSchemaModules()
SchemaModules. This probably shouldn't be used except
by code within the RepoManager or unit tests.@NonNull public static SchemaModule<CommonFactory> getCommonModule()
SchemaModule created by the RepoManager itself. Contains the base
definition of repository, package, revision, etc.@NonNull public static SchemaModule<GenericFactory> getGenericModule()
SchemaModule created by the RepoManager that includes the trivial generic
typeDetails type.public abstract void setLocalPath(@Nullable
java.io.File path)
@Nullable public abstract java.io.File getLocalPath()
public abstract void setFallbackLocalRepoLoader(@Nullable
FallbackLocalRepoLoader local)
FallbackLocalRepoLoader to use when scanning the local repository for
packages.public abstract void registerSourceProvider(@NonNull
RepositorySourceProvider provider)
RepositorySourceProvider from which to get RepositorySources from
which to download lists of available repository packages.@NonNull public abstract java.util.Set<RepositorySourceProvider> getSourceProviders()
RepositorySourceProviders. Should only be needed for
testing.public abstract java.util.Set<RepositorySource> getSources(@Nullable Downloader downloader, @NonNull ProgressIndicator progress, boolean forceRefresh)
RepositorySources from the registered RepositorySourceProviders.
Probably should only be needed by a repository UI.downloader - The Downloader to use for downloading source lists, if needed.progress - A ProgressIndicator for source providers to use to show their
progress and for logging.forceRefresh - Individual RepositorySourceProviders may cache their results. If
forceRefresh is true, specifies that they should reload rather
than returning cached results.RepositorySources obtained from the providers.public abstract void setFallbackRemoteRepoLoader(@Nullable
FallbackRemoteRepoLoader remote)
FallbackRemoteRepoLoader to try when we encounter a remote xml file that the
RepoManger can't read.public abstract void load(long cacheExpirationMs,
@Nullable
java.util.List<RepoManager.RepoLoadedCallback> onLocalComplete,
@Nullable
java.util.List<RepoManager.RepoLoadedCallback> onSuccess,
@Nullable
java.util.List<java.lang.Runnable> onError,
@NonNull
ProgressRunner runner,
@Nullable
Downloader downloader,
@Nullable
SettingsController settings,
boolean sync)
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.RepoLoadedCallbacks 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.sync - If true, load synchronously. If false, load asynchronously (this
method should return quickly, and the onSuccess callbacks
can be used to process the completed results).
TODO: throw exception if cancelledpublic final boolean loadSynchronously(long cacheExpirationMs,
@NonNull
ProgressIndicator progress,
@Nullable
Downloader downloader,
@Nullable
SettingsController settings)
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.true if the load was successful (including if cached results were returned),
false otherwise.public abstract void markInvalid()
load(long, List, List,
List, ProgressRunner, Downloader, SettingsController, boolean) is called, a complete load
will be done.public abstract void markLocalCacheInvalid()
load(long, List, List, List, ProgressRunner, Downloader, SettingsController,
boolean) is called, the load will be done only for the local repositories, the remotes being
loaded from the cache if possible.public abstract boolean reloadLocalIfNeeded(@NonNull
ProgressIndicator progress)
true if the load was successful, false otherwise}.@NonNull public abstract RepositoryPackages getPackages()
RepositoryPackages.@Nullable
public abstract org.w3c.dom.ls.LSResourceResolver getResourceResolver(@NonNull
ProgressIndicator progress)
LSResourceResolver that can find the XSDs for all versions of the
currently-registered SchemaModules by namespace. Returns null if there is an error.public abstract void registerLocalChangeListener(@NonNull
RepoManager.RepoLoadedCallback listener)
RepositoryPackages instance passed to the callback will contain only the
local packages.public abstract void registerRemoteChangeListener(@NonNull
RepoManager.RepoLoadedCallback listener)
RepositoryPackages instance will contain the remote and local packages.public abstract void installBeginning(@NonNull
RepoPackage repoPackage,
@NonNull
PackageOperation installer)
public abstract void installEnded(@NonNull
RepoPackage repoPackage)
@Nullable public abstract PackageOperation getInProgressInstallOperation(@NonNull RepoPackage remotePackage)
null if there is none.