Package org.apache.uima.pear.tools
Class PackageBrowser
- java.lang.Object
-
- org.apache.uima.pear.tools.PackageBrowser
-
public class PackageBrowser extends java.lang.Object
ThePackageBrowser
class 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 static java.lang.String
BINARY_DIR
static java.lang.String
CONFIGURATION_DIR
static java.lang.String
DATA_DIR
static java.lang.String
DESCRIPTORS_DIR
static java.lang.String
DOCUMENTATION_DIR
static java.lang.String
INSTALLATION_DESCRIPTOR_FILE
static java.lang.String
LIBRARY_DIR
static java.lang.String
METADATA_DIR
static java.lang.String
PEAR_PROPERTIES_FILE
static java.lang.String
RESOURCES_DIR
static java.lang.String
SETENV_TXT_FILE
static java.lang.String
SOURCES_DIR
static java.lang.String
SUBMISSION_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.String
buildComponentClassPath()
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 itslib
directory.java.lang.String
buildComponentClassPath(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 itslib
directory.java.lang.String
buildComponentPath()
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.String
buildComponentPath(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.String
buildComponentRuntimeClassPath()
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.File
findStandardDirectory(java.lang.String stdDirName)
Looks for a given standard package directory.java.io.File
findStandardFile(java.lang.String stdFileName)
Looks for a given standard package file.java.io.File[]
getAllDirectories()
java.io.File[]
getAllFiles()
java.lang.String
getComponentDataPath()
Returns the UIMA datapath setting for the component.java.util.Properties
getComponentEnvVars()
Returns the environment variable settings for the component.java.lang.String
getComponentPearDescPath()
returns the pear component pearSpecifier file path.InstallationDescriptor
getInstallationDescriptor()
Loads theINSTALLATION_DESCRIPTOR_FILE
file, and creates theInstallationDescriptor
(InsD) object.java.io.File
getRootDirectory()
boolean
isArchived()
-
-
-
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
-
-
Constructor Detail
-
PackageBrowser
public PackageBrowser(java.util.jar.JarFile pearPackage) throws java.io.IOException
Constructor 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.IOException
Constructor 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.IOException
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 itslib
directory. 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.IOException
LikebuildComponentClassPath()
, 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.IOException
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 itslib
directory. 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 givenboolean
argument. 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.IOException
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. 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.IOException
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. 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 givenboolean
argument. 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,
null
otherwise.
-
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,
null
otherwise.
-
getAllDirectories
public java.io.File[] getAllDirectories()
- Returns:
- Array of
File
objects representing all directories existing in the package.
-
getAllFiles
public java.io.File[] getAllFiles()
- Returns:
- Array of
File
objects representing all files existing in the package.
-
getInstallationDescriptor
public InstallationDescriptor getInstallationDescriptor() throws java.io.IOException
Loads theINSTALLATION_DESCRIPTOR_FILE
file, 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,false
otherwise.
-
getComponentPearDescPath
public java.lang.String getComponentPearDescPath() throws java.io.IOException
returns 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.IOException
Returns 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.IOException
Returns the environment variable settings for the component. The variable settings does not contain theclasspath
anduima.datapath
settings 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.
-
-