com.mindtree.techworks.insight.reporting.jobs
Class JobPersistanceHandler

java.lang.Object
  extended by com.mindtree.techworks.insight.reporting.jobs.JobPersistanceHandler

public class JobPersistanceHandler
extends java.lang.Object

Handles the serialization and deserialization of Jobs.

The fields that are to be serialized are got from the Job#getSerializableFields() method. Unlike Verifiers the Job's serialization is kept simple. No Array or Collection fields are allowed for serialization. Infact, the serialization algorithm does not even bother to check the type of the field being serialized, and simply calls the toString() method on it.

For deserialization the Job#setDeserializedField (String, String) method is used to set the field value with the name, the particular Job is supposed to set the field accordingly.

Serialized Job

The format to serialize a Job is as below:

        <job>
                <!-- The class that implements the Job interface -->
                <class>the.implementing.class.of.the.Job</class>
                <!-- The display name of the job -->
                <name>Job Display Name</name>
                <fields>
                        <field>
                                <name>field</name>
                                <value>Some Value</value>
                        </field>
                        <field>
                                <name>someOtherField</name>
                                <value>Some Other Value</value>
                        </field>
                </fields>
        </job>
 
Unlike Verifiers, the format cannot be varied by the Job implementations.

Since:
Insight 1.5
Version:
$Revision: 27 $ $Date: 2007-12-16 04:58:03 -0700 (Sun, 16 Dec 2007) $
Author:
Bindul Bhowmik
See Also:
Job

Field Summary
static java.lang.String SERIALIZED_JOB_ROOT_TAG
          The root tag of the XML serialized Job
 
Constructor Summary
JobPersistanceHandler()
           
 
Method Summary
static Job deserializeJob(java.lang.String serializedJob)
          Deserializes a job from the persistant format.
static java.lang.String serializeJob(Job job)
          Creates a serialized form of the Job.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SERIALIZED_JOB_ROOT_TAG

public static final java.lang.String SERIALIZED_JOB_ROOT_TAG
The root tag of the XML serialized Job

See Also:
Constant Field Values
Constructor Detail

JobPersistanceHandler

public JobPersistanceHandler()
Method Detail

serializeJob

public static java.lang.String serializeJob(Job job)
Creates a serialized form of the Job. For the format of the serialized Job see documentation for this class.

Parameters:
job - The job to be serialized.
Returns:
String containing the XML form of the serialized job.

deserializeJob

public static Job deserializeJob(java.lang.String serializedJob)
                          throws JobInitializationException
Deserializes a job from the persistant format.

Parameters:
serializedJob - The string representing the serialized Job
Returns:
The serialized Job
Throws:
JobInitializationException - If the Job cannot be deserialized.


Copyright © 2003-2008 MindTree Consulting Ltd.. All Rights Reserved.