org.jmonks.batch.framework.repository.jdbc
Class JdbcRepository

java.lang.Object
  extended byorg.jmonks.batch.framework.Repository
      extended byorg.jmonks.batch.framework.repository.jdbc.JdbcRepository

public class JdbcRepository
extends Repository

JdbcRepository implementation of repository uses any database that can be accessed by using the JDBC technology. This looks for the properties "jdbc-driver-class-name","jdbc-url", "username" and "password" in repository config in framework configuration contains the values to establish the connection to implement the Repository.
Following is the example of repository configuration.

    <repository-config repository-class-name="org.jmonks.batch.framework.repository.jdbc.JdbcRepository">
       <property key="jdbc-driver-class-name">oracle.jdbc.driver.OracleDriver</property>
       <property key="jdbc-url">jdbc:oracle:thin:@hostname:1521:instancename</property>
       <property key="username">scott</property>
       <property key="password">tiger</property>
    </repository-config>
 


The database user specified in the configuration should have update, insert & delete privileges on the following objects in the database.
JOB_DATA_TRANSFER
JOB_STATISTICS
JOB_MGMT_MNTR_INFO

Since:
1.0
Version:
1.0
Author:
Suresh Pragada

Field Summary
protected  java.util.Map jdbcConfigMap
          Map holds the jdbc configuration.
 
Fields inherited from class org.jmonks.batch.framework.Repository
jobName
 
Constructor Summary
JdbcRepository()
           
 
Method Summary
 boolean clearDataTransferredFromThisJob()
           This method will clear all the data that has been sent by this job to all the next jobs.
protected  java.lang.Object deserializeObjectFromInputStream(java.io.InputStream inputStream)
          Deserializes the given inputstream and return the object.
 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  void init(java.util.Map configProps)
           Receives the jdbc configuration in a map from the factory method and validates the given configuration is valid by making a connection to the database.
 boolean logStatistics(JobStatistics statistics)
           Logs the job statistics given in the form of JobStatistics object in the repository for further use/references.
 boolean registerJobMgmtMntrInfo(java.lang.Object registrationInfo)
           Registers the given job management and monitoring information to this job.
 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.
protected  byte[] serializeObjectIntoByteArray(java.lang.Object object)
          Serializes the given object and return that serialized data as byte array.
 boolean unregisterJobMgmtMntrInfo()
          Unregisters the job management and monitoring information assosciated with this job.
 
Methods inherited from class org.jmonks.batch.framework.Repository
createRepository
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jdbcConfigMap

protected java.util.Map jdbcConfigMap
Map holds the jdbc configuration.

Constructor Detail

JdbcRepository

public JdbcRepository()
Method Detail

init

protected void init(java.util.Map configProps)

Receives the jdbc configuration in a map from the factory method and validates the given configuration is valid by making a connection to the database.

Specified by:
init in class Repository
Parameters:
configProps - Map contains the jdbc configuration.
Throws:
ConfigurationException - If not able to get the connection by using the properties given in the map.

clearDataTransferredFromThisJob

public boolean clearDataTransferredFromThisJob()
Description copied from class: Repository

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

Specified by:
clearDataTransferredFromThisJob in class Repository
Returns:
Returns true if it could clear all the data, false, otherwise.
See Also:
org.jmonks.batch.framework.repository.Repository#clearDataTransferredToNextJob()

sendDataToNextJob

public boolean sendDataToNextJob(java.lang.String dataIdentifier,
                                 java.lang.String nextJobName,
                                 java.lang.Object data)
Description copied from class: Repository

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.

Specified by:
sendDataToNextJob in class Repository
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.
See Also:
Repository#sendDataToNextJob(String,String,Object)

getDataFromPreviousJob

public java.lang.Object getDataFromPreviousJob(java.lang.String dataIdentifier,
                                               java.lang.String previousJobName)
Description copied from class: Repository
Gets the data that has been sent by the previous job with the given data identifier.

Specified by:
getDataFromPreviousJob in class Repository
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.
See Also:
org.jmonks.batch.framework.repository.Repository#getDataFromPreviousJob(String,String)

logStatistics

public boolean logStatistics(JobStatistics statistics)
Description copied from class: Repository

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

Specified by:
logStatistics in class Repository
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.
See Also:
org.jmonks.batch.framework.repository.Repository#logStatistics(org.jmonks.batch.framework.JobStatistics)

unregisterJobMgmtMntrInfo

public boolean unregisterJobMgmtMntrInfo()
Description copied from class: Repository
Unregisters the job management and monitoring information assosciated with this job.

Specified by:
unregisterJobMgmtMntrInfo in class Repository
Returns:
Return true, it it could unregister the information, false, otherwise.
See Also:
org.jmonks.batch.framework.repository.Repository#unregisterJobMgmtMntrInfo()

registerJobMgmtMntrInfo

public boolean registerJobMgmtMntrInfo(java.lang.Object registrationInfo)
Description copied from class: Repository

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.

Specified by:
registerJobMgmtMntrInfo in class Repository
Parameters:
registrationInfo - Information to be associated with the job.
Returns:
Return true, if it could assosciate this information, false, otherwise.
See Also:
org.jmonks.batch.framework.repository.Repository#registerJobMgmtMntrInfo(Object)

serializeObjectIntoByteArray

protected byte[] serializeObjectIntoByteArray(java.lang.Object object)
Serializes the given object and return that serialized data as byte array.

Parameters:
object - Object to be serialized.
Returns:
Returns the serialized data as byte array.

deserializeObjectFromInputStream

protected java.lang.Object deserializeObjectFromInputStream(java.io.InputStream inputStream)
Deserializes the given inputstream and return the object.

Parameters:
inputStream - InputStream to be deserialized.
Returns:
Returns the deserialized object.