com.mindtree.techworks.insight.reporting.jobs
Interface Job

All Superinterfaces:
java.io.Serializable

public interface Job
extends java.io.Serializable

A Job is an action that is invoked by a Verifier when it meets its criteria. A Job is called when the Insight action the Verifier is monitoring meets the criterions set in the Verifier.

Jobs may be executed in Synchronous (Blocking) or Asynchronous (Non-Blocking) mode depending on the implementation of the Job. Hence, in particular cases where the Job is invoked even before the entire Insight Action (like Filtering) is completed, may block the original action for executing the Job. When Insight is running in the interactive GUI mode, this might not only block the user requested action, but also freeze up the UI. In such scenarios, the Verifier might start the job execution in its own Thread.

A Job may support any number of JobMessages, which can be checked by calling the #getSupportedMessageTypes() or the #isMessageTypeSupported(String) methods. All Jobs must support atleast the DefaultJobMessage type.

If the #execute(JobMessage) method is called with an unsupported message type, the method would then throw an UnsupportedMessageTypeException. Any exception conditions during the execution of the Job would cause a JobExecutionException to be thrown.

All Jobs are uniquely identified by the fully qualified class name of the implementing class and should be returned in the #getUID() method.

A Job may be serialized (possibly as part of a Verifier) for later reincarnation and execution. The format for the serialized Job is mentioned in the documentation of JobPersistanceHandler. JobPersistanceHandler also handles the serialization and deserialization of the Jobs. It gets the fields to be serialized for the Job from the #getSerializableFields() methods and it deserializes the fields on the Job by calling the #setDeserializedField(String, String). All Jobs must provide a no-arguments public constructor for them to be deserialized.

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

Method Summary
 void execute(JobMessage jobMessage)
          Executes the job with the data supplied in the JobMessage passed to the method.
 java.lang.String getDisplayName()
          Returns the 'display name' of the Job to be displayed to the user.
 java.util.Map getSerializableFields()
          A Map of all fields that might be necessary for serializing the Job.
 java.lang.String[] getSupportedMessageTypes()
          Returns the array of all different message types supported by the Job.
 java.lang.String getUID()
          Returns the unique identifier for this Job - the fully qualified name of the class implementing the interface.
 boolean isMessageTypeSupported(java.lang.String messageType)
          Checks if the particular JobMessage, as identified by the message type, is supported by the Job.
 void setDeserializedField(java.lang.String fieldName, java.lang.String fieldValue)
          Sets the deserialized field in the Job.
 

Method Detail

getSupportedMessageTypes

java.lang.String[] getSupportedMessageTypes()
Returns the array of all different message types supported by the Job. The values returned would be the same as returned by the getJobMessageType() methods of each of the JobMessage types supported by the Job.

All Jobs are required to support atleast the DefaultJobMessage.

Returns:
An array of the types of the JobMessages supported.
See Also:
JobMessage.getJobMessageType()

isMessageTypeSupported

boolean isMessageTypeSupported(java.lang.String messageType)
Checks if the particular JobMessage, as identified by the message type, is supported by the Job. The value of the parameter should be the same as that returned by JobMessage#getJobMessageType().

Parameters:
messageType - The message type to check.
Returns:
true if the message type is supported or false
See Also:
JobMessage.getJobMessageType()

execute

void execute(JobMessage jobMessage)
             throws UnsupportedMessageTypeException,
                    JobExecutionException
Executes the job with the data supplied in the JobMessage passed to the method. The action performed on calling the method depends on the implementation of the Job.

Jobs may be executed asynchronously, or synchronously depending on the implementation of the Job. The method contract for a Job does not specify that. However, Verifiers calling the #executeJob(JobMessage) method while the action they are monitoring need to aware that blocking jobs may hold up (or fail) the action they are monitoring. In such scenarios, the Verifier may as an additional performance feature despatch all calls on the Jobs in a seperate asynchronous Thread.

Parameters:
jobMessage - The message used for executing the Job.
Throws:
UnsupportedMessageTypeException - If the JobMessage passed in is not supported by the Job.
JobExecutionException - If there is problem executing the Job.

getDisplayName

java.lang.String getDisplayName()
Returns the 'display name' of the Job to be displayed to the user.

Returns:
The display name of the job.

getUID

java.lang.String getUID()
Returns the unique identifier for this Job - the fully qualified name of the class implementing the interface.

Returns:
The unique identifier of the Job.

getSerializableFields

java.util.Map getSerializableFields()
A Map of all fields that might be necessary for serializing the Job. This data will later used for recreating a Job instance from the serialized data.

Unlike Verifiers the data passed in the map may not be arrays or Collections.

Returns:
A map containing all fields that need to be persisted in the Job.
See Also:
JobPersistanceHandler

setDeserializedField

void setDeserializedField(java.lang.String fieldName,
                          java.lang.String fieldValue)
Sets the deserialized field in the Job. This method would be called during the deserialization of a Job from the store.

Parameters:
fieldName - The name of the field being deserialized.
fieldValue - The value of the field being deserialized.
See Also:
JobPersistanceHandler


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