Package dk.netarkivet.common.utils.batch
Class LoadableJarBatchJob
- java.lang.Object
-
- dk.netarkivet.common.utils.batch.FileBatchJob
-
- dk.netarkivet.common.utils.batch.LoadableJarBatchJob
-
- All Implemented Interfaces:
Serializable
public class LoadableJarBatchJob extends FileBatchJob
This implementation of FileBatchJob is a bridge to a jar file given as a File object. The given class will be loaded and used to perform the actions of the FileBatchJob class.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class dk.netarkivet.common.utils.batch.FileBatchJob
FileBatchJob.ExceptionOccurrence
-
-
Field Summary
-
Fields inherited from class dk.netarkivet.common.utils.batch.FileBatchJob
batchJobTimeout, exceptions, filesFailed, noOfFilesProcessed
-
-
Constructor Summary
Constructors Constructor Description LoadableJarBatchJob(String jobClass, List<String> arguments, File... jarFiles)
Load a given class from a jar file.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
finish(OutputStream os)
Finish the job.String
getLoadedJobClass()
Method for retrieving the name of the loaded class.void
initialize(OutputStream os)
Initialize the job before running.boolean
postProcess(InputStream input, OutputStream output)
Processes the concatenated result files.boolean
processFile(File file, OutputStream os)
Process one file stored in the bit archive.String
toString()
Human readable representation of this object.-
Methods inherited from class dk.netarkivet.common.utils.batch.FileBatchJob
addException, addFinishException, addInitializeException, getBatchJobTimeout, getExceptions, getFilenamePattern, getFilesFailed, getNoOfFilesProcessed, maxExceptionsReached, processOnlyFileNamed, processOnlyFilesMatching, processOnlyFilesMatching, processOnlyFilesNamed, setBatchJobTimeout
-
-
-
-
Constructor Detail
-
LoadableJarBatchJob
public LoadableJarBatchJob(String jobClass, List<String> arguments, File... jarFiles) throws ArgumentNotValid
Load a given class from a jar file.- Parameters:
jarFiles
- The jar file(s) to load from. This file may also contain other classes required by the FileBatchJob class.arguments
- The arguments for the batchjob.jobClass
- The class to load initially. This must be a subclass of FileBatchJob.- Throws:
ArgumentNotValid
- If any of the arguments are null.
-
-
Method Detail
-
initialize
public void initialize(OutputStream os)
Initialize the job before running. This is called before the processFile() calls.- Specified by:
initialize
in classFileBatchJob
- Parameters:
os
- the OutputStream to which output should be written
-
processFile
public boolean processFile(File file, OutputStream os)
Process one file stored in the bit archive.- Specified by:
processFile
in classFileBatchJob
- Parameters:
file
- the file to be processed.os
- the OutputStream to which output should be written- Returns:
- true if the file was successfully processed, false otherwise
-
finish
public void finish(OutputStream os)
Finish the job. This is called after the last process() call.- Specified by:
finish
in classFileBatchJob
- Parameters:
os
- the OutputStream to which output should be written
-
toString
public String toString()
Human readable representation of this object. Overrides FileBatchJob.toString to include name of loaded jar/class.
-
postProcess
public boolean postProcess(InputStream input, OutputStream output)
Description copied from class:FileBatchJob
Processes the concatenated result files. This is intended to be overridden by batchjobs, who they wants a different post-processing process than concatenation.- Overrides:
postProcess
in classFileBatchJob
- Parameters:
input
- The inputstream to the file containing the concatenated results.output
- The outputstream where the resulting data should be written.- Returns:
- Whether it actually does any post processing. If false is returned then the default concatenated result file is returned.
-
getLoadedJobClass
public String getLoadedJobClass()
Method for retrieving the name of the loaded class.- Returns:
- The name of the loaded class.
-
-