Package org.apache.uima.pear.tools
Class InstallationController
- java.lang.Object
-
- org.apache.uima.pear.tools.InstallationController
-
public class InstallationController extends java.lang.Object
TheInstallationController
class allows installing PEAR files that contain UIMA compliant components.
Note: current version works both in Windows and Linux.
This class may be used in the following ways:- As a standalone Java application -
java -DUIMA_HOME=%UIMA_HOME% org.apache.uima.pear.tools.InstallationController {-local pear_file | component_id} [-root] [installation_directory]
where the-local pear_file
option allows to install local PEAR file in the local file system (without using SITH services);
thecomponent_id
is the ID of the component to be installed using SITH services;
the-root
option enables component installation directly in the specified installation directory, as opposed to installing component in acomponent_id
subdirectory of the specified installation directory;
theinstallation_directory
is the directory where the new component will be installed - if the-root
option is specified, the component is installed in this directory, otherwise it is installed in acomponent_id
subdirectory of this directory; by default - current working directory. - As a Java object -
in this case, the caller is expected to set theUIMA_HOME
variable, using thesetUimaHomePath()
method, immediately after creating a new instance of theInstallationController
class.
Installation is performed by using theinstallComponent()
method.
Installation verification is performed by using theverifyComponent()
method.
Error messages can be retrieved by using thegetInstallationMsg()
andgetVerificationMsg()
methods.
Note 1: Starting from version 0.6, theInstallationController
class utilizes intra-process message routing (seeMessageRouter
). Applications need to call theterminate()
method on each instance of theInstallationController
class after all their operations are completed.
The application can get output and error messages, printed by theInstallationController
, by adding standard channel listeners (see theaddMsgListener()
method). By default, the output and error messages are printed to the standard console streams. Alternatively, the application can use theInstallationController
constructor that accepts a custom message listener. In this case, the output and error messages will not be printed to the standard console streams.
Note 2: Starting from version 1.4, theInstallationController
class defines theInstallationController.PackageSelector
interface and allows to plug-in custom package selectors for manually or automatically selecting root directories of installed PEAR packages, as well as PEAR package files that need to be installed.
Note 2: Starting from version 1.5, theInstallationController
class defines theInstallationController.InstallationMonitor
interface and allows to plug-in custom installation monitors for reporting component installation status and location of installed components.
- As a standalone Java application -
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
InstallationController.InstallationMonitor
TheInstallationMonitor
interface defines methods required for notifying of component installation status and location of the installed PEAR packages.static interface
InstallationController.PackageSelector
ThePackageSelector
interface defines methods required for manually or automatically selecting installed PEAR package root directories and PEAR package files.static class
InstallationController.TestStatus
TheTestStatus
class encapsulates attributes related to the results of the 'serviceability' verification test.
-
Field Summary
Fields Modifier and Type Field Description private static boolean
__inLocalMode
private static java.lang.String
__osName
private boolean
_cleanInstallDir
private MessageRouter.StdChannelListener
_defaultMsgListener
private java.lang.String
_hostIpAddress
private InstallationDescriptor
_insdObject
private java.io.File
_installationDir
private java.lang.String
_installationDirPath
private java.util.Hashtable<java.lang.String,InstallationDescriptor>
_installationInsDs
private InstallationController.InstallationMonitor
_installationMonitor
private java.lang.String
_installationMsg
private java.util.Hashtable<java.lang.String,java.lang.String>
_installationTable
private java.lang.String
_mainComponentId
private java.io.File
_mainComponentRoot
private java.lang.String
_mainComponentRootPath
private java.lang.String
_mainPearFileLocation
private MessageRouter
_msgRouter
private InstallationController.PackageSelector
_packageSelector
private java.lang.String
_uimaHomePath
private java.lang.String
_verificationMsg
static java.lang.String
CLASSPATH_VAR
protected static java.lang.String
INSTALL_IN_ROOT_OPT
static java.lang.String
INSTALLATION_COMPLETED
static java.lang.String
INSTALLATION_FAILED
static java.lang.String
INSTALLATION_IN_PROGRESS
protected static java.lang.String
INSTALLATION_TESTER_APP
protected static java.lang.String
JAR_FILE_EXT
protected static java.lang.String
LOCAL_OPT
static java.lang.String
PACKAGE_BIN_DIR
static java.lang.String
PACKAGE_CONF_DIR
static java.lang.String
PACKAGE_CONFIG_FILE
static java.lang.String
PACKAGE_DATA_DIR
static java.lang.String
PACKAGE_DESC_DIR
static java.lang.String
PACKAGE_DOC_DIR
static java.lang.String
PACKAGE_LIB_DIR
static java.lang.String
PACKAGE_METADATA_DIR
static java.lang.String
PACKAGE_RESOURCES_DIR
static java.lang.String
PACKAGE_SOURCES_DIR
protected static java.lang.String
PATH_VAR
static java.lang.String
PEAR_DESC_FILE_POSTFIX
private static java.lang.String
PEAR_MESSAGE_RESOURCE_BUNDLE
static java.lang.String
SET_ENV_FILE
protected static java.lang.String
UIMA_HOME_ENV
protected static java.lang.String
UIMA_LIB_DIR
static java.lang.String
VERIFICATION_CANCELLED
static java.lang.String
VERIFICATION_COMPLETED
static java.lang.String
VERIFICATION_FAILED
static java.lang.String
VERIFICATION_IN_PROGRESS
protected static java.lang.String
VINCI_LIB_DIR
-
Constructor Summary
Constructors Modifier Constructor Description InstallationController(java.lang.String componentId, java.io.File localPearFile, java.io.File rootDir)
Constructor for the 'local' mode, which specifies component ID, local PEAR file and a local root directory where the component will be installed.InstallationController(java.lang.String componentId, java.io.File localPearFile, java.io.File rootDir, boolean installInRootDir)
Constructor for the 'local' mode, which specifies component ID, local PEAR file and a local root directory where the component will be installed.InstallationController(java.lang.String componentId, java.io.File localPearFile, java.io.File rootDir, boolean installInRootDir, boolean cleanInstallDir)
Constructor for the 'local' mode, which specifies component ID, local PEAR file and a local root directory where the component will be installed.InstallationController(java.lang.String componentId, java.io.File localPearFile, java.io.File rootDir, boolean installInRootDir, MessageRouter.StdChannelListener msgListener)
Constructor for the 'local' mode, which specifies component ID, local PEAR file and a local root directory where the component will be installed.InstallationController(java.lang.String componentId, java.io.File localPearFile, java.io.File rootDir, boolean installInRootDir, MessageRouter.StdChannelListener msgListener, boolean cleanInstallDir)
Constructor for the 'local' mode, which specifies component ID, local PEAR file and a local root directory where the component will be installed.InstallationController(java.lang.String componentId, java.lang.String rootDirPath)
Constructs an instance of theInstallationController
class for a given component and a given installation root directory.InstallationController(java.lang.String componentId, java.lang.String rootDirPath, boolean installInRootDir)
Constructs an instance of theInstallationController
class for a given component and a given installation root directory.InstallationController(java.lang.String componentId, java.lang.String rootDirPath, boolean installInRootDir, MessageRouter.StdChannelListener msgListener)
Constructs an instance of theInstallationController
class for a given component and a given installation root directory.protected
InstallationController(java.lang.String componentId, java.lang.String rootDirPath, boolean installInRootDir, MessageRouter msgRouter, MessageRouter.StdChannelListener msgListener, boolean cleanInstallDir)
Internal constructor that creates an instance of theInstallationController
class for a given component and a given installation root directory.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static java.lang.StringBuffer
addListOfJarFiles(java.io.File libDir, java.lang.StringBuffer listBuffer)
Appends a list of JAR files in a given lib directory, separated with the OS dependent separator (';' or ':'), to a given initialStringBuffer
object.void
addMsgListener(MessageRouter.StdChannelListener listener)
Adds a given object, implementing theMessageRouter.StdChannelListener
interface to the list of standard channel listeners.protected static boolean
addToSystemEnvTable(java.util.Properties sysEnvTable, java.lang.String localKey, java.lang.String localValue)
Adds a given local environment variable to appropriate system environment variable (before the system value).static java.lang.String[]
buildArrayOfNetworkParams(InstallationDescriptor insdObject)
Creates a string array that contains network parameters (in the JVM '-Dname=value' format) specified in a given installation descriptor object.java.lang.String
buildComponentClassPath()
BuildsCLASSPATH
for the installed component, includingCLASSPATH
for all separate delegate components that are utilized by the main installed component, if any.static java.lang.String
buildComponentClassPath(java.lang.String compRootDirPath, InstallationDescriptor insdObject, boolean addLibDir)
Creates a string that should be added to the CLASSPATH for a given installed component associated with a given installation descriptor object.java.lang.String
buildComponentPath()
BuildsPATH
for the installed component, includingPATH
for all separate delegate components that are utilized by the main installed component, if any.static java.lang.String
buildComponentPath(java.lang.String compRootDirPath, InstallationDescriptor insdObject)
Creates a string that should be added to the SPATH for a given installed component associated with a given installation descriptor object.static java.lang.String
buildListOfEnvVars(InstallationDescriptor insdObject)
Creates a string that contains the list of environment variables settings (in the JVM '-Dname=value' format) included in a given installation descriptor object.static java.lang.String
buildListOfNetworkParams(InstallationDescriptor insdObject)
Creates a string that contains network parameters (in the JVM '-Dname=value' format) specified in a given installation descriptor object.java.util.Properties
buildTableOfEnvVars()
BuildsProperties
table of required environment variables for the installed component, including environment variables for all separate delegate components that are utilized by the main installed component, if any.static java.util.Properties
buildTableOfEnvVars(InstallationDescriptor insdObject)
Creates aProperties
table that contains (name, value) pairs of environment variables settings for a given installation descriptor object.static java.lang.String
buildUIMAClassPath(java.lang.String uimaHomeEnv)
Creates a string that should be added to the CLASSPATH environment variable for UIMA framework.static boolean
deleteInstalledFiles(java.lang.String componentId, java.io.File parentDir, boolean includeDelegates)
Deletes all installed files for a given component in a given parent directory.static java.lang.String
extractFilesFromPEARFile(java.lang.String pearFileLocation, java.lang.String fileExt, java.io.File targetDir, boolean cleanTarget)
Extracts files with a given extension from a given PEAR file into a given target directory.protected static java.lang.String
extractFilesFromPEARFile(java.lang.String pearFileLocation, java.lang.String fileExt, java.io.File targetDir, InstallationController controller, boolean cleanTarget)
Internal implementatiton of theextractFilesFromPEARFile
method, which allows sending messages to the OUT and ERR queues.static java.lang.String
extractPEARFile(java.lang.String pearFileLocation, java.io.File installationDir, boolean cleanTarget)
Extracts all files of a given component from a given PEAR file into a given target directory.protected static java.lang.String
extractPEARFile(java.lang.String pearFileLocation, java.io.File installationDir, InstallationController controller, boolean cleanTarget)
Internal implementation of theextractPEARFile
method, which allows sending messages to the OUT and ERR queues.protected void
finalize()
Overrides standardfinalize
method.protected void
generatePackageConfigFile()
Generates/updates the PEAR configuration file setting the main component root directory, as well as root directories of all related delegate components.protected static void
generatePearSpecifier(java.lang.String mainComponentRootPath, java.lang.String mainComponentId)
generates the pearSpecifier to run the installed pear component.protected void
generateSetEnvFile()
Generates the file (batch file for Windows) containing specific environment variables that should be used to run the component.protected static java.util.Hashtable<java.lang.String,InstallationDescriptor>
getDelegateInstallationDescriptors(java.util.Hashtable<java.lang.String,java.lang.String> installationTable)
Creates aHashtable
that contains (compId, InsD) pairs for all separate delegate components specified in a given installation table.protected java.io.PrintWriter
getErrMsgWriter()
static java.lang.String
getHostIpAddress()
java.lang.String
getInstallationMsg()
protected static java.lang.String
getInstalledComponentRootPath(java.lang.String componentId, InstallationController.PackageSelector pkgSelector)
Retrieves the root directory path of a given component, installed in the local file system, by using a givenPackageSelector
input.protected java.io.PrintWriter
getOutMsgWriter()
protected static java.lang.String
getPEARFileLocation(java.lang.String componentId, InstallationController.PackageSelector pkgSelector)
Gets the PEAR file location (file path or URL) for a given component by using SITH DB a givenPackageSelector
input.java.lang.String
getVerificationMsg()
InstallationDescriptor
installComponent()
Performs installation of the specified component in the specified target directory, including all delegate components (if exist).InstallationDescriptor
installComponentDescriptors()
Performs installation of XML descriptors of the specified component in the specified target directory, including XML descriptors of all the delegate components (if exist).protected void
installDelegateComponents()
Performs installation of all separate delegate components for the specified main component.protected void
installDelegateComponentsDescriptors()
Performs installation of XML descriptors for all separate delegate components of the specified main component.static void
main(java.lang.String[] args)
Starts the application.void
removeMsgListener(MessageRouter.StdChannelListener listener)
Removes a givenMessageRouter.StdChannelListener
object from the list of standard channel listeners.void
saveInstallationDescriptorFile()
Saves modified installation descriptor file.protected void
setInstallationError(java.lang.Exception error)
Prints the stack trace of a givenException
object as the installation error message.void
setInstallationMonitor(InstallationController.InstallationMonitor monitor)
Plugs-in a given implementation of theInstallationMonitor
interface.static void
setLocalMode(boolean inLocalMode)
Switches between the 'local' and 'DB' modes, depending on a givenboolean
flag.void
setPackageSelector(InstallationController.PackageSelector selector)
Plugs-in a given implementation of thePackageSelector
interface.void
setUimaHomePath(java.lang.String uimaHomePath)
Sets a given UIMA local home directory path.protected void
setVerificationError(java.lang.Exception error)
Prints the stack trace of a givenException
object as the verification error message.void
terminate()
Terminates theMessageRouter
thread.boolean
verifyComponent()
Verifies installations of the main component, and sets appropriate component status in the SITH DB.static InstallationController.TestStatus
verifyComponentInstallation(PackageBrowser pkgBrowser)
Runs the installation test for a given installed pear component, and returns theTestStatus
object with the test results.
-
-
-
Field Detail
-
INSTALLATION_IN_PROGRESS
public static final java.lang.String INSTALLATION_IN_PROGRESS
- See Also:
- Constant Field Values
-
INSTALLATION_FAILED
public static final java.lang.String INSTALLATION_FAILED
- See Also:
- Constant Field Values
-
INSTALLATION_COMPLETED
public static final java.lang.String INSTALLATION_COMPLETED
- See Also:
- Constant Field Values
-
VERIFICATION_IN_PROGRESS
public static final java.lang.String VERIFICATION_IN_PROGRESS
- See Also:
- Constant Field Values
-
VERIFICATION_FAILED
public static final java.lang.String VERIFICATION_FAILED
- See Also:
- Constant Field Values
-
VERIFICATION_COMPLETED
public static final java.lang.String VERIFICATION_COMPLETED
- See Also:
- Constant Field Values
-
VERIFICATION_CANCELLED
public static final java.lang.String VERIFICATION_CANCELLED
- See Also:
- Constant Field Values
-
INSTALLATION_TESTER_APP
protected static final java.lang.String INSTALLATION_TESTER_APP
- See Also:
- Constant Field Values
-
PEAR_MESSAGE_RESOURCE_BUNDLE
private static final java.lang.String PEAR_MESSAGE_RESOURCE_BUNDLE
- See Also:
- Constant Field Values
-
PACKAGE_CONFIG_FILE
public static final java.lang.String PACKAGE_CONFIG_FILE
- See Also:
- Constant Field Values
-
PACKAGE_METADATA_DIR
public static final java.lang.String PACKAGE_METADATA_DIR
- See Also:
- Constant Field Values
-
PACKAGE_BIN_DIR
public static final java.lang.String PACKAGE_BIN_DIR
- See Also:
- Constant Field Values
-
PACKAGE_CONF_DIR
public static final java.lang.String PACKAGE_CONF_DIR
- See Also:
- Constant Field Values
-
PACKAGE_DATA_DIR
public static final java.lang.String PACKAGE_DATA_DIR
- See Also:
- Constant Field Values
-
PACKAGE_DESC_DIR
public static final java.lang.String PACKAGE_DESC_DIR
- See Also:
- Constant Field Values
-
PACKAGE_DOC_DIR
public static final java.lang.String PACKAGE_DOC_DIR
- See Also:
- Constant Field Values
-
PACKAGE_LIB_DIR
public static final java.lang.String PACKAGE_LIB_DIR
- See Also:
- Constant Field Values
-
PACKAGE_RESOURCES_DIR
public static final java.lang.String PACKAGE_RESOURCES_DIR
- See Also:
- Constant Field Values
-
PACKAGE_SOURCES_DIR
public static final java.lang.String PACKAGE_SOURCES_DIR
- See Also:
- Constant Field Values
-
SET_ENV_FILE
public static final java.lang.String SET_ENV_FILE
- See Also:
- Constant Field Values
-
PEAR_DESC_FILE_POSTFIX
public static final java.lang.String PEAR_DESC_FILE_POSTFIX
- See Also:
- Constant Field Values
-
UIMA_HOME_ENV
protected static final java.lang.String UIMA_HOME_ENV
- See Also:
- Constant Field Values
-
UIMA_LIB_DIR
protected static final java.lang.String UIMA_LIB_DIR
- See Also:
- Constant Field Values
-
VINCI_LIB_DIR
protected static final java.lang.String VINCI_LIB_DIR
- See Also:
- Constant Field Values
-
JAR_FILE_EXT
protected static final java.lang.String JAR_FILE_EXT
- See Also:
- Constant Field Values
-
CLASSPATH_VAR
public static final java.lang.String CLASSPATH_VAR
- See Also:
- Constant Field Values
-
PATH_VAR
protected static final java.lang.String PATH_VAR
- See Also:
- Constant Field Values
-
LOCAL_OPT
protected static final java.lang.String LOCAL_OPT
- See Also:
- Constant Field Values
-
INSTALL_IN_ROOT_OPT
protected static final java.lang.String INSTALL_IN_ROOT_OPT
- See Also:
- Constant Field Values
-
__inLocalMode
private static boolean __inLocalMode
-
__osName
private static java.lang.String __osName
-
_mainComponentId
private java.lang.String _mainComponentId
-
_installationDirPath
private java.lang.String _installationDirPath
-
_installationDir
private java.io.File _installationDir
-
_cleanInstallDir
private boolean _cleanInstallDir
-
_mainComponentRootPath
private java.lang.String _mainComponentRootPath
-
_mainComponentRoot
private java.io.File _mainComponentRoot
-
_mainPearFileLocation
private java.lang.String _mainPearFileLocation
-
_installationTable
private java.util.Hashtable<java.lang.String,java.lang.String> _installationTable
-
_installationInsDs
private java.util.Hashtable<java.lang.String,InstallationDescriptor> _installationInsDs
-
_insdObject
private InstallationDescriptor _insdObject
-
_hostIpAddress
private java.lang.String _hostIpAddress
-
_uimaHomePath
private java.lang.String _uimaHomePath
-
_installationMsg
private java.lang.String _installationMsg
-
_verificationMsg
private java.lang.String _verificationMsg
-
_msgRouter
private MessageRouter _msgRouter
-
_defaultMsgListener
private MessageRouter.StdChannelListener _defaultMsgListener
-
_packageSelector
private InstallationController.PackageSelector _packageSelector
-
_installationMonitor
private InstallationController.InstallationMonitor _installationMonitor
-
-
Constructor Detail
-
InstallationController
public InstallationController(java.lang.String componentId, java.lang.String rootDirPath)
Constructs an instance of theInstallationController
class for a given component and a given installation root directory. By default, theInstallationController
creates acomponent_id
subdirectory for the component code and resources. By default, theInstallationController
class sends all stdout and stderr messages to the default message listener, which prints them to the standard console streams.- Parameters:
componentId
- The given component ID.rootDirPath
- The given installation root directory path.
-
InstallationController
public InstallationController(java.lang.String componentId, java.lang.String rootDirPath, boolean installInRootDir)
Constructs an instance of theInstallationController
class for a given component and a given installation root directory. If theinstallInRootDir
flag istrue
, the component will be installed in the given root directory, otherwise theInstallationController
will create acomponent_id
subdirectory for the component code and resources. By default, theInstallationController
class sends all stdout and stderr messages to the default message listener, which prints them to the standard console streams.- Parameters:
componentId
- The given component ID.rootDirPath
- The given installation root directory path.installInRootDir
- Iftrue
, the component will be installed in the given root directory, otherwise it will be installed in thecomponent_id
subdirectory of the root directory. Note: the installation directory will be cleaned before the PEAR file is installed to it.
-
InstallationController
public InstallationController(java.lang.String componentId, java.lang.String rootDirPath, boolean installInRootDir, MessageRouter.StdChannelListener msgListener)
Constructs an instance of theInstallationController
class for a given component and a given installation root directory. If theinstallInRootDir
flag istrue
, the component will be installed in the given root directory, otherwise theInstallationController
will create acomponent_id
subdirectory for the component code and resources. If a given custom message listener is notnull
, theInstallationController
instance will sends all stdout and stderr messages to the given message listener, otherwise these messages are sent to the default message listener, which prints them to the standard console streams.- Parameters:
componentId
- The given component ID.rootDirPath
- The given installation root directory path.installInRootDir
- Iftrue
, the component will be installed in the given root directory, otherwise it will be installed in thecomponent_id
subdirectory of the root directory. Note: the installation directory will be cleaned before the PEAR file is installed to it.msgListener
- The given custom message listener ornull
.
-
InstallationController
protected InstallationController(java.lang.String componentId, java.lang.String rootDirPath, boolean installInRootDir, MessageRouter msgRouter, MessageRouter.StdChannelListener msgListener, boolean cleanInstallDir)
Internal constructor that creates an instance of theInstallationController
class for a given component and a given installation root directory. If theinstallInRootDir
flag istrue
, the component will be installed in the given root directory, otherwise theInstallationController
will create acomponent_id
subdirectory for the component code and resources. If a given customMessageRouter
is notnull
, the newInstallationController
instance will use the given message router, otherwise it will create a new message router object. If a given custom message listener is notnull
, theInstallationController
instance will send all stdout and stderr messages to the given message listener, otherwise these messages are sent to the default message listener, which prints them to the standard console streams.- Parameters:
componentId
- The given component ID.rootDirPath
- The given installation root directory.installInRootDir
- Iftrue
, the component will be installed in the given root directory, otherwise it will be installed in thecomponent_id
subdirectory of the root directory.msgRouter
- The given customMessageRouter
object ornull
.msgListener
- The given custom message listener object ornull
.cleanInstallDir
- Iftrue
, the target installation directory will be cleaned before the PEAR file is installed.
-
InstallationController
public InstallationController(java.lang.String componentId, java.io.File localPearFile, java.io.File rootDir)
Constructor for the 'local' mode, which specifies component ID, local PEAR file and a local root directory where the component will be installed. By default, theInstallationController
creates acomponent_id
subdirectory for the component code and resources. By default, theInstallationController
class sends all stdout and stderr messages to the default message listener, which prints them to the standard console streams.- Parameters:
componentId
- The given component ID.localPearFile
- The given local PEAR file.rootDir
- The given local root directory for installation.
-
InstallationController
public InstallationController(java.lang.String componentId, java.io.File localPearFile, java.io.File rootDir, boolean installInRootDir, boolean cleanInstallDir)
Constructor for the 'local' mode, which specifies component ID, local PEAR file and a local root directory where the component will be installed. If theinstallInRootDir
flag istrue
, the component code and resources will be installed in the specified root directory, otherwise theInstallationController
will create acomponent_id
subdirectory for the component code and resources. By default, theInstallationController
class sends all stdout and stderr messages to the default message listener, which prints them to the standard console streams.- Parameters:
componentId
- The given component ID.localPearFile
- The given local PEAR file.rootDir
- The given local root directory for installation.installInRootDir
- Iftrue
, the component will be installed in the given root directory, otherwise it will be installed in thecomponent_id
subdirectory of the root directory.cleanInstallDir
- Iftrue
, the target installation directory will be cleaned before the PEAR file is installed.
-
InstallationController
public InstallationController(java.lang.String componentId, java.io.File localPearFile, java.io.File rootDir, boolean installInRootDir)
Constructor for the 'local' mode, which specifies component ID, local PEAR file and a local root directory where the component will be installed. If theinstallInRootDir
flag istrue
, the component code and resources will be installed in the specified root directory, otherwise theInstallationController
will create acomponent_id
subdirectory for the component code and resources. By default, theInstallationController
class sends all stdout and stderr messages to the default message listener, which prints them to the standard console streams.- Parameters:
componentId
- The given component ID.localPearFile
- The given local PEAR file.rootDir
- The given local root directory for installation.installInRootDir
- Iftrue
, the component will be installed in the given root directory, otherwise it will be installed in thecomponent_id
subdirectory of the root directory. Note: the installation directory will be cleaned before the PEAR file is installed to it.
-
InstallationController
public InstallationController(java.lang.String componentId, java.io.File localPearFile, java.io.File rootDir, boolean installInRootDir, MessageRouter.StdChannelListener msgListener)
Constructor for the 'local' mode, which specifies component ID, local PEAR file and a local root directory where the component will be installed. If theinstallInRootDir
flag istrue
, the component code and resources will be installed in the specified root directory, otherwise theInstallationController
will create acomponent_id
subdirectory for the component code and resources. If the custom message listener is notnull
, theInstallationController
class sends all stdout and stderr messages to this message listener, otherwise these messages are sent to the default message listener, which prints them to the standard console streams.- Parameters:
componentId
- The given component ID.localPearFile
- The given local PEAR file.rootDir
- The given local root directory for installation.installInRootDir
- Iftrue
, the component will be installed in the given root directory, otherwise it will be installed in thecomponent_id
subdirectory of the root directory.msgListener
- The given custom message listener ornull
.
-
InstallationController
public InstallationController(java.lang.String componentId, java.io.File localPearFile, java.io.File rootDir, boolean installInRootDir, MessageRouter.StdChannelListener msgListener, boolean cleanInstallDir)
Constructor for the 'local' mode, which specifies component ID, local PEAR file and a local root directory where the component will be installed. If theinstallInRootDir
flag istrue
, the component code and resources will be installed in the specified root directory, otherwise theInstallationController
will create acomponent_id
subdirectory for the component code and resources. If the custom message listener is notnull
, theInstallationController
class sends all stdout and stderr messages to this message listener, otherwise these messages are sent to the default message listener, which prints them to the standard console streams.- Parameters:
componentId
- The given component ID.localPearFile
- The given local PEAR file.rootDir
- The given local root directory for installation.installInRootDir
- Iftrue
, the component will be installed in the given root directory, otherwise it will be installed in thecomponent_id
subdirectory of the root directory.msgListener
- The given custom message listener ornull
.cleanInstallDir
- Iftrue
, the target installation directory will be cleaned before the PEAR file is installed.
-
-
Method Detail
-
addListOfJarFiles
protected static java.lang.StringBuffer addListOfJarFiles(java.io.File libDir, java.lang.StringBuffer listBuffer) throws java.io.IOException
Appends a list of JAR files in a given lib directory, separated with the OS dependent separator (';' or ':'), to a given initialStringBuffer
object. Ifnull
StringBuffer
object is specified, creates newStringBuffer
object.- Parameters:
libDir
- The given lib directory.listBuffer
- The initialStringBuffer
object.- Returns:
- The list of JAR files in the given lib directory, appended to the given
StringBuffer
. - Throws:
java.io.IOException
- If any I/O exception occurred.
-
addToSystemEnvTable
protected static boolean addToSystemEnvTable(java.util.Properties sysEnvTable, java.lang.String localKey, java.lang.String localValue)
Adds a given local environment variable to appropriate system environment variable (before the system value). The case of the local environment variable key is ignored.- Parameters:
sysEnvTable
- The table of system environment variables.localKey
- The given local environment variable key.localValue
- The given local environment variable value.- Returns:
true
if the local value was really added,false
otherwise.
-
buildArrayOfNetworkParams
public static java.lang.String[] buildArrayOfNetworkParams(InstallationDescriptor insdObject)
Creates a string array that contains network parameters (in the JVM '-Dname=value' format) specified in a given installation descriptor object.- Parameters:
insdObject
- The given installation descriptor object.- Returns:
- The string array of network parameters in the JVM format.
-
buildComponentClassPath
public static java.lang.String buildComponentClassPath(java.lang.String compRootDirPath, InstallationDescriptor insdObject, boolean addLibDir) throws java.io.IOException
Creates a string that should be added to the CLASSPATH for a given installed component associated with a given installation descriptor object.- Parameters:
compRootDirPath
- The given root directory of the installed component.insdObject
- The given installation descriptor object.addLibDir
- Whether we should add jars from the libdir or not (true at packaging time, false at runtime).- Returns:
- The string that should be added to the CLASSPATH for the given component.
- Throws:
java.io.IOException
- If any I/O exception occurred.
-
buildComponentPath
public static java.lang.String buildComponentPath(java.lang.String compRootDirPath, InstallationDescriptor insdObject)
Creates a string that should be added to the SPATH for a given installed component associated with a given installation descriptor object.- Parameters:
compRootDirPath
- The given root directory of the installed component.insdObject
- The given installation descriptor object.- Returns:
- The string that should be added to the SPATH for the given component.
-
buildListOfEnvVars
public static java.lang.String buildListOfEnvVars(InstallationDescriptor insdObject)
Creates a string that contains the list of environment variables settings (in the JVM '-Dname=value' format) included in a given installation descriptor object.- Parameters:
insdObject
- The given installation descriptor object.- Returns:
- The string of environment variables settings in the JVM format.
-
buildListOfNetworkParams
public static java.lang.String buildListOfNetworkParams(InstallationDescriptor insdObject)
Creates a string that contains network parameters (in the JVM '-Dname=value' format) specified in a given installation descriptor object.- Parameters:
insdObject
- The given installation descriptor object.- Returns:
- The string of network parameters in the JVM format.
-
buildTableOfEnvVars
public static java.util.Properties buildTableOfEnvVars(InstallationDescriptor insdObject)
Creates aProperties
table that contains (name, value) pairs of environment variables settings for a given installation descriptor object.- Parameters:
insdObject
- The given installation descriptor object.- Returns:
- The
Properties
table that contains environment variables settings for the given installation descriptor object.
-
buildUIMAClassPath
public static java.lang.String buildUIMAClassPath(java.lang.String uimaHomeEnv)
Creates a string that should be added to the CLASSPATH environment variable for UIMA framework.- Parameters:
uimaHomeEnv
- The location of UIMA framework (UIMA_HOME environment variable value).- Returns:
- The CLASSPATH string for UIMA framework.
-
deleteInstalledFiles
public static boolean deleteInstalledFiles(java.lang.String componentId, java.io.File parentDir, boolean includeDelegates) throws java.io.IOException
Deletes all installed files for a given component in a given parent directory. If theincludeDelegates
flag istrue
, deletes also all files installed in a given parent directory for separate delegate components, specified in the main installation descriptor.- Parameters:
componentId
- The given main component ID.parentDir
- The given parent directory of the main component root directory.includeDelegates
- Indicates whether files of the specified separate delegate components should be deleted.- Returns:
true
, if the deletion operation completed successfully,false
otherwise.- Throws:
java.io.IOException
- if any I/O exception occurred.
-
extractFilesFromPEARFile
public static java.lang.String extractFilesFromPEARFile(java.lang.String pearFileLocation, java.lang.String fileExt, java.io.File targetDir, boolean cleanTarget) throws java.io.IOException
Extracts files with a given extension from a given PEAR file into a given target directory. If the given filename extension isnull
, extracts all the files from a given PEAR file. Returns the path to the new component root directory.- Parameters:
pearFileLocation
- The given PEAR file location.fileExt
- The given filename extension.targetDir
- The given target directory.cleanTarget
- If true, the target directory is cleaned before the PEAR file is installed to it.- Returns:
- The path to the new component root directory.
- Throws:
java.io.IOException
- if any I/O exception occurred.
-
extractFilesFromPEARFile
protected static java.lang.String extractFilesFromPEARFile(java.lang.String pearFileLocation, java.lang.String fileExt, java.io.File targetDir, InstallationController controller, boolean cleanTarget) throws java.io.IOException
Internal implementatiton of theextractFilesFromPEARFile
method, which allows sending messages to the OUT and ERR queues.- Parameters:
pearFileLocation
- The given PEAR file location.fileExt
- The given filename extension.targetDir
- The given target directory.controller
- The instance of theInstallationController
class that provides OUT and ERRcleanTarget
- If true, the target directory is cleaned before the PEAR file is installed to it. message routing, ornull
.- Returns:
- The path to the new component root directory.
- Throws:
java.io.IOException
- if any I/O exception occurred.
-
extractPEARFile
public static java.lang.String extractPEARFile(java.lang.String pearFileLocation, java.io.File installationDir, boolean cleanTarget) throws java.io.IOException
Extracts all files of a given component from a given PEAR file into a given target directory. Returns the path to the new component root directory.- Parameters:
pearFileLocation
- The given PEAR file location.installationDir
- The given target directory.cleanTarget
- If true, the target directory is cleaned before the PEAR file is installed to it.- Returns:
- The path to the new component root directory.
- Throws:
java.io.IOException
- if any I/O exception occurred.
-
extractPEARFile
protected static java.lang.String extractPEARFile(java.lang.String pearFileLocation, java.io.File installationDir, InstallationController controller, boolean cleanTarget) throws java.io.IOException
Internal implementation of theextractPEARFile
method, which allows sending messages to the OUT and ERR queues.- Parameters:
pearFileLocation
- The given PEAR file location.installationDir
- The given target directory.controller
- The instance of theInstallationController
class that provides OUT and ERR message routing, ornull
.cleanTarget
- If true, the target directory is cleaned before the PEAR file is installed to it.- Returns:
- The path to the new component root directory.
- Throws:
java.io.IOException
- if any I/O exception occurred.
-
getDelegateInstallationDescriptors
protected static java.util.Hashtable<java.lang.String,InstallationDescriptor> getDelegateInstallationDescriptors(java.util.Hashtable<java.lang.String,java.lang.String> installationTable) throws java.io.IOException
Creates aHashtable
that contains (compId, InsD) pairs for all separate delegate components specified in a given installation table.- Parameters:
installationTable
- The given installation table that specifies (compId, rootDirPath) pairs for all separate delegate components.- Returns:
- The
Hashtable
that contains (compId, InsD) pairs for all separate delegate components specified in the given installation table. - Throws:
java.io.IOException
- If an I/O exception occurred while loading the installation descriptor files.
-
getHostIpAddress
public static java.lang.String getHostIpAddress()
- Returns:
- The local host IP address.
-
getInstalledComponentRootPath
protected static java.lang.String getInstalledComponentRootPath(java.lang.String componentId, InstallationController.PackageSelector pkgSelector)
Retrieves the root directory path of a given component, installed in the local file system, by using a givenPackageSelector
input. If the givenPackageSelector
isnull
, the defaultPackageSelector
implementation is used.- Parameters:
componentId
- The given installed component ID.pkgSelector
- The instance of thePackageSelector
class that allows selecting root directory of the installed component in the local file system.- Returns:
- The root directory path of the given component in the local file system, or
null
, if the component is not installed.
-
getPEARFileLocation
protected static java.lang.String getPEARFileLocation(java.lang.String componentId, InstallationController.PackageSelector pkgSelector)
Gets the PEAR file location (file path or URL) for a given component by using SITH DB a givenPackageSelector
input. If the givenPackageSelector
isnull
, the defaultPackageSelector
implementation is used.- Parameters:
componentId
- The given component ID.pkgSelector
- The instance of thePackageSelector
class that allows selecting location of the given component PEAR file in the local file system, or in the network.- Returns:
- The location of the PEAR file for the given component, or
null
, if the PEAR file was not found.
-
main
public static void main(java.lang.String[] args)
Starts the application. This application expects the following JVM run-time settings:- -DUIMA_HOME=<local_uima_root_dir>
- Parameters:
args
- {-local pear_file | main_component_id} [-default] [installation_dir]
-
setLocalMode
public static void setLocalMode(boolean inLocalMode)
Switches between the 'local' and 'DB' modes, depending on a givenboolean
flag.- Parameters:
inLocalMode
- iftrue
the utility operates in the 'local' mode, otherwise it operates in the 'DB' mode.
-
verifyComponentInstallation
public static InstallationController.TestStatus verifyComponentInstallation(PackageBrowser pkgBrowser)
Runs the installation test for a given installed pear component, and returns theTestStatus
object with the test results.- Parameters:
pkgBrowser
- The given package browser object of the installed pear package.- Returns:
- The
TestStatus
object that contains the return code and possible error message of the test.
-
addMsgListener
public void addMsgListener(MessageRouter.StdChannelListener listener)
Adds a given object, implementing theMessageRouter.StdChannelListener
interface to the list of standard channel listeners.- Parameters:
listener
- The givenMessageRouter.StdChannelListener
object to be added to the list.
-
buildComponentClassPath
public java.lang.String buildComponentClassPath() throws java.io.IOException
BuildsCLASSPATH
for the installed component, includingCLASSPATH
for all separate delegate components that are utilized by the main installed component, if any.- Returns:
- The
CLASSPATH
for the installed component, ornull
, if the component has not been installed. - Throws:
java.io.IOException
- If any I/O exception occurred.
-
buildComponentPath
public java.lang.String buildComponentPath()
BuildsPATH
for the installed component, includingPATH
for all separate delegate components that are utilized by the main installed component, if any.- Returns:
- The
PATH
for the installed component, ornull
, if the component has not been installed.
-
buildTableOfEnvVars
public java.util.Properties buildTableOfEnvVars()
BuildsProperties
table of required environment variables for the installed component, including environment variables for all separate delegate components that are utilized by the main installed component, if any.- Returns:
Properties
table of required environment variables for the installed component, ornull
, if the component has not been installed.
-
finalize
protected void finalize()
Overrides standardfinalize
method.- Overrides:
finalize
in classjava.lang.Object
-
installComponent
public InstallationDescriptor installComponent()
Performs installation of the specified component in the specified target directory, including all delegate components (if exist). If the installation completed successfully, returns theInstallationDescriptor
object for the installed component. If the installation failed, returnsnull
, and sets the installation error message that can be retrieved using thegetInstallationMsg()
method.- Returns:
- The
InstallationDescriptor
object for the installed component, if the installation succeeded,null
otherwise.
-
installComponentDescriptors
public InstallationDescriptor installComponentDescriptors()
Performs installation of XML descriptors of the specified component in the specified target directory, including XML descriptors of all the delegate components (if exist). If the installation completed successfully, returns theInstallationDescriptor
object for the partially installed component. If the installation failed, returnsnull
, and sets the installation error message that can be retrieved using thegetInstallationMsg()
method.- Returns:
- The
InstallationDescriptor
object for the partially installed component, if the installation succeeded,null
otherwise.
-
installDelegateComponents
protected void installDelegateComponents()
Performs installation of all separate delegate components for the specified main component.
-
installDelegateComponentsDescriptors
protected void installDelegateComponentsDescriptors()
Performs installation of XML descriptors for all separate delegate components of the specified main component.
-
generatePearSpecifier
protected static void generatePearSpecifier(java.lang.String mainComponentRootPath, java.lang.String mainComponentId) throws java.io.IOException, org.xml.sax.SAXException
generates the pearSpecifier to run the installed pear component. The descriptor that is created has the filename <componentID>_pear.xml and is created in the main component root directory. If the file already exist, it will be overridden.- Parameters:
mainComponentRootPath
- main component root path where the pear was installed tomainComponentId
- main component ID of the installed pear file- Throws:
java.io.IOException
- if IO Exceptionorg.xml.sax.SAXException
- if SAX Exception
-
generateSetEnvFile
protected void generateSetEnvFile() throws java.io.IOException
Generates the file (batch file for Windows) containing specific environment variables that should be used to run the component.- Throws:
java.io.IOException
- if any I/O exception occurred.
-
generatePackageConfigFile
protected void generatePackageConfigFile() throws java.io.IOException
Generates/updates the PEAR configuration file setting the main component root directory, as well as root directories of all related delegate components.- Throws:
java.io.IOException
- if any I/O exception occurred.
-
getErrMsgWriter
protected java.io.PrintWriter getErrMsgWriter()
- Returns:
- Error message writer for intraprocess messaging.
-
getInstallationMsg
public java.lang.String getInstallationMsg()
- Returns:
- The installation message (error message).
-
getOutMsgWriter
protected java.io.PrintWriter getOutMsgWriter()
- Returns:
- Output message writer for intraprocess messaging.
-
getVerificationMsg
public java.lang.String getVerificationMsg()
- Returns:
- The verification message (error message).
-
removeMsgListener
public void removeMsgListener(MessageRouter.StdChannelListener listener)
Removes a givenMessageRouter.StdChannelListener
object from the list of standard channel listeners.- Parameters:
listener
- The givenMessageRouter.StdChannelListener
object to be removed from the list.
-
saveInstallationDescriptorFile
public void saveInstallationDescriptorFile() throws java.io.IOException
Saves modified installation descriptor file.- Throws:
java.io.IOException
- if any I/O exception occurred.
-
setInstallationError
protected void setInstallationError(java.lang.Exception error)
Prints the stack trace of a givenException
object as the installation error message.- Parameters:
error
- The givenException
object.
-
setInstallationMonitor
public void setInstallationMonitor(InstallationController.InstallationMonitor monitor)
Plugs-in a given implementation of theInstallationMonitor
interface.- Parameters:
monitor
- The given implementation of theInstallationMonitor
interface.
-
setPackageSelector
public void setPackageSelector(InstallationController.PackageSelector selector)
Plugs-in a given implementation of thePackageSelector
interface.- Parameters:
selector
- The given implementation of thePackageSelector
interface.
-
setVerificationError
protected void setVerificationError(java.lang.Exception error)
Prints the stack trace of a givenException
object as the verification error message.- Parameters:
error
- The givenException
object.
-
setUimaHomePath
public void setUimaHomePath(java.lang.String uimaHomePath)
Sets a given UIMA local home directory path.- Parameters:
uimaHomePath
- The given UIMA local home directory path.
-
terminate
public void terminate()
Terminates theMessageRouter
thread. This method should be called after all the processing is finished.
-
verifyComponent
public boolean verifyComponent()
Verifies installations of the main component, and sets appropriate component status in the SITH DB.- Returns:
true
if the verification completed successfully,false
otherwise.
-
-