org.jmonks.batch.framework.config.db
Class DBJobConfigFactory

java.lang.Object
  extended byorg.jmonks.batch.framework.config.JobConfigFactory
      extended byorg.jmonks.batch.framework.config.db.DBJobConfigFactory

public class DBJobConfigFactory
extends JobConfigFactory

DBJobConfigFactory reads the job configuration from defined database to create the configuration objects needed by the job. This factory looks for few properties in the factory config properties map to identify the database it needs to connect to. This factory looks for the job configuration in the job-config table in the database. Controller configuration will be defined in a seperate tables, and DBJobControllerConfig is responsible to read the job controller configuration from the database.

This factory looks for the properties "jdbc-driver-class-name","jdbc-url", "username" and "password" in job config factory config in framework configuration to establish the connection to read the job configuration. If any one of the properties are missing, it throws ConfigurationException. Following example shows, how it can be configured for Oracle database.

    <job-config-factory-config job-config-factory-class-name="org.jmonks.batch.framework.config.db.DBJobConfigFactory">
       <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>
    </job-config-factory-config>
 

The user specified in the configuration should have read privileges to the following database table objects.
JOB_CONFIG
JOB_LOGGING_CONFIG
BASIC_JOB_CONTROLLER_CONFIG
POOL_JOB_CONTROLLER_CONFIG

Since:
1.0
Version:
1.0
Author:
Suresh Pragada

Constructor Summary
DBJobConfigFactory()
           Do not use this constructor to instantiate DBJobConfigFactory directly.
 
Method Summary
 JobConfig getJobConfig(java.lang.String jobName)
          Returns the requested job configuration as JobConfig object.
protected  void init(java.util.Map configFactoryProps)
          This method initializes the factory by accepting the required properties as a map.
 
Methods inherited from class org.jmonks.batch.framework.config.JobConfigFactory
getJobConfigFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBJobConfigFactory

public DBJobConfigFactory()

Do not use this constructor to instantiate DBJobConfigFactory directly. Use the factory method getJobConfigFactory in JobConfigFactory class to get the config factory instance. This constructor has been provided to make sure this should be instantiable and accessible to the JobConfigFactory class.

Method Detail

init

protected void init(java.util.Map configFactoryProps)
This method initializes the factory by accepting the required properties as a map. If it doesnt find any required properties and values are not valid to initialize the factory, throws ConfigurationException with the appropriate error message.

Specified by:
init in class JobConfigFactory
Parameters:
configFactoryProps - Map consists of all the properties defined for this factory.
Throws:
ConfigurationException - If required properties are missing.

getJobConfig

public JobConfig getJobConfig(java.lang.String jobName)
Returns the requested job configuration as JobConfig object. The requested job name should be passed as a parameter. If it doesnt find the configuration of the requested jobName in the table job_config in given database, it returns null.

Specified by:
getJobConfig in class JobConfigFactory
Parameters:
jobName - Name of the job.
Returns:
Returns the job config object if found, null, otherwise.
Throws:
java.lang.IllegalArgumentException - If jobName passed as parameter is null.
java.lang.IllegalStateException - If factory is not initialized properly.