Class RepoManagerImpl
- java.lang.Object
-
- com.android.repository.api.RepoManager
-
- com.android.repository.impl.manager.RepoManagerImpl
-
public class RepoManagerImpl extends RepoManager
Main implementation ofRepoManager. Loads local and remoteRepoPackages synchronously and asynchronously into aRepositoryPackagesinstance from the given local path and from the registeredRepositorySourceProviders, using the registeredSchemaModules.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceRepoManagerImpl.RemoteRepoLoaderFactory-
Nested classes/interfaces inherited from class com.android.repository.api.RepoManager
RepoManager.DummyProgressRunner, RepoManager.RepoLoadedListener
-
-
Field Summary
-
Fields inherited from class com.android.repository.api.RepoManager
DEFAULT_EXPIRATION_PERIOD_MS
-
-
Constructor Summary
Constructors Constructor Description RepoManagerImpl()Create a newRepoManagerImpl.RepoManagerImpl(com.android.repository.impl.manager.RepoManagerImpl.LocalRepoLoaderFactory localFactory, RepoManagerImpl.RemoteRepoLoaderFactory remoteFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddLocalChangeListener(RepoManager.RepoLoadedListener listener)Registers a listener that will be called whenever the local packages are reloaded and have changed.voidaddRemoteChangeListener(RepoManager.RepoLoadedListener listener)Register a listener that will be called whenever the remote packages are reloaded and have changed.PackageOperationgetInProgressInstallOperation(RepoPackage remotePackage)Gets the previously-registered installer that is currently installing the given package, ornullif there is none.java.nio.file.PathgetLocalPath()Gets the path to the local repository root.RepositoryPackagesgetPackages()Gets the currently-loadedRepositoryPackages.org.w3c.dom.ls.LSResourceResolvergetResourceResolver(ProgressIndicator progress)Gets anLSResourceResolverthat can find the XSDs for all versions of the currently-registeredSchemaModules by namespace.java.util.List<SchemaModule<?>>getSchemaModules()Gets the currently-registeredSchemaModules.java.util.List<RepositorySourceProvider>getSourceProviders()Gets the currently registeredRepositorySourceProviders.java.util.List<RepositorySource>getSources(Downloader downloader, ProgressIndicator progress, boolean forceRefresh)Gets the actualRepositorySources from the registeredRepositorySourceProviders.voidinstallBeginning(RepoPackage remotePackage, PackageOperation installer)Record that the given package is in the process of being installed by the given installer.voidinstallEnded(RepoPackage remotePackage)Record that the given package is no longer in the process of being installed (that is, install completed either successfully or unsuccessfully).voidload(long cacheExpirationMs, java.util.List<RepoManager.RepoLoadedListener> onLocalComplete, java.util.List<RepoManager.RepoLoadedListener> onSuccess, java.util.List<java.lang.Runnable> onError, ProgressRunner runner, Downloader downloader, SettingsController settings)Loads the local and remote repositories asynchronously.voidloadSynchronously(long cacheExpirationMs, java.util.List<RepoManager.RepoLoadedListener> onLocalComplete, java.util.List<RepoManager.RepoLoadedListener> onSuccess, java.util.List<java.lang.Runnable> onError, ProgressRunner runner, Downloader downloader, SettingsController settings)Loads the local and remote repositories synchronously.voidmarkInvalid()Causes cached results to be considered expired.voidmarkLocalCacheInvalid()Causes the cached results of the local repositories to be considered expired.voidregisterSchemaModule(SchemaModule<?> module)Register anSchemaModulethat can be used when parsing XML for this repo.voidregisterSourceProvider(RepositorySourceProvider provider)Adds aRepositorySourceProviderfrom which to getRepositorySources from which to download lists of available repository packages.booleanreloadLocalIfNeeded(ProgressIndicator progress)Check to see if there have been any changes to the local repo since the last load.voidremoveLocalChangeListener(RepoManager.RepoLoadedListener listener)Removes the listener previously added by callingRepoManager.addLocalChangeListener(com.android.repository.api.RepoManager.RepoLoadedListener).voidremoveRemoteChangeListener(RepoManager.RepoLoadedListener listener)Removes the listener previously added by callingRepoManager.addRemoteChangeListener(com.android.repository.api.RepoManager.RepoLoadedListener).voidsetFallbackLocalRepoLoader(FallbackLocalRepoLoader fallback)Sets theFallbackLocalRepoLoaderto use when scanning the local repository for packages.voidsetFallbackRemoteRepoLoader(FallbackRemoteRepoLoader remote)Sets theFallbackRemoteRepoLoaderto try when we encounter a remote xml file that the RepoManger can't read.voidsetLocalPath(java.nio.file.Path path)Sets the path to the local repository root.-
Methods inherited from class com.android.repository.api.RepoManager
create, getCommonModule, getGenericModule, loadSynchronously
-
-
-
-
Constructor Detail
-
RepoManagerImpl
public RepoManagerImpl()
Create a newRepoManagerImpl. Before anything can be loaded, at least a local path and/or at least oneRepositorySourceProvidermust be set.
-
RepoManagerImpl
public RepoManagerImpl(@Nullable com.android.repository.impl.manager.RepoManagerImpl.LocalRepoLoaderFactory localFactory, @Nullable RepoManagerImpl.RemoteRepoLoaderFactory remoteFactory)- Parameters:
localFactory- Ifnull,RepoManagerImpl.LocalRepoLoaderFactoryImplwill be used. Can be non-null for testing.remoteFactory- Ifnull,RepoManagerImpl.RemoteRepoLoaderFactoryImplwill be used. Can be non-null for testing.- See Also:
RepoManagerImpl()
-
-
Method Detail
-
getLocalPath
@Nullable public java.nio.file.Path getLocalPath()
Description copied from class:RepoManagerGets the path to the local repository root. This probably shouldn't be needed except by the repository manager and unit tests.- Specified by:
getLocalPathin classRepoManager
-
setFallbackLocalRepoLoader
public void setFallbackLocalRepoLoader(@Nullable FallbackLocalRepoLoader fallback)Sets theFallbackLocalRepoLoaderto use when scanning the local repository for packages. This callsmarkInvalid(), so a complete load will occur the next timeload(long, List, List, List, ProgressRunner, Downloader, SettingsController)is called.- Specified by:
setFallbackLocalRepoLoaderin classRepoManager
-
setFallbackRemoteRepoLoader
public void setFallbackRemoteRepoLoader(@Nullable FallbackRemoteRepoLoader remote)Sets theFallbackRemoteRepoLoaderto try when we encounter a remote xml file that the RepoManger can't read. This callsmarkInvalid(), so a complete load will occur the next timeload(long, List, List, List, ProgressRunner, Downloader, SettingsController)is called.- Specified by:
setFallbackRemoteRepoLoaderin classRepoManager
-
setLocalPath
public void setLocalPath(@Nullable java.nio.file.Path path)Sets the path to the local repository root. This callsmarkInvalid(), so a complete load will occur the next timeload(long, List, List, List, ProgressRunner, Downloader, SettingsController)is called.- Specified by:
setLocalPathin classRepoManager
-
registerSourceProvider
public void registerSourceProvider(@NonNull RepositorySourceProvider provider)Adds aRepositorySourceProviderfrom which to getRepositorySources from which to download lists of available repository packages. This callsmarkInvalid(), so a complete load will occur the next timeload(long, List, List, List, ProgressRunner, Downloader, SettingsController)is called.- Specified by:
registerSourceProviderin classRepoManager
-
getSourceProviders
@NonNull public java.util.List<RepositorySourceProvider> getSourceProviders()
Description copied from class:RepoManagerGets the currently registeredRepositorySourceProviders. Should only be needed for testing.- Specified by:
getSourceProvidersin classRepoManager
-
getSources
@NonNull public java.util.List<RepositorySource> getSources(@Nullable Downloader downloader, @NonNull ProgressIndicator progress, boolean forceRefresh)
Description copied from class:RepoManagerGets the actualRepositorySources from the registeredRepositorySourceProviders.Probably should only be needed by a repository UI.
- Specified by:
getSourcesin classRepoManager- Parameters:
downloader- TheDownloaderto use for downloading source lists, if needed.progress- AProgressIndicatorfor source providers to use to show their progress and for logging.forceRefresh- IndividualRepositorySourceProviders may cache their results. IfforceRefreshis true, specifies that they should reload rather than returning cached results.- Returns:
- The
RepositorySources obtained from the providers.
-
getSchemaModules
@NonNull public java.util.List<SchemaModule<?>> getSchemaModules()
Description copied from class:RepoManagerGets the currently-registeredSchemaModules. This probably shouldn't be used except by code within the RepoManager or unit tests.- Specified by:
getSchemaModulesin classRepoManager
-
registerSchemaModule
public void registerSchemaModule(@NonNull SchemaModule<?> module)Register anSchemaModulethat can be used when parsing XML for this repo. This callsmarkInvalid(), so a complete load will occur the next timeload(long, List, List, List, ProgressRunner, Downloader, SettingsController)is called.- Specified by:
registerSchemaModulein classRepoManager
-
markInvalid
public void markInvalid()
Description copied from class:RepoManagerCauses cached results to be considered expired. The next timeRepoManager.load(long, List, List, List, ProgressRunner, Downloader, SettingsController)is called, a complete load will be done.- Specified by:
markInvalidin classRepoManager
-
markLocalCacheInvalid
public void markLocalCacheInvalid()
Description copied from class:RepoManagerCauses the cached results of the local repositories to be considered expired. The next timeRepoManager.load(long, List, List, List, ProgressRunner, Downloader, SettingsController)is called, the load will be done only for the local repositories, the remotes being loaded from the cache if possible.- Specified by:
markLocalCacheInvalidin classRepoManager
-
getResourceResolver
@Nullable public org.w3c.dom.ls.LSResourceResolver getResourceResolver(@NonNull ProgressIndicator progress)Description copied from class:RepoManagerGets anLSResourceResolverthat can find the XSDs for all versions of the currently-registeredSchemaModules by namespace. Returns null if there is an error.- Specified by:
getResourceResolverin classRepoManager
-
getPackages
@NonNull public RepositoryPackages getPackages()
Description copied from class:RepoManagerGets the currently-loadedRepositoryPackages.- Specified by:
getPackagesin classRepoManager
-
loadSynchronously
public 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)Description copied from class:RepoManagerLoads 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.- Specified by:
loadSynchronouslyin classRepoManager- Parameters:
cacheExpirationMs- How long must have passed since the last load for us to reload. Specify0to reload immediately.onLocalComplete- When loading, the local repo load happens first, and should be relatively fast. When complete, theonLocalCompleteRepoManager.RepoLoadedListeners are run. Will be called with aRepositoryPackagesthat contains only the local packages.onSuccess- Callbacks that are run when the entire load (local and remote) has completed successfully. Called with anRepositoryPackagescontaining both the local and remote packages.onError- Callbacks that are run when there's an error at some point during the load.runner- TheProgressRunnerto use for any tasks started during the load, including running the callbacks.downloader- TheDownloaderto 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
-
load
public 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)Description copied from class:RepoManagerLoads the local and remote repositories asynchronously.- Specified by:
loadin classRepoManager- Parameters:
cacheExpirationMs- How long must have passed since the last load for us to reload. Specify0to reload immediately.onLocalComplete- When loading, the local repo load happens first, and should be relatively fast. When complete, theonLocalCompleteRepoManager.RepoLoadedListeners are run. Will be called with aRepositoryPackagesthat contains only the local packages.onSuccess- Callbacks that are run when the entire load (local and remote) has completed successfully. Called with anRepositoryPackagescontaining both the local and remote packages.onError- Callbacks that are run when there's an error at some point during the load.runner- TheProgressRunnerto use for any tasks started during the load, including running the callbacks.downloader- TheDownloaderto 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
-
reloadLocalIfNeeded
@Slow public boolean reloadLocalIfNeeded(@NonNull ProgressIndicator progress)Description copied from class:RepoManagerCheck 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.- Specified by:
reloadLocalIfNeededin classRepoManager- Returns:
trueif the load was successful,falseotherwise}.
-
addLocalChangeListener
public void addLocalChangeListener(@NonNull RepoManager.RepoLoadedListener listener)Description copied from class:RepoManagerRegisters a listener that will be called whenever the local packages are reloaded and have changed. TheRepositoryPackagesinstance passed to the callback will contain only the local packages.- Specified by:
addLocalChangeListenerin classRepoManager
-
removeLocalChangeListener
public void removeLocalChangeListener(@NonNull RepoManager.RepoLoadedListener listener)Description copied from class:RepoManagerRemoves the listener previously added by callingRepoManager.addLocalChangeListener(com.android.repository.api.RepoManager.RepoLoadedListener).- Specified by:
removeLocalChangeListenerin classRepoManager
-
addRemoteChangeListener
public void addRemoteChangeListener(@NonNull RepoManager.RepoLoadedListener listener)Description copied from class:RepoManagerRegister a listener that will be called whenever the remote packages are reloaded and have changed. TheRepositoryPackagesinstance will contain the remote and local packages.- Specified by:
addRemoteChangeListenerin classRepoManager
-
removeRemoteChangeListener
public void removeRemoteChangeListener(@NonNull RepoManager.RepoLoadedListener listener)Description copied from class:RepoManagerRemoves the listener previously added by callingRepoManager.addRemoteChangeListener(com.android.repository.api.RepoManager.RepoLoadedListener).- Specified by:
removeRemoteChangeListenerin classRepoManager
-
installBeginning
public void installBeginning(@NonNull RepoPackage remotePackage, @NonNull PackageOperation installer)Description copied from class:RepoManagerRecord that the given package is in the process of being installed by the given installer.- Specified by:
installBeginningin classRepoManager
-
installEnded
public void installEnded(@NonNull RepoPackage remotePackage)Description copied from class:RepoManagerRecord that the given package is no longer in the process of being installed (that is, install completed either successfully or unsuccessfully).- Specified by:
installEndedin classRepoManager
-
getInProgressInstallOperation
@Nullable public PackageOperation getInProgressInstallOperation(@NonNull RepoPackage remotePackage)
Description copied from class:RepoManagerGets the previously-registered installer that is currently installing the given package, ornullif there is none.- Specified by:
getInProgressInstallOperationin classRepoManager
-
-