Class PMController
- java.lang.Object
-
- org.apache.uima.tools.pear.merger.PMController
-
public class PMController extends java.lang.ObjectThePMControllerclass allows to merge several input PEAR files in one PEAR file and generate an aggregate analysis engine from the components encapsulated in the input PEARs.- See Also:
PMControllerHelper,PMUimaAgent
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classPMController.PMLogFormatterThePMLogFormatterclass formats messages for the log file.
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String__aggregateNameprivate static java.io.File__aggregatePearFileprivate static boolean__logFileEnabledprivate static java.util.logging.Logger__loggerprivate static java.io.File[]__pearFilesprivate InstallationDescriptor[]_dlgInstDescsprivate java.io.File[]_inpPearFilesprivate java.lang.String_outAggCompNameprivate InstallationDescriptor_outAggInstDescprivate java.io.File_outAggPearFileprivate java.io.File_outAggRootDirprivate java.io.File[]_outDlgRootDirsprivate java.io.File_tempWorkDir(package private) static java.lang.StringAGGREGATE_NAME_ARG(package private) static java.lang.StringAGGREGATE_PEAR_FILE_ARG(package private) static java.lang.StringLOG_FILE(package private) static java.lang.StringPEAR_MERGER
-
Constructor Summary
Constructors Constructor Description PMController(java.io.File[] inpPearFiles, java.lang.String outCompName, java.io.File outPearFile)Constructor that takes a given array of input PEAR files, a given output component name (ID) and a given output PEAR file.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcleanUp()Deletes all temporary directories and files after the merging operation is completed.private longextractInputPears()Extracts all specified input PEARs to their corresponding folders inside the output root folder.static java.util.logging.LoggergetLogger()Returns the instance of the class-specificLoggerobject.private voidinitializeTaskAttributes()Intializes the 'PEAR Merger' task attributes, based on the specified input.static voidlogErrorMessage(java.lang.String message)Logs a given error message to the log file and prints it to the standard error console stream.static voidlogInfoMessage(java.lang.String message)Logs a given info message to the log file and prints it to the standard output console stream.static voidlogWarningMessage(java.lang.String message)Logs a given warning message to the log file and prints it to the standard error console stream.static voidmain(java.lang.String[] args)The command line application entry point.booleanmergePears()Merges specified input PEARs into one PEAR, which encapsulates aggregate AE that refers to input components, as delegates.private static booleanparseCommandLine(java.lang.String[] args)Parses and validates the command line and initializes static attributes.static voidsetLogFileEnabled(boolean enable)Enables/disables PM log file.
-
-
-
Field Detail
-
PEAR_MERGER
static final java.lang.String PEAR_MERGER
- See Also:
- Constant Field Values
-
LOG_FILE
static final java.lang.String LOG_FILE
- See Also:
- Constant Field Values
-
AGGREGATE_NAME_ARG
static final java.lang.String AGGREGATE_NAME_ARG
- See Also:
- Constant Field Values
-
AGGREGATE_PEAR_FILE_ARG
static final java.lang.String AGGREGATE_PEAR_FILE_ARG
- See Also:
- Constant Field Values
-
__pearFiles
private static java.io.File[] __pearFiles
-
__aggregateName
private static java.lang.String __aggregateName
-
__aggregatePearFile
private static java.io.File __aggregatePearFile
-
__logger
private static java.util.logging.Logger __logger
-
__logFileEnabled
private static boolean __logFileEnabled
-
_inpPearFiles
private java.io.File[] _inpPearFiles
-
_outAggCompName
private java.lang.String _outAggCompName
-
_outAggPearFile
private java.io.File _outAggPearFile
-
_tempWorkDir
private java.io.File _tempWorkDir
-
_outAggRootDir
private java.io.File _outAggRootDir
-
_outDlgRootDirs
private java.io.File[] _outDlgRootDirs
-
_dlgInstDescs
private InstallationDescriptor[] _dlgInstDescs
-
_outAggInstDesc
private InstallationDescriptor _outAggInstDesc
-
-
Constructor Detail
-
PMController
public PMController(java.io.File[] inpPearFiles, java.lang.String outCompName, java.io.File outPearFile) throws java.io.IOExceptionConstructor that takes a given array of input PEAR files, a given output component name (ID) and a given output PEAR file.- Parameters:
inpPearFiles- The given array of input PEAR files.outCompName- The given output component name (ID).outPearFile- The given output PEAR file.- Throws:
java.io.IOException- If any I/O exception occurred during initialization.
-
-
Method Detail
-
main
public static void main(java.lang.String[] args)
The command line application entry point. This method expects the following command line arguments:- pear_file_1 ... pear_file_n - input PEAR files (required)
- -n agg_name - a name of the output aggregate analysis engine (required)
- -f agg_pear_file - output aggregate PEAR file (optional).
If the output PEAR file is not specified, the default output PEAR file is created in the current working directory.
- Parameters:
args- pear_file_1 ... pear_file_n -n agg_name [-f agg_pear_file]
-
getLogger
public static java.util.logging.Logger getLogger()
Returns the instance of the class-specificLoggerobject.- Returns:
- The instance of the class-specific
Loggerobject.
-
logErrorMessage
public static void logErrorMessage(java.lang.String message)
Logs a given error message to the log file and prints it to the standard error console stream.- Parameters:
message- The given error message.
-
logInfoMessage
public static void logInfoMessage(java.lang.String message)
Logs a given info message to the log file and prints it to the standard output console stream.- Parameters:
message- The given info message.
-
logWarningMessage
public static void logWarningMessage(java.lang.String message)
Logs a given warning message to the log file and prints it to the standard error console stream.- Parameters:
message- The given warning message.
-
parseCommandLine
private static boolean parseCommandLine(java.lang.String[] args)
Parses and validates the command line and initializes static attributes.- Parameters:
args- The given command line arguments.- Returns:
true, if the command line arguments are valid,falseotherwise.
-
setLogFileEnabled
public static void setLogFileEnabled(boolean enable)
Enables/disables PM log file. By default, the log file is disabled.- Parameters:
enable- iftrue, the log file is enabled, otherwise it is disabled.
-
cleanUp
public void cleanUp() throws java.io.IOExceptionDeletes all temporary directories and files after the merging operation is completed.- Throws:
java.io.IOException- If an I/O exception occurred.
-
extractInputPears
private long extractInputPears() throws java.io.IOExceptionExtracts all specified input PEARs to their corresponding folders inside the output root folder. Returns the total size (bytes) of extracted files.- Returns:
- The total size of extracted files.
- Throws:
java.io.IOException- If any I/O exception occurred during extraction.
-
initializeTaskAttributes
private void initializeTaskAttributes() throws java.io.IOExceptionIntializes the 'PEAR Merger' task attributes, based on the specified input.- Throws:
java.io.IOException- If any I/O exception occurred during initialization.
-
mergePears
public boolean mergePears() throws java.io.IOExceptionMerges specified input PEARs into one PEAR, which encapsulates aggregate AE that refers to input components, as delegates. Returnstrue, if the merging operation completed successfully,falseotherwise.- Returns:
true, if the merge operation completed successfully,falseotherwise.- Throws:
java.io.IOException- If an I/O exception occurred during the merging operation.
-
-