public class DefaultPackageManager extends PackageManager
| Modifier and Type | Class and Description |
|---|---|
protected static class |
DefaultPackageManager.DefaultPMDefaults
Default settings for the default package manager implementation
|
| Modifier and Type | Field and Description |
|---|---|
protected static int |
BUFF_SIZE
buffer size for copying files
|
protected static java.lang.String |
INSTALLED_PACKAGE_CACHE_FILE |
protected static byte[] |
m_buffer
buffer used in copying files
|
protected int |
m_timeout
Timeout to use for comms
|
protected static java.util.List<Package> |
s_installedPackageList |
protected static java.lang.String |
TIMEOUT_PROPERTY
Key for the socket timeout property
|
m_authenticatorSet, m_baseSystemName, m_baseSystemVersion, m_httpProxy, m_packageHome, m_packageRepository, m_proxyPassword, m_proxyUsername| Constructor and Description |
|---|
DefaultPackageManager()
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
applySettings(Settings settings)
Apply settings.
|
protected static boolean |
checkDependencies(PackageConstraint toCheck,
java.util.Map<java.lang.String,Dependency> lookup,
java.util.Map<java.lang.String,java.util.List<Dependency>> conflicts)
Checks a given package's list of dependencies for any conflicts with the
packages in the supplied Map.
|
static void |
deleteDir(java.io.File dir,
java.io.PrintStream... progress) |
protected void |
deleteInstalledPackageCacheFile() |
protected java.io.File |
downloadArchive(java.net.URL packageURL,
java.lang.String fileExtension,
java.io.PrintStream... progress) |
protected boolean |
establishPackageHome()
Checks to see if the package home exists and creates it if necessary.
|
java.util.List<Dependency> |
getAllDependenciesForPackage(Package target,
java.util.Map<java.lang.String,java.util.List<Dependency>> conflicts)
Gets a full list of packages (encapsulated in Dependency objects) that are
required by directly and indirectly by the named target package.
|
java.util.List<Package> |
getAllPackages(java.io.PrintStream... progress)
Get all packages that the system knows about (i.e. all packages contained
in the repository).
|
java.util.List<Package> |
getAvailablePackages()
Get a list of packages that are not currently installed.
|
Defaults |
getDefaultSettings()
Get the default settings for the default package manager
|
Package |
getInstalledPackageInfo(java.lang.String packageName)
Get package information on the named installed package.
|
java.util.List<Package> |
getInstalledPackages()
Get a list of installed packages.
|
Package |
getPackageArchiveInfo(java.lang.String packageArchivePath)
Get package information from the supplied package archive file.
|
Package |
getRepositoryPackageInfo(java.lang.String packageName)
Get package information on the named package from the repository.
|
Package |
getRepositoryPackageInfo(java.lang.String packageName,
java.lang.Object version)
Get package information on the named package from the repository.
|
byte[] |
getRepositoryPackageMetaDataOnlyAsZip(java.io.PrintStream... progress)
Gets an array of bytes containing a zip of all the repository meta data and
supporting files.
|
byte[] |
getRepositoryPackageMetaDataOnlyAsZipLegacy(java.io.PrintStream... progress)
Gets an array of bytes containing a zip of all the repository meta data and
supporting files using the legacy approach.
|
java.util.List<java.lang.Object> |
getRepositoryPackageVersions(java.lang.String packageName)
Get a list of available versions of the named package.
|
Package |
getURLPackageInfo(java.net.URL packageURL)
Get package information on the package at the given URL.
|
protected void |
installAdditionalLibs(java.lang.String packageName,
java.lang.String[] additionalLibURLs,
java.io.PrintStream... progress)
Installs additional library jar files (as specified in the AdditionalLibs
entry in the Description.props file).
|
protected void |
installPackage(java.lang.String packageArchivePath,
java.lang.String packageName,
java.io.PrintStream... progress)
Installs a package from a zip/jar archive.
|
java.lang.String |
installPackageFromArchive(java.lang.String packageArchivePath,
java.io.PrintStream... progress)
Install a package from an archive on the local file system.
|
void |
installPackageFromRepository(java.lang.String packageName,
java.lang.Object version,
java.io.PrintStream... progress)
Install a package sourced from the repository.
|
java.lang.String |
installPackageFromURL(java.net.URL packageURL,
java.io.PrintStream... progress)
Install a package sourced from a given URL.
|
void |
installPackages(java.util.List<Package> toInstall,
java.io.PrintStream... progress)
Installs all the packages in the supplied list.
|
protected java.util.List<Package> |
loadInstalledPackageCache()
Load the serialized installed package cache file
|
static void |
main(java.lang.String[] args) |
protected static java.lang.String |
padLeft(java.lang.String inString,
int length)
Pads a string to a specified length, inserting spaces on the left as
required.
|
protected static java.lang.String |
padRight(java.lang.String inString,
int length)
Pads a string to a specified length, inserting spaces on the right as
required.
|
protected void |
saveInstalledPackageCache(java.util.List<Package> cacheToSave)
Save the supplied list of Packages to the installed package cache file
|
void |
uninstallPackage(java.lang.String packageName,
java.io.PrintStream... progress)
Uninstall a package.
|
create, establishProxy, getBaseSystemName, getBaseSystemVersion, getPackageHome, getPackageRepositoryURL, getProxy, setBaseSystemName, setBaseSystemVersion, setPackageHome, setPackageRepositoryURL, setProxy, setProxyAuthentication, setProxyPassword, setProxyUsernameprotected static final int BUFF_SIZE
protected static final byte[] m_buffer
protected static final java.lang.String INSTALLED_PACKAGE_CACHE_FILE
protected static java.util.List<Package> s_installedPackageList
protected int m_timeout
protected static final java.lang.String TIMEOUT_PROPERTY
public Defaults getDefaultSettings()
getDefaultSettings in class PackageManagerpublic void applySettings(Settings settings)
applySettings in class PackageManagersettings - the settings to applyprotected java.io.File downloadArchive(java.net.URL packageURL,
java.lang.String fileExtension,
java.io.PrintStream... progress)
throws java.lang.Exception
java.lang.Exceptionpublic Package getURLPackageInfo(java.net.URL packageURL) throws java.lang.Exception
getURLPackageInfo in class PackageManagerpackageURL - the URL to the package.java.lang.Exception - if the package meta data can't be retrieved.public Package getRepositoryPackageInfo(java.lang.String packageName) throws java.lang.Exception
getRepositoryPackageInfo in class PackageManagerpackageName - the name of the package to get information about.java.lang.Exception - if the package meta data can't be retrieved.public java.util.List<java.lang.Object> getRepositoryPackageVersions(java.lang.String packageName)
throws java.lang.Exception
getRepositoryPackageVersions in class PackageManagerpackageName - the name of the package to get versions.java.lang.Exception - if something goes wrong while trying to retrieve the list
of versions.public Package getRepositoryPackageInfo(java.lang.String packageName, java.lang.Object version) throws java.lang.Exception
getRepositoryPackageInfo in class PackageManagerpackageName - the name of the package to get information about.version - the version of the package to retrieve (may be null if not
applicable).java.lang.Exception - if the package meta data can't be retrieved.public Package getPackageArchiveInfo(java.lang.String packageArchivePath) throws java.lang.Exception
getPackageArchiveInfo in class PackageManagerpackageArchivePath - the path to the package archive filejava.lang.Exception - if the package meta data can't be retrieved.public Package getInstalledPackageInfo(java.lang.String packageName) throws java.lang.Exception
getInstalledPackageInfo in class PackageManagerpackageName - the name of the package to get information about.java.lang.Exception - if the package meta data can't be retrieved.protected boolean establishPackageHome()
public static void deleteDir(java.io.File dir,
java.io.PrintStream... progress)
throws java.lang.Exception
java.lang.Exceptionpublic void uninstallPackage(java.lang.String packageName,
java.io.PrintStream... progress)
throws java.lang.Exception
uninstallPackage in class PackageManagerpackageName - the package to uninstall.progress - optional varargs parameter, that, if supplied, is expected
to contain one or more PrintStream objects to write progress to.java.lang.Exception - if the named package could not be removed for some
reason.public java.lang.String installPackageFromArchive(java.lang.String packageArchivePath,
java.io.PrintStream... progress)
throws java.lang.Exception
installPackageFromArchive in class PackageManagerpackageArchivePath - the path to the package archive file.progress - optional varargs parameter, that, if supplied, is expected
to contain one or more PrintStream objects to write progress to.java.lang.Exception - if the package can't be installed for some reason.protected void installAdditionalLibs(java.lang.String packageName,
java.lang.String[] additionalLibURLs,
java.io.PrintStream... progress)
throws java.lang.Exception
packageName - the name of the package that will receive the downloaded
libraries into its lib directoryadditionalLibURLs - an array of urls to the libraries to downloadprogress - for progress reportingjava.lang.Exception - if a problem occurspublic void installPackages(java.util.List<Package> toInstall, java.io.PrintStream... progress) throws java.lang.Exception
installPackages in class PackageManagertoInstall - a list of Packages to install.progress - optional varargs parameter, that, if supplied, is expected
to contain one or more PrintStream objects to write progress to.java.lang.Exception - if something goes wrong during the installation process.protected static boolean checkDependencies(PackageConstraint toCheck, java.util.Map<java.lang.String,Dependency> lookup, java.util.Map<java.lang.String,java.util.List<Dependency>> conflicts) throws java.lang.Exception
toCheck - the package to check.lookup - a Map of package name, Dependency pairs to check against.conflicts - a list of Dependency objects for any conflicts that are
detected.java.lang.Exception - if a problem occurs when checking for conflicts.public java.util.List<Dependency> getAllDependenciesForPackage(Package target, java.util.Map<java.lang.String,java.util.List<Dependency>> conflicts) throws java.lang.Exception
getAllDependenciesForPackage in class PackageManagertarget - the package for which a list of dependencies is required.conflicts - will hold any conflicts that are discovered while building
the full dependency list.java.lang.Exception - if a problem occurs while building the dependency list.public void installPackageFromRepository(java.lang.String packageName,
java.lang.Object version,
java.io.PrintStream... progress)
throws java.lang.Exception
installPackageFromRepository in class PackageManagerpackageName - the name of the package to installversion - the version of the package to install (may be null if not
applicable).progress - optional varargs parameter, that, if supplied, is expected
to contain one or more PrintStream objects to write progress to.java.lang.Exception - if the package can't be installed for some reason.public java.lang.String installPackageFromURL(java.net.URL packageURL,
java.io.PrintStream... progress)
throws java.lang.Exception
installPackageFromURL in class PackageManagerpackageURL - the URL to the package.progress - optional varargs parameter, that, if supplied, is expected
to contain one or more PrintStream objects to write progress to.java.lang.Exception - if the package can't be installed for some reason.protected void installPackage(java.lang.String packageArchivePath,
java.lang.String packageName,
java.io.PrintStream... progress)
throws java.lang.Exception
packageArchivePath - the full path to the archived package to install.packageName - the name of the package to install.progress - optional varargs parameter, that, if supplied, is expected
to contain one or more PrintStream objects to write progress to.java.lang.Exception - if the package can't be installed for some reason.public byte[] getRepositoryPackageMetaDataOnlyAsZip(java.io.PrintStream... progress)
throws java.lang.Exception
getRepositoryPackageMetaDataOnlyAsZip in class PackageManagerprogress - optional varargs parameter, that, if supplied, is expected
to contain one or more PrintStream objects to write progress to.java.lang.Exception - if the repository meta data can't be returned as a zippublic byte[] getRepositoryPackageMetaDataOnlyAsZipLegacy(java.io.PrintStream... progress)
throws java.lang.Exception
java.lang.Exceptionpublic java.util.List<Package> getAllPackages(java.io.PrintStream... progress) throws java.lang.Exception
getAllPackages in class PackageManagerprogress - optional varargs parameter, that, if supplied is expected
to contain one or more PrintStream objects to write progress to.java.lang.Exception - if a list of packages can't be determined.public java.util.List<Package> getAvailablePackages() throws java.lang.Exception
getAvailablePackages in class PackageManagerjava.lang.Exception - if a list of packages can't be determined.public java.util.List<Package> getInstalledPackages() throws java.lang.Exception
getInstalledPackages in class PackageManagerjava.lang.Exception - if a list of packages can't be determined.protected void deleteInstalledPackageCacheFile()
throws java.lang.Exception
java.lang.Exceptionprotected void saveInstalledPackageCache(java.util.List<Package> cacheToSave) throws java.lang.Exception
cacheToSave - the list of packages to savejava.lang.Exception - if a problem occursprotected java.util.List<Package> loadInstalledPackageCache() throws java.lang.Exception
java.lang.Exception - if a problem occursprotected static java.lang.String padLeft(java.lang.String inString,
int length)
inString - the input stringlength - the desired length of the output stringprotected static java.lang.String padRight(java.lang.String inString,
int length)
inString - the input stringlength - the desired length of the output stringpublic static void main(java.lang.String[] args)