dk.netarkivet.common.utils.batch
Class LoadableJarBatchJob

java.lang.Object
  extended by dk.netarkivet.common.utils.batch.FileBatchJob
      extended by dk.netarkivet.common.utils.batch.LoadableJarBatchJob
All Implemented Interfaces:
java.io.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
(package private) static class LoadableJarBatchJob.ByteJarLoader
          ByteJarLoader is a ClassLoader that stores java classes in a map where the key to the map is the class name, and the value is the class stored as a byte array.
 
Nested classes/interfaces inherited from class dk.netarkivet.common.utils.batch.FileBatchJob
FileBatchJob.ExceptionOccurrence
 
Field Summary
(package private)  FileBatchJob loadedJob
          The FileBatchJob that this LoadableJarBatchJob is a wrapper for.
(package private)  org.apache.commons.logging.Log log
          The log.
 
Fields inherited from class dk.netarkivet.common.utils.batch.FileBatchJob
batchJobTimeout, exceptions, filesFailed, noOfFilesProcessed
 
Constructor Summary
LoadableJarBatchJob(java.lang.String jobClass, java.io.File... jarFiles)
          Load a given class from a jar file.
 
Method Summary
 void finish(java.io.OutputStream os)
          Finish the job.
 void initialize(java.io.OutputStream os)
          Initialize the job before running.
 boolean processFile(java.io.File file, java.io.OutputStream os)
          Process one file stored in the bit archive.
 java.lang.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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

loadedJob

transient FileBatchJob loadedJob
The FileBatchJob that this LoadableJarBatchJob is a wrapper for.


log

transient org.apache.commons.logging.Log log
The log.

Constructor Detail

LoadableJarBatchJob

public LoadableJarBatchJob(java.lang.String jobClass,
                           java.io.File... jarFiles)
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.
jobClass - The class to load initially. This must be a subclass of FileBatchJob
Method Detail

initialize

public void initialize(java.io.OutputStream os)
Initialize the job before running. This is called before the processFile() calls.

Specified by:
initialize in class FileBatchJob
Parameters:
os - the OutputStream to which output should be written

processFile

public boolean processFile(java.io.File file,
                           java.io.OutputStream os)
Process one file stored in the bit archive.

Specified by:
processFile in class FileBatchJob
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(java.io.OutputStream os)
Finish the job. This is called after the last process() call.

Specified by:
finish in class FileBatchJob
Parameters:
os - the OutputStream to which output should be written

toString

public java.lang.String toString()
Human readable representation of this object. Overrides FileBatchJob.toString to include name of loaded jar/class.

Overrides:
toString in class java.lang.Object
Returns:
a Human readable representation of this class