Package weka.core
Class WekaPackageManager
java.lang.Object
weka.core.WekaPackageManager
Class providing package management and manipulation routines. Also provides a
command line interface for package management.
- Version:
- $Revision: 15543 $
- Author:
- Mark Hall (mhall{[at]}pentaho{[dot]}com)
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Package metadata key for package disablementstatic final String
Package metadata key for package disablementstatic final String
Package metadata key for preventing load if a class is not availablestatic final String
Package metadata key for preventing load if a class is not availablestatic final String
Package metadata key for preventing load if an environment variable is not setstatic final String
Package metadata key for preventing load if an environment variable is not setstatic final String
Package metadata key for preventing load if a file is not presentstatic final String
Package metadata key for preventing load if a file is not presentstatic final String
Package metadata key for dependency injectionThe set of packages that the user has requested not to loadstatic boolean
Package loading in progress?static boolean
static boolean
Operating offline?static final String
Package metadata key for a message to display on installationstatic File
The default native libraries directorystatic String
static final String
Package metadata key for OS architecture.static final String
Package metadata key for OS name.static File
The default packages directorystatic final String
Package metadata key for package preclusionstatic File
The default properties directorystatic final String
Package metadata key for setting system propertiesstatic final String
Package metadata key for version infostatic final String
Package metadata key for JVM version.static File
Default path to where Weka's configuration and packages are stored -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
checkForMissingFiles
(Package toLoad, File packageRoot, PrintStream... progress) Checks to see if there are any missing files/directories for a given package.static Exception
checkForNewPackages
(PrintStream... progress) Check for new packages on the server and refresh the local cache if neededstatic Exception
establishCacheIfNeeded
(PrintStream... progress) Establish the local copy of the package meta data if neededstatic List<Dependency>
getAllDependenciesForPackage
(Package target, Map<String, List<Dependency>> conflicts) Get a list of dependencies for a given packageGet a list of all packagesGet a list of the most recent version of all available packages (i.e.Get a list of all available packages (i.e.static Package
getInstalledPackageInfo
(String packageName) Get meta data for an installed packageGet a list of installed packagesstatic Package
getLatestCompatibleVersion
(String packageName) Get the latest version of the named package that is compatible with the base version of Weka being used.static Package
getPackageArchiveInfo
(String packageArchivePath) Extract meta data from a package archivestatic File
getPackageList
(boolean local) Just get a list of the package names.static URL
Get the package repository URLstatic Package
getRepositoryPackageInfo
(String packageName) Get meta data for the latest version of a package from the repositorystatic Package
getRepositoryPackageInfo
(String packageName, String version) Get meta data for a specific version of a package from the repositorygetRepositoryPackageVersions
(String packageName) Get the versions of the supplied package available on the serverstatic PackageManager
Get the underlying package manager implementationstatic boolean
hasBeenLoaded
(Package toCheck) Check to see if the named package has been loaded successfullystatic boolean
installedPackageResourceExists
(String packageName, String resourceName) Check if a named resource exists in an installed packagestatic String
installPackageFromArchive
(String packageArchivePath, PrintStream... progress) Install a package from an archive (unofficial package install route)static boolean
installPackageFromRepository
(String packageName, String version, PrintStream... progress) Install a named package by retrieving the location of the archive from the meta data stored in the repositorystatic String
installPackageFromURL
(URL packageURL, PrintStream... progress) Install a package from the supplied URLstatic boolean
installPackages
(List<Package> toInstall, PrintStream... progress) Install the supplied list of packagesstatic boolean
loadCheck
(Package toLoad, File packageRoot, PrintStream... progress) Check whether a package should be loaded or not.static void
loadPackages
(boolean verbose) Load all packagesstatic void
loadPackages
(boolean verbose, boolean avoidTriggeringFullClassDiscovery, boolean refreshGOEProperties) Load all packagesstatic void
Main method for using the package manager from the command linestatic Package
Find the most recent version of the package encapsulated in the supplied PackageConstraint argument that satisfies the constraintstatic int
Get the number of packages that are available at the repository.static boolean
osAndArchCheck
(Package toLoad, PrintStream... progress) Checks the supplied package against the current OS and architecture.static Exception
refreshCache
(PrintStream... progress) Refresh the local copy of the package meta datastatic void
Refresh the generic object editor properties via re-running of the dynamic class discovery process.static void
removeExplorerProps
(String installedPackageName) Remove any ExplorerDefaults properties specified in the supplied packagestatic int
Retrieves the size (in KB) of the repository zip archive stored on the server.static Exception
startupCheck
(boolean force, PrintStream... progress) toggleLoadStatus
(List<String> packageNames) Toggle the load status of the supplied list of package namesstatic void
uninstallPackage
(String packageName, boolean updateKnowledgeFlow, PrintStream... progress) Uninstall a named packagestatic boolean
vmVersionCheck
(Package toLoad, PrintStream... progress) Checks the supplied package against the JVM version running Weka.
-
Field Details
-
INJECT_DEPENDENCY_KEY
Package metadata key for dependency injection- See Also:
-
VERSION_KEY
Package metadata key for version info- See Also:
-
DISABLE_KEY
Package metadata key for package disablement- See Also:
-
DISABLED_KEY
Package metadata key for package disablement- See Also:
-
PRECLUDES_KEY
Package metadata key for package preclusion- See Also:
-
OS_NAME_KEY
Package metadata key for OS name. Entries in this list are checked against the java property os.name using a String.contains() operation - any match in the list is taken as passing the test.- See Also:
-
OS_ARCH_KEY
Package metadata key for OS architecture. Entries in this list are checked against the java property os.arch using a String.equalsIgnoreCase() operation, with the exception of entries that are either "64" or "32" in which case the os.arch is checked to see if it contains these numbers. Any match in the list is considered as passing the test.- See Also:
-
VM_VERSION_KEY
Package metadata key for JVM version. Values can be prefixed by a less-than or greater-than sign. Otherwise, equality is assumed.- See Also:
-
DO_NOT_LOAD_IF_ENV_VAR_NOT_SET_KEY
Package metadata key for preventing load if an environment variable is not set- See Also:
-
DO_NOT_LOAD_IF_ENV_VAR_NOT_SET_MESSAGE_KEY
Package metadata key for preventing load if an environment variable is not set- See Also:
-
DO_NOT_LOAD_IF_CLASS_NOT_PRESENT_KEY
Package metadata key for preventing load if a class is not available- See Also:
-
DO_NOT_LOAD_IF_CLASS_NOT_PRESENT_MESSAGE_KEY
Package metadata key for preventing load if a class is not available- See Also:
-
DO_NOT_LOAD_IF_FILE_NOT_PRESENT_KEY
Package metadata key for preventing load if a file is not present- See Also:
-
DO_NOT_LOAD_IF_FILE_NOT_PRESENT_MESSAGE_KEY
Package metadata key for preventing load if a file is not present- See Also:
-
MESSAGE_TO_DISPLAY_ON_INSTALLATION_KEY
Package metadata key for a message to display on installation- See Also:
-
SET_SYSTEM_PROPERTIES_KEY
Package metadata key for setting system properties- See Also:
-
WEKA_HOME
Default path to where Weka's configuration and packages are stored -
PACKAGES_DIR
The default packages directory -
PROPERTIES_DIR
The default properties directory -
NATIVE_LIBS_DIR_NAME
-
NATIVE_LIBS_DIR
The default native libraries directory -
m_offline
public static boolean m_offlineOperating offline? -
m_initialPackageLoadingInProcess
public static boolean m_initialPackageLoadingInProcessPackage loading in progress? -
m_noPackageMetaDataAvailable
public static boolean m_noPackageMetaDataAvailable -
m_doNotLoadList
The set of packages that the user has requested not to load
-
-
Constructor Details
-
WekaPackageManager
public WekaPackageManager()
-
-
Method Details
-
removeExplorerProps
Remove any ExplorerDefaults properties specified in the supplied package- Parameters:
installedPackageName
- the package specifying properties that should be removed from ExplorerDefaults
-
hasBeenLoaded
Check to see if the named package has been loaded successfully- Parameters:
toCheck
- the name of the package to check for- Returns:
- true if the named package has been loaded successfully
-
loadCheck
Check whether a package should be loaded or not. Checks for missing classes, unset environment variables, missing dependencies etc.- Parameters:
toLoad
- the package to checkpackageRoot
- the root directory of the packageprogress
- for reporting loading progress- Returns:
- true if the package is good to load
-
vmVersionCheck
Checks the supplied package against the JVM version running Weka. Packages that don't specify a JVM version are assumed to be OK. The entry in the JVMVersion key are expected to be a floating point number, optionally prefixed by either a greater-than or less-than symbol. Absence of either of these symbols imply equality as the test.- Parameters:
toLoad
- the package to checkprogress
- PrintStream for progress info- Returns:
- true if the supplied package passes the JVM version test.
-
osAndArchCheck
Checks the supplied package against the current OS and architecture. Packages that don't specify OS and (optionally) architecture constraints are assumed to be OK. OS names in the OSName entry of the package's Description.props are checked against System.getProperty("os.name") via a String.contains() comparison. Any single match results in a pass. If supplied, the package's OSArch entries are checked against System.getProperty("os.arch") using a String.equalsIgnoreCase() comparison, with the exception of the values "64" and "32" which are checked for with String.contains().- Parameters:
toLoad
- the package to checkprogress
- PrintStream for progress info- Returns:
- true if the supplied package passes OS/arch constraints.
-
checkForMissingFiles
public static boolean checkForMissingFiles(Package toLoad, File packageRoot, PrintStream... progress) Checks to see if there are any missing files/directories for a given package. If there are missing files, then the package can't be loaded. An example would be a connector package that, for whatever reason, can't include a necessary third-party jar file in its lib folder, and requires the user to download and install this jar file manually.- Parameters:
toLoad
- the package to checkpackageRoot
- the root directory of the package- Returns:
- true if good to go
-
toggleLoadStatus
Toggle the load status of the supplied list of package names- Parameters:
packageNames
- the packages to toggle the load status for- Returns:
- a list of unknown packages (i.e. any supplied package names that don't appear to be installed)
- Throws:
Exception
- if a problem occurs
-
loadPackages
public static void loadPackages(boolean verbose) Load all packages- Parameters:
verbose
- true if loading progress should be output
-
loadPackages
public static void loadPackages(boolean verbose, boolean avoidTriggeringFullClassDiscovery, boolean refreshGOEProperties) Load all packages- Parameters:
verbose
- true if loading progress should be outputavoidTriggeringFullClassDiscovery
- true if we should avoid processing any properties files that might cause a full class discovery run, and may involve instantiating GUI classes.refreshGOEProperties
- true if the GOE properties should be refreshed after loading (i.e. a re-run of the class discovery mechanism, re-initialization of the Knowledge Flow etc.)
-
refreshGOEProperties
public static void refreshGOEProperties()Refresh the generic object editor properties via re-running of the dynamic class discovery process. -
getUnderlyingPackageManager
Get the underlying package manager implementation- Returns:
- the underlying concrete package management implementation.
-
repoZipArchiveSize
public static int repoZipArchiveSize()Retrieves the size (in KB) of the repository zip archive stored on the server.- Returns:
- the size of the repository zip archive in KB.
-
numRepositoryPackages
public static int numRepositoryPackages()Get the number of packages that are available at the repository.- Returns:
- the number of packages that are available (or -1 if this can't be determined for some reason.
-
getPackageList
Just get a list of the package names. This is faster than calling getAllPackages(), especially if fetching from the online repository, since the full meta data for each package doesn't have to be read.- Parameters:
local
- true if the local package list in the cache should be read rather than the online repository- Returns:
- a Map<String, String> of all the package names available either locally or at the repository
-
establishCacheIfNeeded
Establish the local copy of the package meta data if needed- Parameters:
progress
- for reporting progress- Returns:
- any Exception raised or null if all is good
-
checkForNewPackages
Check for new packages on the server and refresh the local cache if needed- Parameters:
progress
- to report progress to- Returns:
- any Exception raised or null if all is good
-
refreshCache
Refresh the local copy of the package meta data- Parameters:
progress
- to report progress to- Returns:
- any Exception raised or null if all is successful
-
installedPackageResourceExists
Check if a named resource exists in an installed package- Parameters:
packageName
- the name of the package in questionresourceName
- the name of the resource to check for- Returns:
- true if the resource exists in the package
-
getPackageHome
-
mostRecentVersionWithRespectToConstraint
public static Package mostRecentVersionWithRespectToConstraint(PackageConstraint toCheck) throws Exception Find the most recent version of the package encapsulated in the supplied PackageConstraint argument that satisfies the constraint- Parameters:
toCheck
- the PackageConstraint containing the package in question- Returns:
- the most recent version of the package satisfying the constraint
- Throws:
Exception
- if a version can't be found that satisfies the constraint or an error occurs while communicating with the respository
-
installPackages
public static boolean installPackages(List<Package> toInstall, PrintStream... progress) throws Exception Install the supplied list of packages- Parameters:
toInstall
- packages to installprogress
- to report progress to- Returns:
- true if successful
- Throws:
Exception
- if a problem occurs
-
getRepositoryPackageVersions
Get the versions of the supplied package available on the server- Parameters:
packageName
- the package name to get available versions for- Returns:
- a list of available versions
- Throws:
Exception
- if a problem occurs
-
getPackageRepositoryURL
Get the package repository URL- Returns:
- the package repository URL
-
getAllPackages
Get a list of all packages- Returns:
- a list of all packages
- Throws:
Exception
- if a problem occurs
-
getAvailablePackages
Get a list of all available packages (i.e. those not yet installed(.- Returns:
- a list of all available packages
- Throws:
Exception
- if a problem occurs
-
getAvailableCompatiblePackages
Get a list of the most recent version of all available packages (i.e. those not yet installed or there is a higher version in the repository) that are compatible with the version of Weka that is installed.- Returns:
- a list of packages that are compatible with the installed version of Weka
- Throws:
Exception
- if a problem occurs
-
getLatestCompatibleVersion
Get the latest version of the named package that is compatible with the base version of Weka being used.- Parameters:
packageName
- the name of the package to get the latest compatible version of- Returns:
- the latest compatible version or null if there is no compatible package
- Throws:
Exception
- if a problem occurs
-
getInstalledPackages
Get a list of installed packages- Returns:
- a list of installed packages
- Throws:
Exception
- if a problem occurs
-
getAllDependenciesForPackage
public static List<Dependency> getAllDependenciesForPackage(Package target, Map<String, List<Dependency>> conflicts) throws ExceptionGet a list of dependencies for a given package- Parameters:
target
- the package to get the dependencies forconflicts
- will hold any conflicts- Returns:
- a list of dependencies for the target package
- Throws:
Exception
- if a problem occurs
-
getPackageArchiveInfo
Extract meta data from a package archive- Parameters:
packageArchivePath
- the path to the package archive- Returns:
- the meta data for the package
- Throws:
Exception
- if a problem occurs
-
getInstalledPackageInfo
Get meta data for an installed package- Parameters:
packageName
- the name of the package- Returns:
- the meta data for the package
- Throws:
Exception
- if a problem occurs
-
getRepositoryPackageInfo
Get meta data for the latest version of a package from the repository- Parameters:
packageName
- the name of the package- Returns:
- the meta data for the package
- Throws:
Exception
- if a problem occurs
-
getRepositoryPackageInfo
Get meta data for a specific version of a package from the repository- Parameters:
packageName
- the name of the packageversion
- the version to get meta data for- Returns:
- the meta data for the package
- Throws:
Exception
- if a problem occurs
-
installPackageFromRepository
public static boolean installPackageFromRepository(String packageName, String version, PrintStream... progress) throws Exception Install a named package by retrieving the location of the archive from the meta data stored in the repository- Parameters:
packageName
- the name of the package to installversion
- the version of the package to installprogress
- for reporting progress- Returns:
- true if the package was installed successfully
- Throws:
Exception
- if a problem occurs
-
installPackageFromArchive
public static String installPackageFromArchive(String packageArchivePath, PrintStream... progress) throws Exception Install a package from an archive (unofficial package install route)- Parameters:
packageArchivePath
- the path to the package archive file to installprogress
- for reporting progress- Returns:
- true if the package was installed successfully
- Throws:
Exception
- if a problem occurs
-
installPackageFromURL
public static String installPackageFromURL(URL packageURL, PrintStream... progress) throws Exception Install a package from the supplied URL- Parameters:
packageURL
- the URL to the package archive to installprogress
- for reporting progress- Returns:
- true if the package was installed successfully
- Throws:
Exception
- if a problem occurs
-
uninstallPackage
public static void uninstallPackage(String packageName, boolean updateKnowledgeFlow, PrintStream... progress) throws Exception Uninstall a named package- Parameters:
packageName
- the name of the package to removeupdateKnowledgeFlow
- true if any Knowledge Flow beans provided by the package should be deregistered from the KnoweledgeFlowprogress
- for reporting progress- Throws:
Exception
- if a problem occurs
-
startupCheck
-
main
Main method for using the package manager from the command line- Parameters:
args
- command line arguments
-