Package org.apache.uima.pear.tools
Class PackageBrowser
- java.lang.Object
-
- org.apache.uima.pear.tools.PackageBrowser
-
public class PackageBrowser extends java.lang.ObjectThePackageBrowserclass allows browsing both archived and unarchived PEAR packages, finding package files and directories, loading installation descriptor files and returning run-time environment settings required for installed components.- See Also:
InstallationDescriptor
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.TreeSet<java.io.File>_allDirsprivate java.util.TreeSet<java.io.File>_allFilesprivate boolean_archivedprivate java.io.File_pearFileprivate java.util.jar.JarFile_pearPackageprivate java.io.File_rootDirstatic java.lang.StringBINARY_DIRstatic java.lang.StringCONFIGURATION_DIRstatic java.lang.StringDATA_DIRstatic java.lang.StringDESCRIPTORS_DIRstatic java.lang.StringDOCUMENTATION_DIRstatic java.lang.StringINSTALLATION_DESCRIPTOR_FILEstatic java.lang.StringLIBRARY_DIRstatic java.lang.StringMETADATA_DIRstatic java.lang.StringPEAR_PROPERTIES_FILEstatic java.lang.StringRESOURCES_DIRstatic java.lang.StringSETENV_TXT_FILEstatic java.lang.StringSOURCES_DIRstatic java.lang.StringSUBMISSION_PROPERTIES_FILE
-
Constructor Summary
Constructors Constructor Description PackageBrowser(java.io.File pearPackageDir)Constructor that allows browsing a given unacrhived PEAR package before or after its installation.PackageBrowser(java.util.jar.JarFile pearPackage)Constructor that allows browsing a given PEAR package without unarchiving it.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringbuildComponentClassPath()Creates a string that should be added to the CLASSPATH to run the given installed component, based on its installation descriptor specifications, as well as the contents of itslibdirectory.java.lang.StringbuildComponentClassPath(boolean relativePath, boolean addLibDir)Creates a string that should be added to the CLASSPATH to run the given installed component, based on its installation descriptor specifications, as well as the contents of itslibdirectory.java.lang.StringbuildComponentPath()Creates a string that should be added to the PATH to run the given installed component, based on the PEAR package defaults and its installation descriptor specifications.java.lang.StringbuildComponentPath(boolean relativePath)Creates a string that should be added to the PATH to run the given installed component, based on the PEAR package defaults and its installation descriptor specifications.java.lang.StringbuildComponentRuntimeClassPath()LikebuildComponentClassPath(), but without all jars from the lib dir.java.io.File[]findDirectory(java.lang.String dirNamePattern)Looks for package directories matching a given directory name pattern in the PEAR package.java.io.File[]findFile(java.lang.String fileNamePattern)Looks for package files matching a given file name pattern in the PEAR package.java.io.FilefindStandardDirectory(java.lang.String stdDirName)Looks for a given standard package directory.java.io.FilefindStandardFile(java.lang.String stdFileName)Looks for a given standard package file.java.io.File[]getAllDirectories()java.io.File[]getAllFiles()java.lang.StringgetComponentDataPath()Returns the UIMA datapath setting for the component.java.util.PropertiesgetComponentEnvVars()Returns the environment variable settings for the component.java.lang.StringgetComponentPearDescPath()returns the pear component pearSpecifier file path.InstallationDescriptorgetInstallationDescriptor()Loads theINSTALLATION_DESCRIPTOR_FILEfile, and creates theInstallationDescriptor(InsD) object.java.io.FilegetRootDirectory()booleanisArchived()
-
-
-
Field Detail
-
BINARY_DIR
public static final java.lang.String BINARY_DIR
-
CONFIGURATION_DIR
public static final java.lang.String CONFIGURATION_DIR
-
DATA_DIR
public static final java.lang.String DATA_DIR
-
DESCRIPTORS_DIR
public static final java.lang.String DESCRIPTORS_DIR
-
DOCUMENTATION_DIR
public static final java.lang.String DOCUMENTATION_DIR
-
LIBRARY_DIR
public static final java.lang.String LIBRARY_DIR
-
METADATA_DIR
public static final java.lang.String METADATA_DIR
-
RESOURCES_DIR
public static final java.lang.String RESOURCES_DIR
-
SOURCES_DIR
public static final java.lang.String SOURCES_DIR
-
INSTALLATION_DESCRIPTOR_FILE
public static final java.lang.String INSTALLATION_DESCRIPTOR_FILE
-
PEAR_PROPERTIES_FILE
public static final java.lang.String PEAR_PROPERTIES_FILE
-
SUBMISSION_PROPERTIES_FILE
public static final java.lang.String SUBMISSION_PROPERTIES_FILE
-
SETENV_TXT_FILE
public static final java.lang.String SETENV_TXT_FILE
-
_rootDir
private java.io.File _rootDir
-
_pearPackage
private java.util.jar.JarFile _pearPackage
-
_pearFile
private java.io.File _pearFile
-
_archived
private boolean _archived
-
_allFiles
private java.util.TreeSet<java.io.File> _allFiles
-
_allDirs
private java.util.TreeSet<java.io.File> _allDirs
-
-
Constructor Detail
-
PackageBrowser
public PackageBrowser(java.util.jar.JarFile pearPackage) throws java.io.IOExceptionConstructor that allows browsing a given PEAR package without unarchiving it.- Parameters:
pearPackage- The given archived PEAR package to browse.- Throws:
java.io.IOException- if a problem with IO
-
PackageBrowser
public PackageBrowser(java.io.File pearPackageDir) throws java.io.IOExceptionConstructor that allows browsing a given unacrhived PEAR package before or after its installation.- Parameters:
pearPackageDir- The root directory where the PEAR package was unarchived.- Throws:
java.io.IOException- if a problem with IO
-
-
Method Detail
-
buildComponentClassPath
public java.lang.String buildComponentClassPath() throws java.io.IOExceptionCreates a string that should be added to the CLASSPATH to run the given installed component, based on its installation descriptor specifications, as well as the contents of itslibdirectory. The output string includes absolute path expressions for all relevant objects containing in the component PEAR package. If the component package is archived, returnsnull.- Returns:
- The string that needs to be added to the CLASSPATH to run the given installed component.
- Throws:
java.io.IOException- If any I/O exception occurred.
-
buildComponentRuntimeClassPath
public java.lang.String buildComponentRuntimeClassPath() throws java.io.IOExceptionLikebuildComponentClassPath(), but without all jars from the lib dir.- Returns:
- The runtime classpath for the component.
- Throws:
java.io.IOException- if there was an IO problem
-
buildComponentClassPath
public java.lang.String buildComponentClassPath(boolean relativePath, boolean addLibDir) throws java.io.IOExceptionCreates a string that should be added to the CLASSPATH to run the given installed component, based on its installation descriptor specifications, as well as the contents of itslibdirectory. The output string includes absolute or relative path expressions for all relevant objects containing in the component PEAR package, depending on the value of a givenbooleanargument. If the component package is archived, returnsnull.- Parameters:
relativePath- Iftrue, the output string will include relative path expressions for all relevant objects containing in the component PEAR package, otherwise it will contain absolute path expressions for these objects.addLibDir- Whether to add jars from the lib dir to the classpath (true at packaging time, false at runtime).- Returns:
- The string that should be added to the CLASSPATH to run the given installed component.
- Throws:
java.io.IOException- If any I/O exception occurred.
-
buildComponentPath
public java.lang.String buildComponentPath() throws java.io.IOExceptionCreates a string that should be added to the PATH to run the given installed component, based on the PEAR package defaults and its installation descriptor specifications. The output string includes absolute path expressions for all relevant objects containing in the component PEAR package. If the component package is archived, returnsnull.- Returns:
- The string that needs to be added to the PATH to run the given installed component.
- Throws:
java.io.IOException- If any I/O exception occurred.
-
buildComponentPath
public java.lang.String buildComponentPath(boolean relativePath) throws java.io.IOExceptionCreates a string that should be added to the PATH to run the given installed component, based on the PEAR package defaults and its installation descriptor specifications. The output string includes absolute or relative path expressions for all relevant objects containing in the component PEAR package, depending on the value of a givenbooleanargument. If the component package is archived, returnsnull.- Parameters:
relativePath- Iftrue, the output string will include relative path expressions for all relevant objects containing in the component PEAR package, otherwise it will contain absolute path expressions for these objects.- Returns:
- The string that needs to be added to the PATH to run the given installed component.
- Throws:
java.io.IOException- If any I/O exception occurred.
-
findDirectory
public java.io.File[] findDirectory(java.lang.String dirNamePattern)
Looks for package directories matching a given directory name pattern in the PEAR package. If the given directory name pattern starts with '/' or '\', the method looks for directory names that start with the given name pattern, otherwise it looks for directory names that contain the given name pattern as a substring. The method does not support wild cards.- Parameters:
dirNamePattern- The given directory name pattern to look for.- Returns:
- The array of matching package directories.
-
findFile
public java.io.File[] findFile(java.lang.String fileNamePattern)
Looks for package files matching a given file name pattern in the PEAR package. If the given file name pattern starts with '/' or '\', the method looks for file names that start from the given name pattern, otherwise it looks for file names that contain the given name pattern as a substring. The method does not support wild cards.- Parameters:
fileNamePattern- The given file name pattern to look for.- Returns:
- The array of matching package files.
-
findStandardDirectory
public java.io.File findStandardDirectory(java.lang.String stdDirName)
Looks for a given standard package directory. This method assumes that the given standard directory name is the full name of the directory in the package root directory.- Parameters:
stdDirName- The given full standard package directory name.- Returns:
- The specified standard package directory, if this directory exists in the package,
nullotherwise.
-
findStandardFile
public java.io.File findStandardFile(java.lang.String stdFileName)
Looks for a given standard package file. This method assumes that the given standard file name is the full name of the file in the package root directory.- Parameters:
stdFileName- The given full standard package file name.- Returns:
- The specified standard package file, if this file exists in the package,
nullotherwise.
-
getAllDirectories
public java.io.File[] getAllDirectories()
- Returns:
- Array of
Fileobjects representing all directories existing in the package.
-
getAllFiles
public java.io.File[] getAllFiles()
- Returns:
- Array of
Fileobjects representing all files existing in the package.
-
getInstallationDescriptor
public InstallationDescriptor getInstallationDescriptor() throws java.io.IOException
Loads theINSTALLATION_DESCRIPTOR_FILEfile, and creates theInstallationDescriptor(InsD) object. Note: if the component package has been installed, the InsD object contains real specifications of package directories, otherwise it may contain macros like$main_root.- Returns:
- The InsD object corresponding the installation descriptor file.
- Throws:
java.io.IOException- If any I/O exception occurred.
-
getRootDirectory
public java.io.File getRootDirectory()
- Returns:
- The package root directory, where the package was unarchived, or the directory corresponding to the package file path without its extension, if the archived package was specified.
-
isArchived
public boolean isArchived()
- Returns:
true, if the archived package was specified,falseotherwise.
-
getComponentPearDescPath
public java.lang.String getComponentPearDescPath() throws java.io.IOExceptionreturns the pear component pearSpecifier file path.- Returns:
- returns the pear component pearSpecifier file path or null if an archived package was used.
- Throws:
java.io.IOException- if there was an IO problem
-
getComponentDataPath
public java.lang.String getComponentDataPath() throws java.io.IOExceptionReturns the UIMA datapath setting for the component. The datapath of the component must be specified as environment variable with the keyuima.datapath.- Returns:
- the datapath setting for the component or null if the datapath is not specified.
- Throws:
java.io.IOException- If any I/O exception occurred while reading the component meta data.
-
getComponentEnvVars
public java.util.Properties getComponentEnvVars() throws java.io.IOExceptionReturns the environment variable settings for the component. The variable settings does not contain theclasspathanduima.datapathsettings for the component.- Returns:
- returns the environment variable settings for the component
- Throws:
java.io.IOException- If any I/O exception occurred while reading the component meta data.
-
-