Package org.apache.uima.pear.tools
Class LocalInstallationAgent
- java.lang.Object
-
- org.apache.uima.pear.tools.LocalInstallationAgent
-
public class LocalInstallationAgent extends java.lang.ObjectTheLocalInstallationAgentallows localizing files of UIMA compliant components within the single PEAR structure, and verifying localized component's files using UIMA framework API.
This class may be used in the following ways:- As a standalone Java application -
java -Xmx512M -DUIMA_HOME=%UIMA_HOME% org.apache.uima.pear.tools.LocalInstallationAgent main_component_root_directory
where themain_component_root_directoryis the path to the root directory of the main component (root directory of the single PEAR structure); - As a Java object -
in this case the caller is expected to set theUIMA_HOMEvariable, using thesetUimaHomePath()method, immediately after creating a new instance of theLocalInstallationAgentclass.
Note: Some TAEs require large heap size, so the '-Xmx[heapSize]' JVM option may be needed.
Localization of component files is performed by using thelocalizeComponent()method.
Verification of localized files is performed by using theverifyLocalizedComponent()method.
The applications prints all messages to the standard output and error messages to the standard error output.
metadata/PEAR.propertiesfile for the component localization information.
Note: during the localization phase the application creates backup copies of all files in both theconfanddescdirectories, adding the extension ".$" to each backup file. If the application fails, please make sure all original files in both the directories are restored from appropriate "*.$" backup copies. - As a standalone Java application -
-
-
Field Summary
Fields Modifier and Type Field Description private InstallationDescriptor_insdObjectprivate java.io.File[]_localizedFilesprivate java.io.File_mainRootDirprivate java.lang.String_osNameprivate java.util.Properties_packageConfigprivate java.lang.String_uimaHomePathprotected static java.lang.StringBACKUP_FILE_SUFFIXprotected static java.lang.StringCOMP_ROOT_PREFIXprotected static java.lang.StringCOMP_ROOT_SUFFIXprotected static java.lang.StringMAIN_ROOT
-
Constructor Summary
Constructors Constructor Description LocalInstallationAgent(java.lang.String mainComponentRootPath)Constructs new instance of theLocalInstallationAgentclass, using a given main component root directory.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static booleancheckPackageConfig(java.util.Properties packageConfig, InstallationDescriptor insdObject)Checks that a specified PEAR configuration corresponds to a given installation descriptor.booleanlocalizeComponent()Performs localization of the component files in the 'conf' and 'desc' subdirectories of the specified main root directory, as well as localization of the installation descriptor.static voidlocalizeComponentFile(java.io.File file, InstallationDescriptor insdObject, java.util.Properties packageConfig)Performs localization of a given component file using information from a given installation descriptor and a specified PEAR configuration.protected java.io.File[]localizeComponentFiles()Performs localization of the component files in the 'conf' and 'desc' directories by replacing $main_root and $component_id$root macros with the actual path values from the PEAR configuration file.static voidlocalizeInstallationDescriptor(InstallationDescriptor insdObject, java.util.Properties packageConfig)Performs localization of a given installation descriptor object using information from a specified PEAR configuration.static voidmain(java.lang.String[] args)Starts the application.voidsetUimaHomePath(java.lang.String uimaHomePath)Sets a given UIMA local home directory path.booleanundoComponentLocalization()Restores original files in the 'conf' and 'desc' directories from the back-up copies (with extension '.$').booleanverifyLocalizedComponent()Performs verification of the localized component by running theInstallationTesterapplication.
-
-
-
Field Detail
-
BACKUP_FILE_SUFFIX
protected static final java.lang.String BACKUP_FILE_SUFFIX
- See Also:
- Constant Field Values
-
MAIN_ROOT
protected static final java.lang.String MAIN_ROOT
- See Also:
- Constant Field Values
-
COMP_ROOT_PREFIX
protected static final java.lang.String COMP_ROOT_PREFIX
- See Also:
- Constant Field Values
-
COMP_ROOT_SUFFIX
protected static final java.lang.String COMP_ROOT_SUFFIX
- See Also:
- Constant Field Values
-
_osName
private java.lang.String _osName
-
_uimaHomePath
private java.lang.String _uimaHomePath
-
_mainRootDir
private java.io.File _mainRootDir
-
_packageConfig
private java.util.Properties _packageConfig
-
_insdObject
private InstallationDescriptor _insdObject
-
_localizedFiles
private java.io.File[] _localizedFiles
-
-
Constructor Detail
-
LocalInstallationAgent
public LocalInstallationAgent(java.lang.String mainComponentRootPath)
Constructs new instance of theLocalInstallationAgentclass, using a given main component root directory.- Parameters:
mainComponentRootPath- The given main component root directory path.
-
-
Method Detail
-
checkPackageConfig
public static boolean checkPackageConfig(java.util.Properties packageConfig, InstallationDescriptor insdObject)Checks that a specified PEAR configuration corresponds to a given installation descriptor.- Parameters:
packageConfig- The specified PEAR configuration (Propertiesobject).insdObject- The given installation descriptor object.- Returns:
trueif the specified PEAR configuration corresponds to the given installation descriptor,falseotherwise.
-
localizeComponentFile
public static void localizeComponentFile(java.io.File file, InstallationDescriptor insdObject, java.util.Properties packageConfig) throws java.io.IOExceptionPerforms localization of a given component file using information from a given installation descriptor and a specified PEAR configuration.- Parameters:
file- The given component file to be localized.insdObject- The given installation descriptor object.packageConfig- The specified PEAR configuration.- Throws:
java.io.IOException- if any I/O exception occurred.
-
localizeInstallationDescriptor
public static void localizeInstallationDescriptor(InstallationDescriptor insdObject, java.util.Properties packageConfig)
Performs localization of a given installation descriptor object using information from a specified PEAR configuration.- Parameters:
insdObject- installation descriptor objectpackageConfig- pear configuration properties
-
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- main_component_root_dir
-
localizeComponent
public boolean localizeComponent() throws java.io.IOExceptionPerforms localization of the component files in the 'conf' and 'desc' subdirectories of the specified main root directory, as well as localization of the installation descriptor.- Returns:
trueif the localization process completed successfully,falseotherwise.- Throws:
java.io.IOException- if any I/O exception occurred.
-
localizeComponentFiles
protected java.io.File[] localizeComponentFiles() throws java.io.IOExceptionPerforms localization of the component files in the 'conf' and 'desc' directories by replacing $main_root and $component_id$root macros with the actual path values from the PEAR configuration file. Back-up copies of original files are stored with '.$' extension.- Returns:
- The array of localized files.
- Throws:
java.io.IOException- if any I/O exception occurred.
-
undoComponentLocalization
public boolean undoComponentLocalization() throws java.io.IOExceptionRestores original files in the 'conf' and 'desc' directories from the back-up copies (with extension '.$').- Returns:
trueif the operation completed successfully,falseotherwise.- Throws:
java.io.IOException- if any I/O exception occurred.
-
verifyLocalizedComponent
public boolean verifyLocalizedComponent() throws java.io.IOException, ResourceInitializationException, UIMAExceptionPerforms verification of the localized component by running theInstallationTesterapplication.- Returns:
trueif the verification completed successfully,falseotherwise.- Throws:
java.io.IOException- if any I/O exception occurred.ResourceInitializationException- if the specified component cannot be instantiated.UIMAException- if this exception occurred while identifying UIMA component category.- See Also:
InstallationTester
-
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.
-
-