org.jmonks.batch.framework
Class Repository

java.lang.Object
  extended byorg.jmonks.batch.framework.Repository
Direct Known Subclasses:
Db4oRepository, JdbcRepository

public abstract class Repository
extends java.lang.Object

Repository class provides utility methods to access and use the repository maintained by the framework. The repository could be any data store from files to databases, useful to save and retrieve the data. So, there could be different implementations available of this Repository class. Framework configuration defines which implementation should be used for the framework.

This povides utility methods to log the job statistics and transfer data between the jobs and register & unregister management and monitoring information. Framework creates the repository at the startup and provides this reference through the JobContext to all the jobs. When the repository get created, it will be associated with the job beign run and all the operations will be performed with respect to that job only. The job being run will be taken as source job in all the operations.

Default framework configuration uses Db4o database as repository for its simplicity. There is a JdbcRepository implementation by using which we can use any database that can be used JDBC can be configured to use as repository. If anyone wish to use tools provided to manage and monitor the applications, consider of using the JdbcRepository implementation.

Since:
1.0
Version:
1.0
Author:
Suresh Pragada

Field Summary
protected  java.lang.String jobName
          Name of the job associated with the repository.
 
Constructor Summary
Repository()
           
 
Method Summary
abstract  boolean clearDataTransferredFromThisJob()
           This method will clear all the data that has been sent by this job to all the next jobs.
static Repository createRepository(java.lang.String jobName, FrameworkConfig.RepositoryConfig repositoryConfig, Main repositoryCreator)
           Factory method creates the repository instance based on the given repository configuration and associate this repository instance with the given job.
abstract  java.lang.Object getDataFromPreviousJob(java.lang.String dataIdentifier, java.lang.String previousJobName)
          Gets the data that has been sent by the previous job with the given data identifier.
protected abstract  void init(java.util.Map configProps)
           Method to initialize the repository implementation by using the properties defined in the framework configuration.
abstract  boolean logStatistics(JobStatistics statistics)
           Logs the job statistics given in the form of JobStatistics object in the repository for further use/references.
abstract  boolean registerJobMgmtMntrInfo(java.lang.Object registrationInfo)
           Registers the given job management and monitoring information to this job.
abstract  boolean sendDataToNextJob(java.lang.String dataIdentifier, java.lang.String nextJobName, java.lang.Object data)
           Data will be send to the specified next job and will be identified with the given identifier.
abstract  boolean unregisterJobMgmtMntrInfo()
          Unregisters the job management and monitoring information assosciated with this job.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jobName

protected java.lang.String jobName
Name of the job associated with the repository.

Constructor Detail

Repository

public Repository()
Method Detail

init

protected abstract void init(java.util.Map configProps)

Method to initialize the repository implementation by using the properties defined in the framework configuration. This method will be called immediately after instantiating the implementation class.

Parameters:
configProps - Configuration properties defined in <repository-config> element in framework configuration file.
Throws:
ConfigurationException - If required configuration properties are missing or the values are invalid.

createRepository

public static Repository createRepository(java.lang.String jobName,
                                          FrameworkConfig.RepositoryConfig repositoryConfig,
                                          Main repositoryCreator)

Factory method creates the repository instance based on the given repository configuration and associate this repository instance with the given job. So, all the repository operations performed using this repository instance will be associated with that job and taken that job as source job in all operations. This method will be called by the framework to create the repository and places the reference in JobContext object.

Parameters:
jobName - Name of the job this repository will be associated with.
repositoryConfig - Repository configuration defined in framework configuration.
repositoryCreator - Creator of the repository. This is is restrict only framework can instantiate the repository.
Throws:
java.lang.SecurityException - If an attempt is made to create the repository by other than the Main class(framework).
java.lang.IllegalArgumentException - If jobName is null to create the repository instance.
ConfigurationException - If required properties are missing in the repository configuration or the values are invalid.

sendDataToNextJob

public abstract boolean sendDataToNextJob(java.lang.String dataIdentifier,
                                          java.lang.String nextJobName,
                                          java.lang.Object data)

Data will be send to the specified next job and will be identified with the given identifier. By using different identifiers, multiple data objects can be send to the same next job. Next job should use the data identifier and this (source) job name to read the data. If there is any data with this identifier from this job to the next job, it will be overriden.

Parameters:
dataIdentifier - Identifier to be used to exchange the data between two jobs.
nextJobName - Name of the next job this data to be send.
data - Data that needs to be send as the object.
Returns:
Returns true, if it could save the data to be send to the next job.
Throws:
java.lang.IllegalArgumentException - If any one of the incoming values are null.

getDataFromPreviousJob

public abstract java.lang.Object getDataFromPreviousJob(java.lang.String dataIdentifier,
                                                        java.lang.String previousJobName)
Gets the data that has been sent by the previous job with the given data identifier.

Parameters:
dataIdentifier - Identifier tied to the data that has been sent.
previousJobName - Name of the previous job sent the data to this job.
Returns:
Returns the data, null, if it couldnt find any data from the previous job with that identifier.
Throws:
java.lang.IllegalArgumentException - If any one of the input values are null.

clearDataTransferredFromThisJob

public abstract boolean clearDataTransferredFromThisJob()

This method will clear all the data that has been sent by this job to all the next jobs.

Returns:
Returns true if it could clear all the data, false, otherwise.

registerJobMgmtMntrInfo

public abstract boolean registerJobMgmtMntrInfo(java.lang.Object registrationInfo)

Registers the given job management and monitoring information to this job. If there is any information already associated with this job, it will be overriden.

Parameters:
registrationInfo - Information to be associated with the job.
Returns:
Return true, if it could assosciate this information, false, otherwise.
Throws:
java.lang.IllegalArgumentException - If input argument registration information value is null.

unregisterJobMgmtMntrInfo

public abstract boolean unregisterJobMgmtMntrInfo()
Unregisters the job management and monitoring information assosciated with this job.

Returns:
Return true, it it could unregister the information, false, otherwise.

logStatistics

public abstract boolean logStatistics(JobStatistics statistics)

Logs the job statistics given in the form of JobStatistics object in the repository for further use/references.

Parameters:
statistics - Job Statistics object which holds all the statistics related to that job.
Returns:
Returns true if statistics can be logged into repository, false, otherwise.
Throws:
java.lang.IllegalArgumentException - If input argument job statistics is null.