org.jmonks.batch.framework
Class JobContext

java.lang.Object
  extended byorg.jmonks.batch.framework.JobContext

public class JobContext
extends java.lang.Object

JobContext provides the references to the framework resources. All the jobs will receives the JobContext reference either in their initialize methods or process methods based on the controllers they choose to implement the job. It exposes the resources like reference to repository (by using which you can transfer the data between the jobs, saves the management & monitoring information and job running statistics), running job configuration (by using which you can refer the properties defined in the controller/processor configuration), configuration provided to invoke the job (could be either command line configuration or configuration provided to process method) and finally framework configuration. All the configuration maps accessed through this job context are unmodifiable. Framework creates the JobContext instance and passes it to the controllers.

Since:
1.0
Version:
1.0
Author:
Suresh Pragada

Field Summary
static java.lang.String CONTEXT_PARAM_JOB_CONFIG
          Constant defines the parameter name to be used in the context parameters map to pass the job configuration to create the job context.
static java.lang.String CONTEXT_PARAM_JOB_INVOKE_CONFIG
          Constant defines the parameter name to be used in the context parameters map to pass the job invoke configuration to create the job context.
static java.lang.String CONTEXT_PARAM_REPOSITORY
          Constant defines the parameter name to be used in the context parameters map to pass the repository instance to create the job context.
protected  JobConfig jobConfig
          Holds the job configuration object reference.
protected  java.util.Map jobInvokeConfig
          Holds the job invoke configuration reference.
protected  Repository repository
          Holds the framework repository reference.
 
Constructor Summary
JobContext(java.util.Map contextParams, Main contextCreator)
           Creates and Initializes the JobContext object by looking up the information in the given context parameters map.
 
Method Summary
 FrameworkConfig getFrameworkConfig()
          Gets the reference to the framework configuration.
 JobConfig getJobConfig()
          Gets the job configuration object belongs to the running job.
 java.util.Map getJobInvokeConfig()
          Gets the configuration passed in the invocation to the framework.
 java.lang.String getJobName()
          Gets the name of the job this context is associated with.
 Repository getRepository()
          Gets the repository reference configured for this framework.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTEXT_PARAM_JOB_CONFIG

public static final java.lang.String CONTEXT_PARAM_JOB_CONFIG
Constant defines the parameter name to be used in the context parameters map to pass the job configuration to create the job context.

See Also:
Constant Field Values

CONTEXT_PARAM_JOB_INVOKE_CONFIG

public static final java.lang.String CONTEXT_PARAM_JOB_INVOKE_CONFIG
Constant defines the parameter name to be used in the context parameters map to pass the job invoke configuration to create the job context.

See Also:
Constant Field Values

CONTEXT_PARAM_REPOSITORY

public static final java.lang.String CONTEXT_PARAM_REPOSITORY
Constant defines the parameter name to be used in the context parameters map to pass the repository instance to create the job context.

See Also:
Constant Field Values

jobConfig

protected JobConfig jobConfig
Holds the job configuration object reference.


repository

protected Repository repository
Holds the framework repository reference.


jobInvokeConfig

protected java.util.Map jobInvokeConfig
Holds the job invoke configuration reference.

Constructor Detail

JobContext

public JobContext(java.util.Map contextParams,
                  Main contextCreator)

Creates and Initializes the JobContext object by looking up the information in the given context parameters map. It looks for all the required parameters and then initializes the complete job context. It accepts the Main class instance context creator reference to make sure this will not be created by other than Main class.

Parameters:
contextParams - Map contains all the required information to initialize the job context.
contextCreator - Main class instance to make sure nobody can instantiate the job context.
Throws:
java.lang.SecurityException - If context creator is other than Main class.
java.lang.IllegalArgumentException - If any of the required parameters are missing in the context params.
Method Detail

getJobName

public java.lang.String getJobName()
Gets the name of the job this context is associated with.

Returns:
Returns the name of the job.

getRepository

public Repository getRepository()
Gets the repository reference configured for this framework.

Returns:
Gets the repository reference.

getJobConfig

public JobConfig getJobConfig()
Gets the job configuration object belongs to the running job.

Returns:
Returns the running job's configuration object.

getJobInvokeConfig

public java.util.Map getJobInvokeConfig()
Gets the configuration passed in the invocation to the framework. This could be command line parameters, if job is invoked from command line or config map if job is invoked through Main.process method.

Returns:
Returns the configuration provided at the invocation time.

getFrameworkConfig

public FrameworkConfig getFrameworkConfig()
Gets the reference to the framework configuration.

Returns:
Gets the framework configuration reference.