batchserver-cvs Mailing List for Enterprise Batch Server (Page 23)
Brought to you by:
suresh_pragada
You can subscribe to this list here.
2006 |
Jan
|
Feb
(10) |
Mar
(159) |
Apr
(5) |
May
(52) |
Jun
(70) |
Jul
|
Aug
(28) |
Sep
(256) |
Oct
(38) |
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/db In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1852 Modified Files: DBBasicJobControllerConfig.java DBJobConfig.java DBJobConfigFactory.java DBJobControllerConfig.java DBPoolJobControllerConfig.java Log Message: no message Index: DBJobConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/db/DBJobConfig.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DBJobConfig.java 3 Mar 2006 04:19:56 -0000 1.1 --- DBJobConfig.java 10 Mar 2006 08:15:16 -0000 1.2 *************** *** 11,28 **** package org.jmonks.batchserver.framework.config.db; import org.jmonks.batchserver.framework.config.JobConfig; /** ! * ! * @author Suresh Pragada */ public class DBJobConfig extends JobConfig { ! ! /** Creates a new instance of DBJobConfig */ ! DBJobConfig(Object dbValueToLoadJobConfig) { } - } --- 11,86 ---- package org.jmonks.batchserver.framework.config.db; + import java.sql.Connection; + import java.sql.PreparedStatement; + import java.sql.ResultSet; + import java.sql.SQLException; + import org.jmonks.batchserver.framework.common.ErrorCode; + import org.jmonks.batchserver.framework.config.ConfigurationException; import org.jmonks.batchserver.framework.config.JobConfig; /** ! * <p> ! * DBJobConfig provides the implementation of JobConfig by reading the ! * job configuration from given connection. This reads the job configuration ! * from table "job_config". Following is the schema of that table. ! * <br><br> ! * <pre> ! * <table> ! * <tr><td><b>Column Name</b></td><td><b>Data Type</b></td></tr> ! * <tr><td>JOB_NAME</td><td>VARCHAR2(64)</td></tr> ! * <tr><td>JOB_STATUS</td><td>NUMBER</td></tr> ! * <tr><td>JOB_CONTROLLER_CLASS_NAME</td><td>VARCHAR2(256)</td></tr> ! * <tr><td>JOB_CONTROLLER_PROPS</td><td>VARCHAR2(1024)</td></tr> ! * </table> ! * </pre> ! * </p> ! * ! * @author Suresh Pragada ! * @since 1.0 ! * @version 1.0 */ public class DBJobConfig extends JobConfig { ! /** ! * Query to load the job configuration from job_config table. ! */ ! private static final String JOB_CONFIG_QUERY = "select job_status from job_config where job_name=?"; ! /** ! * Loads the job name and controller configuration into the job configuration object. ! * ! * @param jobName Name of the job to be loaded. ! * @param connection Connection to the Database. ! * ! * @throws ConfigurationException If job or controllers are not configured properly. ! */ ! DBJobConfig(String jobName,Connection connection) { + this.jobName=jobName; + try + { + PreparedStatement statement=connection.prepareStatement(DBJobConfig.JOB_CONFIG_QUERY); + statement.setString(1, jobName); + ResultSet resultSet=statement.executeQuery(); + if(resultSet.next()) + { + int status=resultSet.getInt(1); + this.jobStatus=(status==1?true:false); + + this.jobControllerConfig=DBJobControllerConfig.getJobControllerConfig(jobName, connection); + } + else + { + /** + * How can this is possible? Just now.. I could see this entry in job_config. + */ + throw new IllegalStateException("Surprisingly.. Could not find entry in job_config with job_name " + jobName); + } + } + catch(SQLException exception) + { + exception.printStackTrace(); + throw new ConfigurationException(ErrorCode.CANNOT_CREATE_DB_JOB_CONFIG); + } } } Index: DBJobConfigFactory.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/db/DBJobConfigFactory.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DBJobConfigFactory.java 3 Mar 2006 04:19:56 -0000 1.1 --- DBJobConfigFactory.java 10 Mar 2006 08:15:16 -0000 1.2 *************** *** 11,37 **** package org.jmonks.batchserver.framework.config.db; import java.util.Map; import org.jmonks.batchserver.framework.config.JobConfig; import org.jmonks.batchserver.framework.config.JobConfigFactory; /** * ! * @author Suresh Pragada */ public class DBJobConfigFactory extends JobConfigFactory { ! private Map mConfigFactoryProps=null; ! /** Creates a new instance of DBJobConfigFactory */ public DBJobConfigFactory(Map configFactoryProps) { ! } public JobConfig getJobConfig(String jobName) { /** ! * Look up job configuration in database and pass that to DBJobConfig. */ ! return new DBJobConfig(null); } } --- 11,194 ---- package org.jmonks.batchserver.framework.config.db; + import java.sql.Connection; + import java.sql.DriverManager; + import java.sql.PreparedStatement; + import java.sql.ResultSet; + import java.sql.SQLException; + import java.util.HashMap; import java.util.Map; + import org.jmonks.batchserver.framework.common.ErrorCode; + import org.jmonks.batchserver.framework.config.ConfigurationException; import org.jmonks.batchserver.framework.config.JobConfig; import org.jmonks.batchserver.framework.config.JobConfigFactory; /** + * <p> + * 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 config properties map to identify the database it needs to connect to. This + * factory looks for the job configuration in the table <b>job-config</b> 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. + * </p> + * <p> + * Following are the four properties, this factory looks in job config properties + * to connect to the database. If anyone of the property is missing, it throws + * ConfigurationException. + * <table> + * <tr><td><b>property key</b></td><td><b>property value</b></td></tr> + * <tr><td>config-db-jdbc-driver-class-name</td><td>oracle.jdbc.driver.OracleDriver</td></tr> + * <tr><td>config-db-url</td><td>jdbc:oracle:thin:@hostname:1521:instname</td></tr> + * <tr><td>config-db-username</td><td>scott</td></tr> + * <tr><td>config-db-password</td><td>tiger</td></tr> + * </table> + * These properties can be configured using <property> element in the <job-config-factory-config> element + * in the framework configuration file. + * </p> * ! * @author Suresh Pragada ! * @version 1.0 ! * @since 1.0 */ public class DBJobConfigFactory extends JobConfigFactory { ! /** ! * Property map holds the properites required by this factory. ! */ ! private Map configFactoryProps=null; ! /** ! * Constant defines the property name of jdbc driver class name. ! */ ! private static final String PROPERTY_JOB_CONFIG_JDBC_DRIVER_CLASS_NAME = "config-db-jdbc-driver-class-name"; ! /** ! * Constant defines the property name of database URL. ! */ ! private static final String PROPERTY_JOB_CONFIG_DATABASE_URL = "config-db-url"; ! /** ! * Constant defines the property name of daabase user name. ! */ ! private static final String PROPERTY_JOB_CONFIG_DATABASE_USER_NAME = "config-db-username"; ! /** ! * Constant defines the property name of database password. ! */ ! private static final String PROPERTY_JOB_CONFIG_DATABASE_PASSWORD = "config-db-password"; ! /** ! * SQL Query to pull the job configuration. ! */ ! private static final String JOB_CONFIG_QUERY = "select 1 from job_config where job_name=?"; ! /** ! * This constructor initializes the factory by accepting the required properties ! * map as a parameter to the constructor. If it doesnt find any required properties ! * and values are not valid to initialize the factory, ! * throws ConfigurationException with the appropriate error code. ! * ! * @param configFactoryProps Map consists of all the properties defined for this factory. ! * ! * @throws ConfigurationException If required properties are missing. ! */ public DBJobConfigFactory(Map configFactoryProps) { ! this.configFactoryProps=new HashMap(configFactoryProps); ! /** ! * Do the basic validation like look for the required properites and make a connection ! * and close it to make sure property values are valid. ! */ ! Connection connection=this.getConnection(); ! if(connection==null) ! throw new ConfigurationException(ErrorCode.DB_JOB_CONFIG_FACTORY_PROPERTIES_INVALID); ! else ! { ! try ! { ! connection.close(); ! } ! catch(SQLException sqle) ! { ! sqle.printStackTrace(); ! } ! } } + /** + * 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 <b>job_config</b> in given database, it returns null. + * + * @param jobName Name of the job. + * + * @return Returns the job config object if found, null, otherwise. + * + * @throws IllegalArgumentException If jobName passed as parameter is null. + * @throws IllegalStateException If factory is not initialized properly. + */ public JobConfig getJobConfig(String jobName) { + JobConfig jobConfig=null; + if(jobName==null) + throw new IllegalArgumentException("Job name cannot be null."); + + Connection connection=this.getConnection(); + if(connection==null) + throw new IllegalStateException("DBJobConfigFacotry not initialized properly. Unable to get the connection."); /** ! * Look up job configuration in table job_config and pass that information to DBJobConfig. */ ! try ! { ! PreparedStatement statement=connection.prepareStatement(DBJobConfigFactory.JOB_CONFIG_QUERY); ! statement.setString(1, jobName); ! ResultSet resultSet=statement.executeQuery(); ! if(resultSet.next()) ! { ! jobConfig=new DBJobConfig(jobName,connection); ! } ! else ! jobConfig=null; ! } ! finally ! { ! connection.close(); ! } ! ! return jobConfig; ! } ! ! /** ! * Get the required properties from the configFactoryProperties map and ! * establishes the connection. Returns null, if it cannot establish the ! * connection. ! * ! * @return Returns the database connction, null, if it cannot establish the connection. ! */ ! private Connection getConnection() ! { ! Connection connection=null; ! ! String driverClassName=(String)this.configFactoryProps.get(DBJobConfigFactory.PROPERTY_JOB_CONFIG_JDBC_DRIVER_CLASS_NAME); ! String databaseURL=(String)this.configFactoryProps.get(DBJobConfigFactory.PROPERTY_JOB_CONFIG_DATABASE_URL); ! String userName=(String)this.configFactoryProps.get(DBJobConfigFactory.PROPERTY_JOB_CONFIG_DATABASE_USER_NAME); ! String password=(String)this.configFactoryProps.get(DBJobConfigFactory.PROPERTY_JOB_CONFIG_DATABASE_PASSWORD); ! ! if(driverClassName==null || "".equals(driverClassName) || databaseURL==null || "".equals(databaseURL) || ! userName==null || "".equals(userName) || password==null || "".equals(password)) ! connection=null; ! else ! { ! try ! { ! Class.forName(driverClassName); ! connection=DriverManager.getConnection(databaseURL,userName, password); ! } ! /** ! * No need to worry about the specific exception. Either case need to return null. ! * So catching the generic one. ! */ ! catch(Exception exception) ! { ! exception.printStackTrace(); ! connection=null; ! } ! } ! return connection; } } Index: DBBasicJobControllerConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/db/DBBasicJobControllerConfig.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DBBasicJobControllerConfig.java 9 Mar 2006 04:44:24 -0000 1.2 --- DBBasicJobControllerConfig.java 10 Mar 2006 08:15:16 -0000 1.3 *************** *** 11,25 **** package org.jmonks.batchserver.framework.config.db; import org.jmonks.batchserver.framework.config.BasicJobControllerConfig; /** * ! * @author Suresh Pragada */ public class DBBasicJobControllerConfig extends BasicJobControllerConfig { ! /** Creates a new instance of DBBasicJobControllerConfig */ ! public DBBasicJobControllerConfig(Object dbValueToReadControllerConfig) { } --- 11,84 ---- package org.jmonks.batchserver.framework.config.db; + import java.sql.Connection; + import java.sql.PreparedStatement; + import java.sql.ResultSet; + import java.sql.SQLException; + import org.jmonks.batchserver.framework.common.ErrorCode; + import org.jmonks.batchserver.framework.common.FrameworkUtil; import org.jmonks.batchserver.framework.config.BasicJobControllerConfig; + import org.jmonks.batchserver.framework.config.ConfigurationException; /** + * <p> + * DBBasicJobControllerConfig loads the job controller configuration from the defined + * database. This loads the basic controller configuration from the table "basic_job_controller_config". + * Following is the schema of that table defined in the database. + * <br><br> + * <pre> + * <table> + * <tr><td><b>Column Name</b></td><td><b>Data Type</b></td></tr> + * <tr><td>JOB_NAME</td><td>VARCHAR2(64)</td></tr> + * <tr><td>BASIC_JOB_PROCESSOR_CLASS_NAME</td><td>VARCHAR2(256)</td></tr> + * <tr><td>BASIC_JOB_PROCESSOR_THREAD_CNT</td><td>NUMBER</td></tr> + * <tr><td>BASIC_JOB_PROCESSOR_PROPS</td><td>VARCHAR2(1024)</td></tr> + * </table> + * </pre> + * </p> * ! * @author Suresh Pragada ! * @version 1.0 ! * @since 1.0 */ public class DBBasicJobControllerConfig extends BasicJobControllerConfig { ! /** ! * SQL Query pulls the information basic_job_controller_config table. ! */ ! private static final String BASIC_JOB_CONTROLLER_CONFIG_QUERY = "select basic_job_processor_class_name, basic_job_processor_thread_cnt, basic_job_processor_props from basic_job_controller_config where job_name=?"; ! /** ! * Loads the basic job controller configuration from table basic_job_controller_config ! * into DBBasicJobControllerConfig object. ! * ! * @param jobName Name of the job. ! * @param connection Connection to the defined database. ! * ! * @throws ConfigurationException If controller class name or job processor name doest not found. ! */ ! public DBBasicJobControllerConfig(String jobName,Connection connection) { + + try + { + PreparedStatement statement=connection.prepareStatement(DBBasicJobControllerConfig.BASIC_JOB_CONTROLLER_CONFIG_QUERY); + statement.setString(1,jobName); + ResultSet resultSet=statement.executeQuery(); + if(resultSet.next()) + { + this.basicJobProcessorClassName=resultSet.getString(1); + this.basicJobProcessorThreadCount=resultSet.getInt(2); + String processorConfigProps=resultSet.getString(3); + if(processorConfigProps!=null) + FrameworkUtil.loadPropertiesFromStringToMap(processorConfigProps,this.basicJobProcessorConfigProps); + } + else + { + throw new ConfigurationException(ErrorCode.BASIC_JOB_CONTROLLER_CONFIG_NOT_FOUND); + } + } + catch(SQLException exception) + { + exception.printStackTrace(); + } } Index: DBPoolJobControllerConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/db/DBPoolJobControllerConfig.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DBPoolJobControllerConfig.java 9 Mar 2006 04:44:24 -0000 1.2 --- DBPoolJobControllerConfig.java 10 Mar 2006 08:15:16 -0000 1.3 *************** *** 11,14 **** --- 11,15 ---- package org.jmonks.batchserver.framework.config.db; + import java.sql.Connection; import org.jmonks.batchserver.framework.config.PoolJobControllerConfig; *************** *** 20,24 **** { /** Creates a new instance of DBPoolJobControllerConfig */ ! public DBPoolJobControllerConfig(Object dbValueToReadControllerConfig) { /** --- 21,25 ---- { /** Creates a new instance of DBPoolJobControllerConfig */ ! public DBPoolJobControllerConfig(String jobName,Connection connection) { /** Index: DBJobControllerConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/db/DBJobControllerConfig.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DBJobControllerConfig.java 3 Mar 2006 04:19:56 -0000 1.1 --- DBJobControllerConfig.java 10 Mar 2006 08:15:16 -0000 1.2 *************** *** 11,25 **** package org.jmonks.batchserver.framework.config.db; import org.jmonks.batchserver.framework.config.JobControllerConfig; /** ! * ! * @author Suresh Pragada */ public abstract class DBJobControllerConfig extends JobControllerConfig { ! public static JobControllerConfig getJobControllerConfig(Object dbValueToReadControllerConfig) { ! return null; } } --- 11,114 ---- package org.jmonks.batchserver.framework.config.db; + import java.lang.reflect.Constructor; + import java.lang.reflect.InvocationTargetException; + import java.sql.Connection; + import java.sql.PreparedStatement; + import java.sql.ResultSet; + import java.sql.SQLException; + import org.jmonks.batchserver.framework.common.ErrorCode; + import org.jmonks.batchserver.framework.config.ConfigurationException; + import org.jmonks.batchserver.framework.config.FrameworkConfig; import org.jmonks.batchserver.framework.config.JobControllerConfig; /** ! * DBJobControllerConfig responsible to build the controller specific ! * JobControllerConfig objects from the given database. ! * ! * @author Suresh Pragada ! * @version 1.0 ! * @since 1.0 */ public abstract class DBJobControllerConfig extends JobControllerConfig { ! /** ! * SQL Query retrieves the job controller class name and controller properites. ! */ ! private static final String JOB_CONFIG_QUERY = "select job_controller_class_name,job_controller_props from job_config where job_name=?"; ! /** ! * Identifier used to request the Framework controller configuration for the specific controller config for this factory. ! */ ! public static final String JOB_CONTROLLER_CONFIG_FACTORY_CLASS_ATTRIBUTE_NAME = "db-factory-config-class-name"; ! ! /** ! * <p> ! * Factory method creates and returns the controller specific controller config object ! * from the table job_config and controller specific tables. This looks for the ! * controller class name in job_config and tries to find specific controller config object for this controller ! * and defined for the DB factory in framework configuration file. ! * </p> ! * ! * @return Returns the controller specific controller config object. ! * ! * @throws ConfigurationException If controller config class name is not defined or controller specific config object cannot be found ! * in framework controller configuration. ! */ ! public static JobControllerConfig getJobControllerConfig(String jobName,Connection connection) { ! JobControllerConfig controllerConfig=null; ! ! try ! { ! PreparedStatement statement=connection.prepareStatement(DBJobControllerConfig.JOB_CONFIG_QUERY); ! statement.setString(1, jobName); ! ResultSet resultSet=statement.executeQuery(); ! if(resultSet.next()) ! { ! String controllerClassName=resultSet.getString(1); ! try ! { ! String controllerConfigClassName=FrameworkConfig.getInstance().getJobControllerConfig().getConfigClassName(controllerClassName, DBJobControllerConfig.JOB_CONTROLLER_CONFIG_FACTORY_CLASS_ATTRIBUTE_NAME); ! if(controllerConfigClassName==null) ! throw new ConfigurationException(ErrorCode.JOB_CONTROLLER_CLASS_NOT_DEFINED); ! else ! { ! Class configClass=Class.forName(controllerConfigClassName); ! Constructor constructor=configClass.getConstructor(new Class[]{String.class,Connection.class}); ! controllerConfig=(JobControllerConfig)constructor.newInstance(new Object[]{jobName,connection}); ! } ! } ! catch(InstantiationException exception) ! { ! exception.printStackTrace(); ! throw new ConfigurationException(ErrorCode.JOB_CONTROLLER_CONFIG_CLASS_NOT_VALID); ! } ! catch(NoSuchMethodException exception) ! { ! exception.printStackTrace(); ! throw new ConfigurationException(ErrorCode.JOB_CONTROLLER_CONFIG_CLASS_NOT_VALID); ! } ! catch(ClassNotFoundException exception) ! { ! exception.printStackTrace(); ! throw new ConfigurationException(ErrorCode.JOB_CONTROLLER_CONFIG_CLASS_NOT_VALID); ! } ! catch(IllegalAccessException exception) ! { ! exception.printStackTrace(); ! throw new ConfigurationException(ErrorCode.JOB_CONTROLLER_CONFIG_CLASS_NOT_VALID); ! } ! catch(InvocationTargetException exception) ! { ! exception.printStackTrace(); ! throw new ConfigurationException(ErrorCode.JOB_CONTROLLER_CONFIG_CLASS_NOT_VALID); ! } ! } ! } ! catch(SQLException exception) ! { ! exception.printStackTrace(); ! throw new ConfigurationException(ErrorCode.CANNOT_CREATE_DB_JOB_CONFIG); ! } ! return controllerConfig; } } |
From: Suresh <sur...@us...> - 2006-03-10 08:14:55
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1421 Modified Files: BasicJobControllerConfig.java framework-config.xml JobConfig.java PoolJobControllerConfig.java Log Message: no message Index: JobConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/JobConfig.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** JobConfig.java 8 Mar 2006 00:30:49 -0000 1.4 --- JobConfig.java 10 Mar 2006 08:14:51 -0000 1.5 *************** *** 30,34 **** */ protected String jobName=null; ! /** * Controller configuration of the job. --- 30,37 ---- */ protected String jobName=null; ! /** ! * Variable holds the status of the job. True stands for active and flase stands inactive. ! */ ! protected boolean jobStatus = true; /** * Controller configuration of the job. *************** *** 57,63 **** /** * <p> * Returns the string representation of JobConfig class in the format ! * <br> {JobConfig [name = value] [controllerConfig = value]} * </p> * --- 60,78 ---- /** + * Returns whether the job is active or not. + * This information will be found from the instance varaiable jobStatus. + * JobStatus of true indicates active and false indicates inactive. + * + * @return Returns true, if job is active, false otherwise. + */ + public boolean isActive() + { + return this.jobStatus; + } + + /** * <p> * Returns the string representation of JobConfig class in the format ! * <br> {JobConfig [name = value] [status = value] [controllerConfig = value]} * </p> * *************** *** 68,71 **** --- 83,87 ---- StringBuffer stringValue=new StringBuffer("{JobConfig "); stringValue.append("[name = " + this.jobName + "]"); + stringValue.append("[status = " + this.jobStatus + "]"); stringValue.append("[controllerConfig = " + this.jobControllerConfig + "]"); stringValue.append("}"); Index: framework-config.xml =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/framework-config.xml,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** framework-config.xml 9 Mar 2006 04:44:07 -0000 1.7 --- framework-config.xml 10 Mar 2006 08:14:51 -0000 1.8 *************** *** 12,17 **** <job-config-reader-config config-reader-class-name="org.jmonks.batchserver.framework.config.DBJobConfigReader"> ! <property key="config-db-jdbc-driver-class-name"></property> ! <property key="config-db-url">jdbc:oracle:thin@hostname:1521:instname</property> <property key="config-db-username">scott</property> <property key="config-db-password">tiger</property> --- 12,17 ---- <job-config-reader-config config-reader-class-name="org.jmonks.batchserver.framework.config.DBJobConfigReader"> ! <property key="config-db-jdbc-driver-class-name">oracle.jdbc.driver.OracleDriver</property> ! <property key="config-db-url">jdbc:oracle:thin:@hostname:1521:instname</property> <property key="config-db-username">scott</property> <property key="config-db-password">tiger</property> Index: BasicJobControllerConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/BasicJobControllerConfig.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** BasicJobControllerConfig.java 9 Mar 2006 04:44:07 -0000 1.4 --- BasicJobControllerConfig.java 10 Mar 2006 08:14:51 -0000 1.5 *************** *** 38,42 **** */ protected Map basicJobProcessorConfigProps=new HashMap(); ! /** * Gets the basic job processor class name. --- 38,46 ---- */ protected Map basicJobProcessorConfigProps=new HashMap(); ! ! /** ! * Holds the number of instances needs to be created. ! */ ! protected int basicJobProcessorThreadCount=1; /** * Gets the basic job processor class name. *************** *** 96,103 **** /** * <p> * Returns the string representation of BasicJobControllerConfig class in the format * <br> {BasicJobControllerConfig [controllerClassName = value] [controllerConfigProps = value] ! * [basicJobProcessorClassName = value] [basicJobProcessorConfigProps = value]} * </p> * --- 100,118 ---- /** + * Returns the number of basic job processor instances needs to be run to process this job. + * + * @return Returns the number of threads. + */ + public int getBasicJobProcessThreadCount() + { + return this.basicJobProcessorThreadCount; + } + + /** * <p> * Returns the string representation of BasicJobControllerConfig class in the format * <br> {BasicJobControllerConfig [controllerClassName = value] [controllerConfigProps = value] ! * [basicJobProcessorClassName = value] [basicJobProcessorConfigProps = value] ! * [basicJobProcessorThreadCount = value]} * </p> * *************** *** 111,114 **** --- 126,130 ---- stringValue.append("[basicJobProcessorClassName = " + this.basicJobProcessorClassName + "]"); stringValue.append("[basicJobProcessorConfigProps = " + this.basicJobProcessorConfigProps + "]"); + stringValue.append("[basicJobProcessorThreadCount = " + this.basicJobProcessorThreadCount + "]"); stringValue.append("}"); return stringValue.toString(); Index: PoolJobControllerConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/PoolJobControllerConfig.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PoolJobControllerConfig.java 9 Mar 2006 04:44:07 -0000 1.4 --- PoolJobControllerConfig.java 10 Mar 2006 08:14:51 -0000 1.5 *************** *** 49,52 **** --- 49,56 ---- protected Map poolJobProcessorConfigProps=new HashMap(); /** + * Holds the number of instances to be created. + */ + protected int poolJobProcessorThreadCount=1; + /** * Pool class name. */ *************** *** 181,184 **** --- 185,198 ---- /** + * Returns the number of instances of pool job processors needs to be created to process this job. + * + * @return Return the number of threads. + */ + public int getPoolJobProcessorThreadCount() + { + return this.poolJobProcessorThreadCount; + } + + /** * <p> * Returns the string representation of PoolJobControllerConfig class in the format *************** *** 186,190 **** * [poolJobProcessorClassName = value] [poolJobProcessorConfigProps = value] * [poolJobLoaderClassName = value] [poolJobLoaderConfigProps = value] ! * [jobPoolClassName = value] [jobPoolConfigProps = value]} * </p> * --- 200,205 ---- * [poolJobProcessorClassName = value] [poolJobProcessorConfigProps = value] * [poolJobLoaderClassName = value] [poolJobLoaderConfigProps = value] ! * [jobPoolClassName = value] [jobPoolConfigProps = value] ! * [poolJobProcessorThreadCount = value]} * </p> * *************** *** 203,206 **** --- 218,222 ---- stringValue.append("[jobPoolClassName = " + this.poolClassName + "]"); stringValue.append("[jobPoolConfigProps = " + this.poolConfigProps + "]"); + stringValue.append("[poolJobProcessorThreadCount = " + this.poolJobProcessorThreadCount + "]"); stringValue.append("}"); |
From: Suresh <sur...@us...> - 2006-03-10 08:14:24
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1092 Modified Files: ErrorCode.java FrameworkUtil.java Log Message: no message Index: FrameworkUtil.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/common/FrameworkUtil.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** FrameworkUtil.java 6 Mar 2006 23:54:55 -0000 1.5 --- FrameworkUtil.java 10 Mar 2006 08:14:21 -0000 1.6 *************** *** 2,5 **** --- 2,6 ---- import java.util.Map; + import java.util.StringTokenizer; import org.w3c.dom.Element; import org.w3c.dom.Node; *************** *** 78,80 **** --- 79,118 ---- } } + + /** + * <p> + * Loads the property elements exists in the given element to the given map. + * This looks for the <property> elements in the given element and looks + * for the value of "key" attribute and the values of <property> element + * and load them as key values pairs. + * </p> + * <p> + * Property elements should be in the following format.<br><br> + * <property key="some-config-key1">some-config-value1</property> + * </p> + * + * @param configElement DOM Element consists of <property> elements. + * @param propertyMap Map to be loaded with property key values. + * + * @throws IllegalArgumentException If either configElement or propertyMap is null. + */ + public static void loadPropertiesFromStringToMap(String propertiesString,Map propertyMap) + { + if(propertiesString==null) + throw new IllegalArgumentException("Input properties string cannot be null"); + + if(propertyMap==null) + throw new IllegalArgumentException("Input properties map propertyMap cannot be null"); + + StringTokenizer propertiesTokenizer=new StringTokenizer(propertiesString,":"); + while(propertiesTokenizer.hasMoreTokens()) + { + String property=propertiesTokenizer.nextToken(); + StringTokenizer propertyTokenizer=new StringTokenizer(property,"="); + String key=propertyTokenizer.nextToken(); + String value=propertyTokenizer.nextToken(); + propertyMap.put(key,value); + } + } + } \ No newline at end of file Index: ErrorCode.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/common/ErrorCode.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ErrorCode.java 8 Mar 2006 23:20:38 -0000 1.8 --- ErrorCode.java 10 Mar 2006 08:14:21 -0000 1.9 *************** *** 118,121 **** --- 118,125 ---- public static final ErrorCode NONE_OR_MULTIPLE_JOB_POOL_ELEMENTS_FOUND = new ErrorCode(2019,"None or multiple job pool elements found in job controller"); public static final ErrorCode POOL_JOB_POOL_CLASS_NAME_NOT_DEFINED = new ErrorCode(2020,"job-pool-class-name is not defined in job-pool element."); + + public static final ErrorCode DB_JOB_CONFIG_FACTORY_PROPERTIES_INVALID = new ErrorCode(2021,"required properties to create db job config factory are missing or values are not valid"); + public static final ErrorCode CANNOT_CREATE_DB_JOB_CONFIG = new ErrorCode(2022,"Cannot create JobConfig due sql exception"); + public static final ErrorCode BASIC_JOB_CONTROLLER_CONFIG_NOT_FOUND = new ErrorCode(2023,"basic job controller cofiguration not defined"); } |
From: Suresh <sur...@us...> - 2006-03-10 01:28:52
|
Update of /cvsroot/batchserver/batchserver/test/org/jmonks/batchserver/framework/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27723 Modified Files: ErrorCodeTest.java Log Message: no message Index: ErrorCodeTest.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/test/org/jmonks/batchserver/framework/common/ErrorCodeTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ErrorCodeTest.java 7 Mar 2006 03:41:35 -0000 1.2 --- ErrorCodeTest.java 10 Mar 2006 01:28:48 -0000 1.3 *************** *** 44,48 **** public void testGetCode() { ! ErrorCode errorCode=ErrorCode.JOB_NOT_CONFIGURED; int code=errorCode.getCode(); assertEquals(1002,code); --- 44,48 ---- public void testGetCode() { ! ErrorCode errorCode=ErrorCode.FRAMEWORK_CONFIG_FILE_NOT_FOUND; int code=errorCode.getCode(); assertEquals(1002,code); |
From: Suresh <sur...@us...> - 2006-03-10 01:28:31
|
Update of /cvsroot/batchserver/batchserver/test/org/jmonks/batchserver/framework/config In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27419 Modified Files: BasicJobControllerConfigTest.java Added Files: PoolJobControllerConfigTest.java Log Message: no message Index: BasicJobControllerConfigTest.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/test/org/jmonks/batchserver/framework/config/BasicJobControllerConfigTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BasicJobControllerConfigTest.java 9 Mar 2006 04:42:55 -0000 1.1 --- BasicJobControllerConfigTest.java 10 Mar 2006 01:28:24 -0000 1.2 *************** *** 8,15 **** package org.jmonks.batchserver.framework.config; - import junit.framework.*; import java.util.HashMap; - import java.util.Iterator; import java.util.Map; /** --- 8,15 ---- package org.jmonks.batchserver.framework.config; import java.util.HashMap; import java.util.Map; + import junit.framework.*; + /** *************** *** 40,75 **** /** ! * Test of getBasicJobProcessorClassName method, of class org.jmonks.batchserver.framework.config.BasicJobControllerConfig. */ public void testGetBasicJobProcessorClassName() { } /** ! * Test of getBasicJobProcessorConfigProperties method, of class org.jmonks.batchserver.framework.config.BasicJobControllerConfig. */ public void testGetBasicJobProcessorConfigProperties() { } /** ! * Test of getJobControllerConfigPropertyPrefix method, of class org.jmonks.batchserver.framework.config.BasicJobControllerConfig. */ public void testGetJobControllerConfigPropertyPrefix() { } /** ! * Test of overrideConfigProperties method, of class org.jmonks.batchserver.framework.config.BasicJobControllerConfig. */ public void testOverrideConfigProperties() { - } - /** - * Test of toString method, of class org.jmonks.batchserver.framework.config.BasicJobControllerConfig. - */ - public void testToString() - { } --- 40,106 ---- /** ! * Test to make sure that controller config never returns null. */ public void testGetBasicJobProcessorClassName() { + FrameworkConfig frameworkConfig=FrameworkConfig.getInstance(); + assertNotNull(frameworkConfig); + FrameworkConfig.JobConfigFactoryConfig factoryConfig=frameworkConfig.getJobConfigFactoryConfig(); + assertNotNull(factoryConfig); + JobConfigFactory factory=JobConfigFactory.getJobConfigFactory(factoryConfig); + assertNotNull(factory); + JobConfig jobConfig=factory.getJobConfig("process_file_xyz"); + assertNotNull(jobConfig); + BasicJobControllerConfig controllerConfig=(BasicJobControllerConfig)jobConfig.getJobControllerConfig(); + assertNotNull(controllerConfig); + String jobProcessorName=controllerConfig.getBasicJobProcessorClassName(); + assertNotNull(jobProcessorName); } /** ! * Test to make sure that basic job processor config properties are not null. */ public void testGetBasicJobProcessorConfigProperties() { + FrameworkConfig frameworkConfig=FrameworkConfig.getInstance(); + assertNotNull(frameworkConfig); + FrameworkConfig.JobConfigFactoryConfig factoryConfig=frameworkConfig.getJobConfigFactoryConfig(); + assertNotNull(factoryConfig); + JobConfigFactory factory=JobConfigFactory.getJobConfigFactory(factoryConfig); + assertNotNull(factory); + JobConfig jobConfig=factory.getJobConfig("process_file_xyz"); + assertNotNull(jobConfig); + BasicJobControllerConfig controllerConfig=(BasicJobControllerConfig)jobConfig.getJobControllerConfig(); + assertNotNull(controllerConfig); + Map configProps=controllerConfig.getBasicJobProcessorConfigProperties(); + assertNotNull(configProps); } /** ! * Test case to make get prefix is not returning any null prefix. */ public void testGetJobControllerConfigPropertyPrefix() { + FrameworkConfig frameworkConfig=FrameworkConfig.getInstance(); + assertNotNull(frameworkConfig); + FrameworkConfig.JobConfigFactoryConfig factoryConfig=frameworkConfig.getJobConfigFactoryConfig(); + assertNotNull(factoryConfig); + JobConfigFactory factory=JobConfigFactory.getJobConfigFactory(factoryConfig); + assertNotNull(factory); + JobConfig jobConfig=factory.getJobConfig("process_file_xyz"); + assertNotNull(jobConfig); + BasicJobControllerConfig controllerConfig=(BasicJobControllerConfig)jobConfig.getJobControllerConfig(); + assertNotNull(controllerConfig); + String prefix=controllerConfig.getJobControllerConfigPropertyPrefix(); + assertNotNull(prefix); + assertTrue(!"".equals(prefix)); } /** ! * Test to make sure that properties being overriden. */ public void testOverrideConfigProperties() { } --- NEW FILE: PoolJobControllerConfigTest.java --- /* * PoolJobControllerConfigTest.java * JUnit based test * * Created on March 9, 2006, 6:59 PM */ package org.jmonks.batchserver.framework.config; import junit.framework.*; import java.util.HashMap; import java.util.Iterator; import java.util.Map; /** * Test cases to test PoolJobControllerConfig class. * @author Suresh Pragada */ public class PoolJobControllerConfigTest extends TestCase { public PoolJobControllerConfigTest(String testName) { super(testName); } protected void setUp() throws Exception { } protected void tearDown() throws Exception { } public static Test suite() { TestSuite suite = new TestSuite(PoolJobControllerConfigTest.class); return suite; } /** * Test to make sure that it is not returning null loader class name. */ public void testGetPoolJobLoaderClassName() { FrameworkConfig frameworkConfig=FrameworkConfig.getInstance(); assertNotNull(frameworkConfig); FrameworkConfig.JobConfigFactoryConfig factoryConfig=frameworkConfig.getJobConfigFactoryConfig(); assertNotNull(factoryConfig); JobConfigFactory factory=JobConfigFactory.getJobConfigFactory(factoryConfig); assertNotNull(factory); JobConfig jobConfig=factory.getJobConfig("process_file_abc"); assertNotNull(jobConfig); PoolJobControllerConfig controllerConfig=(PoolJobControllerConfig)jobConfig.getJobControllerConfig(); assertNotNull(controllerConfig); String loaderClassName=controllerConfig.getPoolJobLoaderClassName(); assertNotNull(loaderClassName); } /** * Test to make sure loader properties is not return null map. */ public void testGetPoolJobLoaderConfigProperties() { FrameworkConfig frameworkConfig=FrameworkConfig.getInstance(); assertNotNull(frameworkConfig); FrameworkConfig.JobConfigFactoryConfig factoryConfig=frameworkConfig.getJobConfigFactoryConfig(); assertNotNull(factoryConfig); JobConfigFactory factory=JobConfigFactory.getJobConfigFactory(factoryConfig); assertNotNull(factory); JobConfig jobConfig=factory.getJobConfig("process_file_abc"); assertNotNull(jobConfig); PoolJobControllerConfig controllerConfig=(PoolJobControllerConfig)jobConfig.getJobControllerConfig(); assertNotNull(controllerConfig); Map configProps=controllerConfig.getPoolJobLoaderConfigProperties(); assertNotNull(configProps); } /** * Test to make sure that processor classname is not null. */ public void testGetPoolJobProcessorClassName() { FrameworkConfig frameworkConfig=FrameworkConfig.getInstance(); assertNotNull(frameworkConfig); FrameworkConfig.JobConfigFactoryConfig factoryConfig=frameworkConfig.getJobConfigFactoryConfig(); assertNotNull(factoryConfig); JobConfigFactory factory=JobConfigFactory.getJobConfigFactory(factoryConfig); assertNotNull(factory); JobConfig jobConfig=factory.getJobConfig("process_file_abc"); assertNotNull(jobConfig); PoolJobControllerConfig controllerConfig=(PoolJobControllerConfig)jobConfig.getJobControllerConfig(); assertNotNull(controllerConfig); String processorClassName=controllerConfig.getPoolJobProcessorClassName(); assertNotNull(processorClassName); } /** * Test to make sure that it wont return null properties. */ public void testGetPoolJobProcessorConfigProperties() { FrameworkConfig frameworkConfig=FrameworkConfig.getInstance(); assertNotNull(frameworkConfig); FrameworkConfig.JobConfigFactoryConfig factoryConfig=frameworkConfig.getJobConfigFactoryConfig(); assertNotNull(factoryConfig); JobConfigFactory factory=JobConfigFactory.getJobConfigFactory(factoryConfig); assertNotNull(factory); JobConfig jobConfig=factory.getJobConfig("process_file_abc"); assertNotNull(jobConfig); PoolJobControllerConfig controllerConfig=(PoolJobControllerConfig)jobConfig.getJobControllerConfig(); assertNotNull(controllerConfig); Map configProps=controllerConfig.getPoolJobProcessorConfigProperties(); assertNotNull(configProps); } /** * Test to make sure, it doesnt return null pool class name. */ public void testGetPoolClassName() { FrameworkConfig frameworkConfig=FrameworkConfig.getInstance(); assertNotNull(frameworkConfig); FrameworkConfig.JobConfigFactoryConfig factoryConfig=frameworkConfig.getJobConfigFactoryConfig(); assertNotNull(factoryConfig); JobConfigFactory factory=JobConfigFactory.getJobConfigFactory(factoryConfig); assertNotNull(factory); JobConfig jobConfig=factory.getJobConfig("process_file_abc"); assertNotNull(jobConfig); PoolJobControllerConfig controllerConfig=(PoolJobControllerConfig)jobConfig.getJobControllerConfig(); assertNotNull(controllerConfig); String poolClassName=controllerConfig.getPoolClassName(); assertNotNull(poolClassName); } /** * Test to make sure pool config properities will not be null. */ public void testGetPoolConfigProperties() { FrameworkConfig frameworkConfig=FrameworkConfig.getInstance(); assertNotNull(frameworkConfig); FrameworkConfig.JobConfigFactoryConfig factoryConfig=frameworkConfig.getJobConfigFactoryConfig(); assertNotNull(factoryConfig); JobConfigFactory factory=JobConfigFactory.getJobConfigFactory(factoryConfig); assertNotNull(factory); JobConfig jobConfig=factory.getJobConfig("process_file_abc"); assertNotNull(jobConfig); PoolJobControllerConfig controllerConfig=(PoolJobControllerConfig)jobConfig.getJobControllerConfig(); assertNotNull(controllerConfig); Map configProps=controllerConfig.getPoolConfigProperties(); assertNotNull(configProps); } /** * Test to make sure prefix will not be null. */ public void testGetJobControllerConfigPropertyPrefix() { FrameworkConfig frameworkConfig=FrameworkConfig.getInstance(); assertNotNull(frameworkConfig); FrameworkConfig.JobConfigFactoryConfig factoryConfig=frameworkConfig.getJobConfigFactoryConfig(); assertNotNull(factoryConfig); JobConfigFactory factory=JobConfigFactory.getJobConfigFactory(factoryConfig); assertNotNull(factory); JobConfig jobConfig=factory.getJobConfig("process_file_abc"); assertNotNull(jobConfig); PoolJobControllerConfig controllerConfig=(PoolJobControllerConfig)jobConfig.getJobControllerConfig(); assertNotNull(controllerConfig); String prefix=controllerConfig.getJobControllerConfigPropertyPrefix(); assertNotNull(prefix); assertTrue(!"".equals(prefix)); } /** * Test to make sure the new properties will be overriden. */ public void testOverrideConfigProperties() { } } |
From: Suresh <sur...@us...> - 2006-03-10 01:26:58
|
Update of /cvsroot/batchserver/batchserver/test/org/jmonks/batchserver/framework/config/xml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26322 Removed Files: XMLPoolJobControllerConfigTest.java Log Message: no message --- XMLPoolJobControllerConfigTest.java DELETED --- |
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/xml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9644 Modified Files: XMLBasicJobControllerConfig.java XMLJobConfigFactory.java XMLPoolJobControllerConfig.java Added Files: batch-config.xml Log Message: no message Index: XMLBasicJobControllerConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/xml/XMLBasicJobControllerConfig.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** XMLBasicJobControllerConfig.java 8 Mar 2006 23:21:13 -0000 1.3 --- XMLBasicJobControllerConfig.java 9 Mar 2006 04:45:08 -0000 1.4 *************** *** 54,58 **** * @throws ConfigurationException If controller class name or job processor name doest not found. */ ! XMLBasicJobControllerConfig(Element controllerConfigElement) { this.jobControllerClassName=controllerConfigElement.getAttribute(XMLJobControllerConfig.JOB_CONTROLLER_CLASS_ATTRIBUTE_NAME); --- 54,58 ---- * @throws ConfigurationException If controller class name or job processor name doest not found. */ ! public XMLBasicJobControllerConfig(Element controllerConfigElement) { this.jobControllerClassName=controllerConfigElement.getAttribute(XMLJobControllerConfig.JOB_CONTROLLER_CLASS_ATTRIBUTE_NAME); Index: XMLPoolJobControllerConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/xml/XMLPoolJobControllerConfig.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** XMLPoolJobControllerConfig.java 8 Mar 2006 23:21:14 -0000 1.3 --- XMLPoolJobControllerConfig.java 9 Mar 2006 04:45:08 -0000 1.4 *************** *** 28,32 **** * <property key="pool-job-loader-key1">loader-value1</property> * </pool-job-loader> ! * <pool-job-processor pool-job-processor-class-name="com.mycompany.batch.processfileabc.AbcJobLoader" thread-count="1"> * <property key="pool-job-processor-key1">processor-value1</property> * </pool-job-processor> --- 28,32 ---- * <property key="pool-job-loader-key1">loader-value1</property> * </pool-job-loader> ! * <pool-job-processor pool-job-processor-class-name="com.mycompany.batch.processfileabc.AbcJobProcessor" thread-count="1"> * <property key="pool-job-processor-key1">processor-value1</property> * </pool-job-processor> *************** *** 76,80 **** * @throws ConfigurationException If controller class name not defined or required controller properties missing. */ ! XMLPoolJobControllerConfig(Element controllerConfigElement) { this.jobControllerClassName=controllerConfigElement.getAttribute(XMLJobControllerConfig.JOB_CONTROLLER_CLASS_ATTRIBUTE_NAME); --- 76,80 ---- * @throws ConfigurationException If controller class name not defined or required controller properties missing. */ ! public XMLPoolJobControllerConfig(Element controllerConfigElement) { this.jobControllerClassName=controllerConfigElement.getAttribute(XMLJobControllerConfig.JOB_CONTROLLER_CLASS_ATTRIBUTE_NAME); *************** *** 92,96 **** Element xmlPoolJobLoaderElement=(Element)xmlPoolJobLoaderNodeList.item(0); this.poolJobLoaderClassName=xmlPoolJobLoaderElement.getAttribute(XMLPoolJobControllerConfig.POOL_JOB_LOADER_CLASS_ATTRIBUTE_NAME); ! if(this.poolJobProcessorClassName==null) throw new ConfigurationException(ErrorCode.POOL_JOB_LOADER_CLASS_NAME_NOT_DEFINED); else --- 92,96 ---- Element xmlPoolJobLoaderElement=(Element)xmlPoolJobLoaderNodeList.item(0); this.poolJobLoaderClassName=xmlPoolJobLoaderElement.getAttribute(XMLPoolJobControllerConfig.POOL_JOB_LOADER_CLASS_ATTRIBUTE_NAME); ! if(this.poolJobLoaderClassName==null) throw new ConfigurationException(ErrorCode.POOL_JOB_LOADER_CLASS_NAME_NOT_DEFINED); else --- NEW FILE: batch-config.xml --- <?xml version="1.0" encoding="UTF-8"?> <batch-config> <job-config job-name="process_file_abc"> <job-controller job-controller-class-name="org.jmonks.batchserver.framework.controller.pool.PoolJobController"> <pool-job-loader pool-job-loader-class-name="com.mycompany.batch.processfileabc.AbcJobLoader"> <property key="pool-job-loader-key1">loader-value1</property> </pool-job-loader> <pool-job-processor pool-job-processor-class-name="com.mycompany.batch.processfileabc.AbcJobProcessor" thread-count="1"> <property key="pool-job-processor-key1">processor-value1</property> </pool-job-processor> <job-pool job-pool-class-name="org.jmonks.batchserver.framework.controller.pool.DefaultJobPool"> <property key="job-pool-size">50000</property> </job-pool> <property key="pool-job-controller-restart">true</property> </job-controller> </job-config> <job-config job-name="process_file_xyz"> <job-controller job-controller-class-name="org.jmonks.batchserver.framework.controller.basic.BasicJobController"> <basic-job-processor basic-job-processor-class-name="com.mycompany.batch.processfilexyz.XyzProcessor"> <property key="basic-job-processor-key1">processor-value1</property> </basic-job-processor> <property key="basic-job-controller-restart">true</property> </job-controller> </job-config> </batch-config> Index: XMLJobConfigFactory.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/xml/XMLJobConfigFactory.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** XMLJobConfigFactory.java 8 Mar 2006 00:31:12 -0000 1.3 --- XMLJobConfigFactory.java 9 Mar 2006 04:45:08 -0000 1.4 *************** *** 121,125 **** * If we dont find this file on classpath, throw configuration exception. */ ! InputStream inputStream=XMLJobConfigFactory.class.getClassLoader().getResourceAsStream(classpathLocation); if(inputStream==null) throw new ConfigurationException(ErrorCode.XML_JOB_CONFIG_FACTORY_INVALID_CLASSPATH_LOCATION); --- 121,125 ---- * If we dont find this file on classpath, throw configuration exception. */ ! InputStream inputStream=XMLJobConfigFactory.class.getResourceAsStream(classpathLocation); if(inputStream==null) throw new ConfigurationException(ErrorCode.XML_JOB_CONFIG_FACTORY_INVALID_CLASSPATH_LOCATION); |
From: Suresh <sur...@us...> - 2006-03-09 04:44:28
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/db In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9308 Modified Files: DBBasicJobControllerConfig.java DBPoolJobControllerConfig.java Log Message: no message Index: DBBasicJobControllerConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/db/DBBasicJobControllerConfig.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DBBasicJobControllerConfig.java 3 Mar 2006 04:19:56 -0000 1.1 --- DBBasicJobControllerConfig.java 9 Mar 2006 04:44:24 -0000 1.2 *************** *** 20,24 **** { /** Creates a new instance of DBBasicJobControllerConfig */ ! DBBasicJobControllerConfig(Object dbValueToReadControllerConfig) { } --- 20,24 ---- { /** Creates a new instance of DBBasicJobControllerConfig */ ! public DBBasicJobControllerConfig(Object dbValueToReadControllerConfig) { } Index: DBPoolJobControllerConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/db/DBPoolJobControllerConfig.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DBPoolJobControllerConfig.java 3 Mar 2006 04:19:56 -0000 1.1 --- DBPoolJobControllerConfig.java 9 Mar 2006 04:44:24 -0000 1.2 *************** *** 20,24 **** { /** Creates a new instance of DBPoolJobControllerConfig */ ! DBPoolJobControllerConfig(Object dbValueToReadControllerConfig) { /** --- 20,24 ---- { /** Creates a new instance of DBPoolJobControllerConfig */ ! public DBPoolJobControllerConfig(Object dbValueToReadControllerConfig) { /** |
From: Suresh <sur...@us...> - 2006-03-09 04:44:10
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9186 Modified Files: BasicJobControllerConfig.java framework-config.xml FrameworkConfig.java JobControllerConfig.java PoolJobControllerConfig.java Removed Files: batch-config.xml Log Message: no message Index: BasicJobControllerConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/BasicJobControllerConfig.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** BasicJobControllerConfig.java 8 Mar 2006 23:20:57 -0000 1.3 --- BasicJobControllerConfig.java 9 Mar 2006 04:44:07 -0000 1.4 *************** *** 11,14 **** --- 11,15 ---- package org.jmonks.batchserver.framework.config; + import java.util.HashMap; import java.util.Iterator; import java.util.Map; *************** *** 36,40 **** * Map contains the properties required by the basic job processor. */ ! protected Map basicJobProcessorConfigProps=null; /** --- 37,41 ---- * Map contains the properties required by the basic job processor. */ ! protected Map basicJobProcessorConfigProps=new HashMap(); /** --- batch-config.xml DELETED --- Index: FrameworkConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/FrameworkConfig.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** FrameworkConfig.java 8 Mar 2006 05:18:55 -0000 1.5 --- FrameworkConfig.java 9 Mar 2006 04:44:07 -0000 1.6 *************** *** 689,693 **** * Skip the controller-class-name attribute here. */ ! if(!controllerClassName.equals(attribName)) { controllerPropertyMap.put(attribName,controllerAttribute.getNodeValue()); --- 689,693 ---- * Skip the controller-class-name attribute here. */ ! if(!JobControllerConfig.JOB_CONTROLLER_CLASS_ATTRIB_NAME.equals(attribName)) { controllerPropertyMap.put(attribName,controllerAttribute.getNodeValue()); Index: framework-config.xml =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/framework-config.xml,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** framework-config.xml 8 Mar 2006 05:18:55 -0000 1.6 --- framework-config.xml 9 Mar 2006 04:44:07 -0000 1.7 *************** *** 1,5 **** <framework-config> <job-config-factory-config job-config-factory-class-name="org.jmonks.batchserver.framework.config.xml.XMLJobConfigFactory"> ! <property key="job-config-file-absolute-location">/batchserver/config/batch-config.xml</property> <!-- Following is the another way to configure the XML Job configuration. --- 1,6 ---- <framework-config> <job-config-factory-config job-config-factory-class-name="org.jmonks.batchserver.framework.config.xml.XMLJobConfigFactory"> ! <!-- <property key="job-config-file-absolute-location">/batchserver/batch-config.xml</property> --> ! <property key="job-config-file-classpath-location">batch-config.xml</property> <!-- Following is the another way to configure the XML Job configuration. *************** *** 7,18 **** --> </job-config-factory-config> - <repository-config repository-class-name="org.jmonks.batchserver.framework.DefaultRepository"> - <property key="repository-location">/batchserver/repository</property> - <property key="repository-filename">batchserver_repository.db</property> - </repository-config> - <logging-config logging-direcotry="/batchserver/logs" logging-level="DEBUG" job-base-package-name="com.mycompany.batch"/> - <mgmt-mntr-config mgmt-mntr-class-name="org.jmonks.batchserver.framework.mgmtmntr.DefaultMgmtMntrManager"> - <property key="port-range">15000-20000</property> - </mgmt-mntr-config> <!-- Following is the sample configuration to read the job configuration from the database. --- 8,11 ---- *************** *** 24,35 **** <property key="config-db-password">tiger</property> </job-config-reader-config> ! --> <job-controller-config> <job-controller controller-class-name="org.jmonks.batchserver.framework.controller.pool.PoolJobController" ! xml-factory-config-class-name="org.jmonks.batchserver.framework.config.xml.XMLPoolJobController" ! db-factory-config-class-name="org.jmonks.batchserver.framework.config.xml.DBPoolJobController"/> ! <job-controller controller-class-name="org.jmonks.batchserver.framework.controller.pool.BasicJobController" ! xml-factory-config-class-name="org.jmonks.batchserver.framework.config.xml.XMLBasicJobController" ! db-factory-config-class-name="org.jmonks.batchserver.framework.config.xml.DBBasicJobController"/> </job-controller-config> </framework-config> \ No newline at end of file --- 17,36 ---- <property key="config-db-password">tiger</property> </job-config-reader-config> ! --> ! <repository-config repository-class-name="org.jmonks.batchserver.framework.DefaultRepository"> ! <property key="repository-location">/batchserver/repository</property> ! <property key="repository-filename">batchserver_repository.db</property> ! </repository-config> ! <logging-config logging-direcotry="/batchserver/logs" logging-level="DEBUG" job-base-package-name="com.mycompany.batch"/> ! <mgmt-mntr-config mgmt-mntr-class-name="org.jmonks.batchserver.framework.mgmtmntr.DefaultMgmtMntrManager"> ! <property key="port-range">15000-20000</property> ! </mgmt-mntr-config> <job-controller-config> <job-controller controller-class-name="org.jmonks.batchserver.framework.controller.pool.PoolJobController" ! xml-factory-config-class-name="org.jmonks.batchserver.framework.config.xml.XMLPoolJobControllerConfig" ! db-factory-config-class-name="org.jmonks.batchserver.framework.config.db.DBPoolJobControllerConfig"/> ! <job-controller controller-class-name="org.jmonks.batchserver.framework.controller.basic.BasicJobController" ! xml-factory-config-class-name="org.jmonks.batchserver.framework.config.xml.XMLBasicJobControllerConfig" ! db-factory-config-class-name="org.jmonks.batchserver.framework.config.db.DBBasicJobControllerConfig"/> </job-controller-config> </framework-config> \ No newline at end of file Index: JobControllerConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/JobControllerConfig.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** JobControllerConfig.java 8 Mar 2006 23:20:57 -0000 1.3 --- JobControllerConfig.java 9 Mar 2006 04:44:07 -0000 1.4 *************** *** 10,13 **** --- 10,14 ---- package org.jmonks.batchserver.framework.config; + import java.util.HashMap; import java.util.Iterator; import java.util.Map; *************** *** 42,46 **** * Map holds the required properties support the specified controller. */ ! protected Map jobControllerConfigProps=null; /** --- 43,47 ---- * Map holds the required properties support the specified controller. */ ! protected Map jobControllerConfigProps=new HashMap(); /** Index: PoolJobControllerConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/PoolJobControllerConfig.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PoolJobControllerConfig.java 8 Mar 2006 23:20:57 -0000 1.3 --- PoolJobControllerConfig.java 9 Mar 2006 04:44:07 -0000 1.4 *************** *** 11,14 **** --- 11,15 ---- package org.jmonks.batchserver.framework.config; + import java.util.HashMap; import java.util.Iterator; import java.util.Map; *************** *** 38,42 **** * Map contains the properties needed by pool job loader. */ ! protected Map poolJobLoaderConfigProps=null; /** * Pool job processor class name. --- 39,43 ---- * Map contains the properties needed by pool job loader. */ ! protected Map poolJobLoaderConfigProps=new HashMap(); /** * Pool job processor class name. *************** *** 46,50 **** * Map contains the properties needed by pool job processor. */ ! protected Map poolJobProcessorConfigProps=null; /** * Pool class name. --- 47,51 ---- * Map contains the properties needed by pool job processor. */ ! protected Map poolJobProcessorConfigProps=new HashMap(); /** * Pool class name. *************** *** 54,58 **** * Map contains the properties needed by pool class. */ ! protected Map poolConfigProps=null; /** --- 55,59 ---- * Map contains the properties needed by pool class. */ ! protected Map poolConfigProps=new HashMap(); /** |
From: Suresh <sur...@us...> - 2006-03-09 04:43:24
|
Update of /cvsroot/batchserver/batchserver/test/org/jmonks/batchserver/framework/config/xml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8791 Added Files: XMLPoolJobControllerConfigTest.java Log Message: no message --- NEW FILE: XMLPoolJobControllerConfigTest.java --- /* * XMLPoolJobControllerConfigTest.java * JUnit based test * * Created on March 8, 2006, 9:33 PM */ package org.jmonks.batchserver.framework.config.xml; import java.lang.reflect.Constructor; import junit.framework.*; import org.w3c.dom.Element; /** * * @author Suresh Pragada */ public class XMLPoolJobControllerConfigTest extends TestCase { public XMLPoolJobControllerConfigTest(String testName) { super(testName); } protected void setUp() throws Exception { } protected void tearDown() throws Exception { } public static Test suite() { TestSuite suite = new TestSuite(XMLPoolJobControllerConfigTest.class); return suite; } public void testInstantiation() throws Exception { try { Class configClass =Class.forName("org.jmonks.batchserver.framework.config.xml.XMLPoolJobControllerConfig"); Constructor constructor=configClass.getConstructor(new Class[]{Element.class}); XMLPoolJobControllerConfig configObject=(XMLPoolJobControllerConfig)constructor.newInstance(new Object[]{null}); } catch(NullPointerException e) { /** * This is as expected. */ } } } |
From: Suresh <sur...@us...> - 2006-03-09 04:42:58
|
Update of /cvsroot/batchserver/batchserver/test/org/jmonks/batchserver/framework/config In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8444 Modified Files: FrameworkConfigTest.java Added Files: BasicJobControllerConfigTest.java JobConfigFactoryTest.java JobConfigTest.java JobControllerConfigTest.java Log Message: no message Index: FrameworkConfigTest.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/test/org/jmonks/batchserver/framework/config/FrameworkConfigTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** FrameworkConfigTest.java 7 Mar 2006 03:42:25 -0000 1.1 --- FrameworkConfigTest.java 9 Mar 2006 04:42:55 -0000 1.2 *************** *** 133,136 **** --- 133,151 ---- System.out.println(repConfig); } + + /** + * Test that job-controller-config is properly configured. + */ + public void testGetJobControllerConfig() + { + FrameworkConfig frameworkConfig=FrameworkConfig.getInstance(); + assertNotNull(frameworkConfig); + FrameworkConfig.JobControllerConfig controllerConfig=frameworkConfig.getJobControllerConfig(); + assertNotNull(controllerConfig); + String configClassName=controllerConfig.getConfigClassName("org.jmonks.batchserver.framework.controller.pool.PoolJobController", "xml-factory-config-class-name"); + System.out.println(configClassName); + assertNotNull(configClassName); + System.out.println(controllerConfig); + } } --- NEW FILE: BasicJobControllerConfigTest.java --- /* * BasicJobControllerConfigTest.java * JUnit based test * * Created on March 8, 2006, 10:38 PM */ package org.jmonks.batchserver.framework.config; import junit.framework.*; import java.util.HashMap; import java.util.Iterator; import java.util.Map; /** * Test cases to test the BasicJobControllerConfig class. * @author Suresh Pragada */ public class BasicJobControllerConfigTest extends TestCase { public BasicJobControllerConfigTest(String testName) { super(testName); } protected void setUp() throws Exception { } protected void tearDown() throws Exception { } public static Test suite() { TestSuite suite = new TestSuite(BasicJobControllerConfigTest.class); return suite; } /** * Test of getBasicJobProcessorClassName method, of class org.jmonks.batchserver.framework.config.BasicJobControllerConfig. */ public void testGetBasicJobProcessorClassName() { } /** * Test of getBasicJobProcessorConfigProperties method, of class org.jmonks.batchserver.framework.config.BasicJobControllerConfig. */ public void testGetBasicJobProcessorConfigProperties() { } /** * Test of getJobControllerConfigPropertyPrefix method, of class org.jmonks.batchserver.framework.config.BasicJobControllerConfig. */ public void testGetJobControllerConfigPropertyPrefix() { } /** * Test of overrideConfigProperties method, of class org.jmonks.batchserver.framework.config.BasicJobControllerConfig. */ public void testOverrideConfigProperties() { } /** * Test of toString method, of class org.jmonks.batchserver.framework.config.BasicJobControllerConfig. */ public void testToString() { } } --- NEW FILE: JobConfigTest.java --- /* * JobConfigTest.java * JUnit based test * * Created on March 8, 2006, 10:13 PM */ package org.jmonks.batchserver.framework.config; import junit.framework.*; import java.util.Map; /** * Test cases to test the JobConfig class. * @author Suresh Pragada */ public class JobConfigTest extends TestCase { public JobConfigTest(String testName) { super(testName); } protected void setUp() throws Exception { } protected void tearDown() throws Exception { } public static Test suite() { TestSuite suite = new TestSuite(JobConfigTest.class); return suite; } /** * Test case to make sure that JobConfig never returns null controller object. */ public void testGetJobControllerConfig() { FrameworkConfig frameworkConfig=FrameworkConfig.getInstance(); assertNotNull(frameworkConfig); FrameworkConfig.JobConfigFactoryConfig factoryConfig=frameworkConfig.getJobConfigFactoryConfig(); assertNotNull(factoryConfig); JobConfigFactory factory=JobConfigFactory.getJobConfigFactory(factoryConfig); assertNotNull(factory); JobConfig jobConfig=factory.getJobConfig("process_file_abc"); assertNotNull(jobConfig); JobControllerConfig controllerConfig=jobConfig.getJobControllerConfig(); assertNotNull(controllerConfig); } /** * Test that getJobName doesnt return null and make sure it returns the same job name * that we requested. */ public void testGetJobName() { FrameworkConfig frameworkConfig=FrameworkConfig.getInstance(); assertNotNull(frameworkConfig); FrameworkConfig.JobConfigFactoryConfig factoryConfig=frameworkConfig.getJobConfigFactoryConfig(); assertNotNull(factoryConfig); JobConfigFactory factory=JobConfigFactory.getJobConfigFactory(factoryConfig); assertNotNull(factory); JobConfig jobConfig=factory.getJobConfig("process_file_abc"); assertNotNull(jobConfig); String jobName=jobConfig.getJobName(); assertNotNull(jobName); assertEquals("process_file_abc",jobName); } } --- NEW FILE: JobConfigFactoryTest.java --- /* * JobConfigFactoryTest.java * JUnit based test * * Created on March 8, 2006, 8:01 PM */ package org.jmonks.batchserver.framework.config; import junit.framework.*; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.Map; import org.jmonks.batchserver.framework.common.ErrorCode; /** * Test cases to test the JobConfigFactory * @author Suresh Pragada */ public class JobConfigFactoryTest extends TestCase { public JobConfigFactoryTest(String testName) { super(testName); } protected void setUp() throws Exception { } protected void tearDown() throws Exception { } public static Test suite() { TestSuite suite = new TestSuite(JobConfigFactoryTest.class); return suite; } /** * Test case will check the config factory returned property or not. */ public void testGetJobConfigFactory() { FrameworkConfig frameworkConfig=FrameworkConfig.getInstance(); assertNotNull(frameworkConfig); FrameworkConfig.JobConfigFactoryConfig jobConfigFactoryConfig=frameworkConfig.getJobConfigFactoryConfig(); assertNotNull(jobConfigFactoryConfig); JobConfigFactory configFactory=JobConfigFactory.getJobConfigFactory(jobConfigFactoryConfig); assertNotNull(configFactory); } /** * Test case to make sure requested job being returned or not. */ public void testGetJobConfig() { FrameworkConfig frameworkConfig=FrameworkConfig.getInstance(); assertNotNull(frameworkConfig); FrameworkConfig.JobConfigFactoryConfig jobConfigFactoryConfig=frameworkConfig.getJobConfigFactoryConfig(); assertNotNull(jobConfigFactoryConfig); JobConfigFactory configFactory=JobConfigFactory.getJobConfigFactory(jobConfigFactoryConfig); assertNotNull(configFactory); JobConfig jobConfigNotExist=configFactory.getJobConfig("job_not_exist"); assertNull(jobConfigNotExist); JobConfig jobProcessFileAbc=configFactory.getJobConfig("process_file_abc"); assertNotNull(jobProcessFileAbc); JobConfig jobProcessFileXyz=configFactory.getJobConfig("process_file_xyz"); assertNotNull(jobProcessFileXyz); } } --- NEW FILE: JobControllerConfigTest.java --- /* * JobControllerConfigTest.java * JUnit based test * * Created on March 8, 2006, 10:21 PM */ package org.jmonks.batchserver.framework.config; import java.util.HashMap; import junit.framework.*; import java.util.Map; /** * * @author Suresh Pragada */ public class JobControllerConfigTest extends TestCase { public JobControllerConfigTest(String testName) { super(testName); } protected void setUp() throws Exception { } protected void tearDown() throws Exception { } public static Test suite() { TestSuite suite = new TestSuite(JobControllerConfigTest.class); return suite; } /** * Test to make sure returned controller class name cannot be null. */ public void testGetJobControllerClasName() { FrameworkConfig frameworkConfig=FrameworkConfig.getInstance(); assertNotNull(frameworkConfig); FrameworkConfig.JobConfigFactoryConfig factoryConfig=frameworkConfig.getJobConfigFactoryConfig(); assertNotNull(factoryConfig); JobConfigFactory factory=JobConfigFactory.getJobConfigFactory(factoryConfig); assertNotNull(factory); JobConfig jobConfig=factory.getJobConfig("process_file_abc"); assertNotNull(jobConfig); JobControllerConfig controllerConfig=jobConfig.getJobControllerConfig(); assertNotNull(controllerConfig); String controllerClassName=controllerConfig.getJobControllerClasName(); assertNotNull(controllerClassName); } /** * Test to make sure controller config never returns null map. */ public void testGetJobControllerConfigProperties() { FrameworkConfig frameworkConfig=FrameworkConfig.getInstance(); assertNotNull(frameworkConfig); FrameworkConfig.JobConfigFactoryConfig factoryConfig=frameworkConfig.getJobConfigFactoryConfig(); assertNotNull(factoryConfig); JobConfigFactory factory=JobConfigFactory.getJobConfigFactory(factoryConfig); assertNotNull(factory); JobConfig jobConfig=factory.getJobConfig("process_file_abc"); assertNotNull(jobConfig); JobControllerConfig controllerConfig=jobConfig.getJobControllerConfig(); assertNotNull(controllerConfig); Map controllerConfigProps=controllerConfig.getJobControllerConfigProperties(); assertNotNull(controllerConfigProps); } /** * Test to make sure that it overrides the given values and add the missing values. */ public void testOverrideConfigProperties() { FrameworkConfig frameworkConfig=FrameworkConfig.getInstance(); assertNotNull(frameworkConfig); FrameworkConfig.JobConfigFactoryConfig factoryConfig=frameworkConfig.getJobConfigFactoryConfig(); assertNotNull(factoryConfig); JobConfigFactory factory=JobConfigFactory.getJobConfigFactory(factoryConfig); assertNotNull(factory); JobConfig jobConfig=factory.getJobConfig("process_file_abc"); assertNotNull(jobConfig); JobControllerConfig controllerConfig=jobConfig.getJobControllerConfig(); assertNotNull(controllerConfig); Map controllerConfigProps=controllerConfig.getJobControllerConfigProperties(); assertNotNull(controllerConfigProps); String introducingKey=controllerConfig.getJobControllerConfigPropertyPrefix()+"somekey"; String introducingValue="Value being introduced"; Map newProps=new HashMap(); newProps.put(introducingKey,introducingValue); controllerConfig.overrideConfigProperties(newProps); String introducedValue=(String)controllerConfig.getJobControllerConfigProperties().get(introducingKey); assertNotNull(introducedValue); assertEquals(introducingValue,introducedValue); String overridingValue="Value being overriden"; Map overridenProps=new HashMap(); overridenProps.put(introducingKey,overridingValue); controllerConfig.overrideConfigProperties(overridenProps); String overridenValue=(String)controllerConfig.getJobControllerConfigProperties().get(introducingKey); assertNotNull(overridenValue); assertEquals(overridingValue,overridenValue); } /** * Test to make sure controller config doesnt return null or empty as common property prefix. */ public void testGetJobControllerConfigPropertyPrefix() { FrameworkConfig frameworkConfig=FrameworkConfig.getInstance(); assertNotNull(frameworkConfig); FrameworkConfig.JobConfigFactoryConfig factoryConfig=frameworkConfig.getJobConfigFactoryConfig(); assertNotNull(factoryConfig); JobConfigFactory factory=JobConfigFactory.getJobConfigFactory(factoryConfig); assertNotNull(factory); JobConfig jobConfig=factory.getJobConfig("process_file_abc"); assertNotNull(jobConfig); JobControllerConfig controllerConfig=jobConfig.getJobControllerConfig(); assertNotNull(controllerConfig); String prefixName=controllerConfig.getJobControllerConfigPropertyPrefix(); assertNotNull(prefixName); assertTrue(!"".equals(prefixName)); } } |
From: Suresh <sur...@us...> - 2006-03-09 04:42:31
|
Update of /cvsroot/batchserver/batchserver/test/org/jmonks/batchserver/framework/config/xml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8331/xml Log Message: Directory /cvsroot/batchserver/batchserver/test/org/jmonks/batchserver/framework/config/xml added to the repository |
From: Suresh <sur...@us...> - 2006-03-08 23:21:17
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/xml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21935 Modified Files: XMLBasicJobControllerConfig.java XMLJobControllerConfig.java XMLPoolJobControllerConfig.java Log Message: no message Index: XMLBasicJobControllerConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/xml/XMLBasicJobControllerConfig.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** XMLBasicJobControllerConfig.java 8 Mar 2006 05:17:48 -0000 1.2 --- XMLBasicJobControllerConfig.java 8 Mar 2006 23:21:13 -0000 1.3 *************** *** 11,16 **** --- 11,20 ---- package org.jmonks.batchserver.framework.config.xml; + import org.jmonks.batchserver.framework.common.ErrorCode; + import org.jmonks.batchserver.framework.common.FrameworkUtil; import org.jmonks.batchserver.framework.config.BasicJobControllerConfig; + import org.jmonks.batchserver.framework.config.ConfigurationException; import org.w3c.dom.Element; + import org.w3c.dom.NodeList; /** *************** *** 35,38 **** --- 39,50 ---- public class XMLBasicJobControllerConfig extends BasicJobControllerConfig { + /** + * XML Element name defiens the basic job processor configuration. + */ + private static final String BASIC_JOB_PROCESSOR_ELEMENT_NAME = "basic-job-processor"; + /** + * XML Attribute name defines the basic job processor class name. + */ + private static final String BASIC_JOB_PROCESSOR_CLASS_ATTRIBUTE_NAME = "basic-job-processor-class-name"; /** * Loads the XML job controller configuration into XMLBasicJobControllerConfig object. *************** *** 44,48 **** --- 56,79 ---- XMLBasicJobControllerConfig(Element controllerConfigElement) { + this.jobControllerClassName=controllerConfigElement.getAttribute(XMLJobControllerConfig.JOB_CONTROLLER_CLASS_ATTRIBUTE_NAME); + if(this.jobControllerClassName==null) + throw new ConfigurationException(ErrorCode.JOB_CONTROLLER_CLASS_NOT_DEFINED); + FrameworkUtil.loadPropertiesFromElementToMap(controllerConfigElement, this.jobControllerConfigProps); + + NodeList xmlBasicJobProcessorNodeList=controllerConfigElement.getElementsByTagName(XMLBasicJobControllerConfig.BASIC_JOB_PROCESSOR_ELEMENT_NAME); + if(xmlBasicJobProcessorNodeList.getLength()==1) + { + Element xmlBasicJobProcessorElement=(Element)xmlBasicJobProcessorNodeList.item(0); + this.basicJobProcessorClassName=xmlBasicJobProcessorElement.getAttribute(XMLBasicJobControllerConfig.BASIC_JOB_PROCESSOR_CLASS_ATTRIBUTE_NAME); + if(this.basicJobProcessorClassName==null) + throw new ConfigurationException(ErrorCode.BASIC_JOB_PROCESSOR_CLASS_NAME_NOT_DEFINED); + else + { + FrameworkUtil.loadPropertiesFromElementToMap(xmlBasicJobProcessorElement, this.basicJobProcessorConfigProps); + } + } + else + throw new ConfigurationException(ErrorCode.NONE_OR_MULTIPLE_BASIC_JOB_PROCESSOR_ELEMENTS_FOUND); } } Index: XMLPoolJobControllerConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/xml/XMLPoolJobControllerConfig.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** XMLPoolJobControllerConfig.java 8 Mar 2006 05:17:48 -0000 1.2 --- XMLPoolJobControllerConfig.java 8 Mar 2006 23:21:14 -0000 1.3 *************** *** 11,16 **** --- 11,20 ---- package org.jmonks.batchserver.framework.config.xml; + import org.jmonks.batchserver.framework.common.ErrorCode; + import org.jmonks.batchserver.framework.common.FrameworkUtil; + import org.jmonks.batchserver.framework.config.ConfigurationException; import org.jmonks.batchserver.framework.config.PoolJobControllerConfig; import org.w3c.dom.Element; + import org.w3c.dom.NodeList; /** *************** *** 40,43 **** --- 44,72 ---- public class XMLPoolJobControllerConfig extends PoolJobControllerConfig { + /** + * XML Element name defines the pool job loader configuration. + */ + private static final String POOL_JOB_LOADER_ELEMENT_NAME = "pool-job-loader"; + /** + * XML Attribute name defines the pool job loader class name. + */ + private static final String POOL_JOB_LOADER_CLASS_ATTRIBUTE_NAME = "pool-job-loader-class-name"; + /** + * XML Element name defines the job pool configuration. + */ + private static final String POOL_JOB_POOL_ELEMENT_NAME = "job-pool"; + /** + * XML Attribute name defines the job pool class name. + */ + private static final String POOL_JOB_POOL_CLASS_ATTRIBUTE_NAME = "job-pool-class-name"; + /** + * XML Element name defines the pool job processor configuration. + */ + private static final String POOL_JOB_PROCESSOR_ELEMENT_NAME = "pool-job-processor"; + /** + * XML Attribute name defines the pool job processor class name. + */ + private static final String POOL_JOB_PROCESSOR_CLASS_ATTRIBUTE_NAME = "pool-job-processor-class-name"; + /** * Loads the XMLPoolJobControllerConfig from XML DOM Element <job-controller> *************** *** 49,55 **** XMLPoolJobControllerConfig(Element controllerConfigElement) { /** ! * Load everything defined in base class using the input element. */ } --- 78,140 ---- XMLPoolJobControllerConfig(Element controllerConfigElement) { + this.jobControllerClassName=controllerConfigElement.getAttribute(XMLJobControllerConfig.JOB_CONTROLLER_CLASS_ATTRIBUTE_NAME); + if(this.jobControllerClassName==null) + throw new ConfigurationException(ErrorCode.JOB_CONTROLLER_CLASS_NOT_DEFINED); + + FrameworkUtil.loadPropertiesFromElementToMap(controllerConfigElement, this.jobControllerConfigProps); + /** ! * Load pool job loader configuration. */ + NodeList xmlPoolJobLoaderNodeList=controllerConfigElement.getElementsByTagName(XMLPoolJobControllerConfig.POOL_JOB_LOADER_ELEMENT_NAME); + if(xmlPoolJobLoaderNodeList.getLength()==1) + { + Element xmlPoolJobLoaderElement=(Element)xmlPoolJobLoaderNodeList.item(0); + this.poolJobLoaderClassName=xmlPoolJobLoaderElement.getAttribute(XMLPoolJobControllerConfig.POOL_JOB_LOADER_CLASS_ATTRIBUTE_NAME); + if(this.poolJobProcessorClassName==null) + throw new ConfigurationException(ErrorCode.POOL_JOB_LOADER_CLASS_NAME_NOT_DEFINED); + else + { + FrameworkUtil.loadPropertiesFromElementToMap(xmlPoolJobLoaderElement, this.poolJobLoaderConfigProps); + } + } + else + throw new ConfigurationException(ErrorCode.NONE_OR_MULTIPLE_POOL_JOB_LOADER_ELEMENTS_FOUND); + + /** + * Load pool job procesor configuration. + */ + NodeList xmlPoolJobProcessorNodeList=controllerConfigElement.getElementsByTagName(XMLPoolJobControllerConfig.POOL_JOB_PROCESSOR_ELEMENT_NAME); + if(xmlPoolJobProcessorNodeList.getLength()==1) + { + Element xmlPoolJobProcessorElement=(Element)xmlPoolJobProcessorNodeList.item(0); + this.poolJobProcessorClassName=xmlPoolJobProcessorElement.getAttribute(XMLPoolJobControllerConfig.POOL_JOB_PROCESSOR_CLASS_ATTRIBUTE_NAME); + if(this.poolJobProcessorClassName==null) + throw new ConfigurationException(ErrorCode.POOL_JOB_PROCESSOR_CLASS_NAME_NOT_DEFINED); + else + { + FrameworkUtil.loadPropertiesFromElementToMap(xmlPoolJobProcessorElement, this.poolJobProcessorConfigProps); + } + } + else + throw new ConfigurationException(ErrorCode.NONE_OR_MULTIPLE_POOL_JOB_PROCESSOR_ELEMENTS_FOUND); + + /** + * Load job pool configuration. + */ + NodeList xmlJobPoolNodeList=controllerConfigElement.getElementsByTagName(XMLPoolJobControllerConfig.POOL_JOB_POOL_ELEMENT_NAME); + if(xmlJobPoolNodeList.getLength()==1) + { + Element xmlJobPoolElement=(Element)xmlJobPoolNodeList.item(0); + this.poolClassName=xmlJobPoolElement.getAttribute(XMLPoolJobControllerConfig.POOL_JOB_POOL_CLASS_ATTRIBUTE_NAME); + if(this.poolClassName==null) + throw new ConfigurationException(ErrorCode.POOL_JOB_POOL_CLASS_NAME_NOT_DEFINED); + else + { + FrameworkUtil.loadPropertiesFromElementToMap(xmlJobPoolElement, this.poolConfigProps); + } + } + else + throw new ConfigurationException(ErrorCode.NONE_OR_MULTIPLE_JOB_POOL_ELEMENTS_FOUND); } Index: XMLJobControllerConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/xml/XMLJobControllerConfig.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** XMLJobControllerConfig.java 8 Mar 2006 05:17:48 -0000 1.3 --- XMLJobControllerConfig.java 8 Mar 2006 23:21:14 -0000 1.4 *************** *** 20,25 **** /** ! * ! * @author Suresh Pragada */ public abstract class XMLJobControllerConfig extends JobControllerConfig --- 20,29 ---- /** ! * XMLJobControllerConfig responsible to build the controller specific ! * JobControllerConfig objects from the given XML. ! * ! * @author Suresh Pragada ! * @version 1.0 ! * @since 1.0 */ public abstract class XMLJobControllerConfig extends JobControllerConfig *************** *** 38,43 **** public static final String JOB_CONTROLLER_CONFIG_FACTORY_CLASS_ATTRIBUTE_NAME = "xml-factory-config-class-name"; /** * ! * @throws ConfigurationException If controller config class name is not defined. */ public static JobControllerConfig getJobControllerConfig(Element controllerConfigElement) --- 42,62 ---- public static final String JOB_CONTROLLER_CONFIG_FACTORY_CLASS_ATTRIBUTE_NAME = "xml-factory-config-class-name"; /** + * <p> + * Factory method creates and returns the controller specific controller config object + * from the following XML block from the job configuration file. This looks for the + * controller class name and tries to find specific controller config object for this controller + * and defined for the XML factory in framework configuration file. + * <br><br> + * <pre> + * <job-controller job-controller-class-name="org.jmonks.batchserver.framework.controller.basic.BasicJobController"> + * <property key="basic-job-controller-restart">true</property> + * </job-controller> + * </pre> + * </p> + * + * @return Returns the controller specific controller config object. * ! * @throws ConfigurationException If controller config class name is not defined or controller specific config object cannot be found ! * in framework controller configuration. */ public static JobControllerConfig getJobControllerConfig(Element controllerConfigElement) *************** *** 88,92 **** } } ! return controllerConfig; } --- 107,111 ---- } } ! return controllerConfig; } |
From: Suresh <sur...@us...> - 2006-03-08 23:21:00
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21627 Modified Files: BasicJobControllerConfig.java JobControllerConfig.java PoolJobControllerConfig.java Log Message: no message Index: JobControllerConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/JobControllerConfig.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** JobControllerConfig.java 8 Mar 2006 05:18:55 -0000 1.2 --- JobControllerConfig.java 8 Mar 2006 23:20:57 -0000 1.3 *************** *** 71,75 **** * If any property defined newProps starting with controller config prefix, * doesnt exist in controller defined props, it will add that property to the ! * controller map. * * @param newProps Map contains the new properties. --- 71,77 ---- * If any property defined newProps starting with controller config prefix, * doesnt exist in controller defined props, it will add that property to the ! * controller map. This also overrides the properties common to the controller ! * which starts with "job-controller-". This will be used to override some common ! * properties like "job-controller-restart". * * @param newProps Map contains the new properties. *************** *** 79,83 **** if(newProps==null ) return; ! String configPrefix=this.getJobControllerConfigPropertyPrefix(); if(configPrefix==null) --- 81,99 ---- if(newProps==null ) return; ! /** ! * Override controller common properties like restart of the controller. ! */ ! for(Iterator iterator=newProps.keySet().iterator();iterator.hasNext();) ! { ! String key=(String)iterator.next(); ! if(key.startsWith("job-controller-")) ! { ! this.jobControllerConfigProps.put(key, newProps.get(key)); ! } ! } ! /** ! * Override controller specific properties by getting the prefix from ! * specific controller. ! */ String configPrefix=this.getJobControllerConfigPropertyPrefix(); if(configPrefix==null) Index: BasicJobControllerConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/BasicJobControllerConfig.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BasicJobControllerConfig.java 8 Mar 2006 05:18:55 -0000 1.2 --- BasicJobControllerConfig.java 8 Mar 2006 23:20:57 -0000 1.3 *************** *** 11,14 **** --- 11,15 ---- package org.jmonks.batchserver.framework.config; + import java.util.Iterator; import java.util.Map; *************** *** 69,75 **** /** ! * Base implementation overrides the properties in controller config props only. ! * So, override all the props like loader, process and pool here along with controller ! * config props. * * @param newProps Map contains new properties. --- 70,77 ---- /** ! * Override the properties controller and controller sub componenets. ! * JobControllerConfig provides the implementation of overriding common controller ! * properties and controller specific properties. So, this will override ! * the properties of controller sub componenents like basic job processor. * * @param newProps Map contains new properties. *************** *** 80,86 **** /** ! * Override the processor here. */ } } --- 82,115 ---- /** ! * Override basic job processor config properites. */ + for(Iterator iterator=newProps.keySet().iterator();iterator.hasNext();) + { + String key=(String)iterator.next(); + if(key.startsWith("basic-job-processor-")) + { + this.basicJobProcessorConfigProps.put(key, newProps.get(key)); + } + } } + /** + * <p> + * Returns the string representation of BasicJobControllerConfig class in the format + * <br> {BasicJobControllerConfig [controllerClassName = value] [controllerConfigProps = value] + * [basicJobProcessorClassName = value] [basicJobProcessorConfigProps = value]} + * </p> + * + * @return Returns the string representation of BasicJobControllerConfig. + */ + public String toString() + { + StringBuffer stringValue=new StringBuffer("{BasicJobControllerConfig "); + stringValue.append("[controllerClassName = " + this.jobControllerClassName + "]"); + stringValue.append("[controllerConfigProps = " + this.jobControllerConfigProps + "]"); + stringValue.append("[basicJobProcessorClassName = " + this.basicJobProcessorClassName + "]"); + stringValue.append("[basicJobProcessorConfigProps = " + this.basicJobProcessorConfigProps + "]"); + stringValue.append("}"); + return stringValue.toString(); + } } Index: PoolJobControllerConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/PoolJobControllerConfig.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PoolJobControllerConfig.java 8 Mar 2006 05:18:55 -0000 1.2 --- PoolJobControllerConfig.java 8 Mar 2006 23:20:57 -0000 1.3 *************** *** 11,14 **** --- 11,15 ---- package org.jmonks.batchserver.framework.config; + import java.util.Iterator; import java.util.Map; *************** *** 126,134 **** /** ! * Base implementation overrides the properties in controller config props only. ! * So, override all the props like loader, process and pool here along with controller ! * config props. * ! * @param newProps Properties needs to be overriden. */ public void overrideConfigProperties(Map newProps) --- 127,137 ---- /** ! * Override the properties controller and controller sub componenets. ! * JobControllerConfig provides the implementation of overriding common controller ! * properties and controller specific properties. So, this will override ! * the properties of controller sub componenents like pool job processor, ! * pool job loader and job pool. * ! * @param newProps Map contains new properties. */ public void overrideConfigProperties(Map newProps) *************** *** 136,142 **** super.overrideConfigProperties(newProps); /** ! * Override the loader, processor and pool here. */ } } --- 139,209 ---- super.overrideConfigProperties(newProps); + if(newProps==null ) + return; + /** ! * Override pool job loader properties. */ + for(Iterator iterator=newProps.keySet().iterator();iterator.hasNext();) + { + String key=(String)iterator.next(); + if(key.startsWith("pool-job-loader-")) + { + this.poolJobLoaderConfigProps.put(key, newProps.get(key)); + } + } + /** + * Override pool job processor properties. + */ + for(Iterator iterator=newProps.keySet().iterator();iterator.hasNext();) + { + String key=(String)iterator.next(); + if(key.startsWith("pool-job-processor-")) + { + this.poolJobProcessorConfigProps.put(key, newProps.get(key)); + } + } + /** + * Override pool job loader properties. + */ + for(Iterator iterator=newProps.keySet().iterator();iterator.hasNext();) + { + String key=(String)iterator.next(); + if(key.startsWith("job-pool-")) + { + this.poolConfigProps.put(key, newProps.get(key)); + } + } + + } + + /** + * <p> + * Returns the string representation of PoolJobControllerConfig class in the format + * <br> {PoolJobControllerConfig [controllerClassName = value] [controllerConfigProps = value] + * [poolJobProcessorClassName = value] [poolJobProcessorConfigProps = value] + * [poolJobLoaderClassName = value] [poolJobLoaderConfigProps = value] + * [jobPoolClassName = value] [jobPoolConfigProps = value]} + * </p> + * + * @return Returns the string representation of PoolJobControllerConfig. + */ + public String toString() + { + StringBuffer stringValue=new StringBuffer("{PoolJobControllerConfig "); + + stringValue.append("[controllerClassName = " + this.jobControllerClassName + "]"); + stringValue.append("[controllerConfigProps = " + this.jobControllerConfigProps + "]"); + stringValue.append("[poolJobProcessorClassName = " + this.poolJobProcessorClassName + "]"); + stringValue.append("[poolJobProcessorConfigProps = " + this.poolJobProcessorConfigProps + "]"); + stringValue.append("[poolJobLoaderClassName = " + this.poolJobLoaderClassName + "]"); + stringValue.append("[poolJobLoaderConfigProps = " + this.poolJobLoaderConfigProps + "]"); + stringValue.append("[jobPoolClassName = " + this.poolClassName + "]"); + stringValue.append("[jobPoolConfigProps = " + this.poolConfigProps + "]"); + stringValue.append("}"); + + return stringValue.toString(); + } + } |
From: Suresh <sur...@us...> - 2006-03-08 23:20:41
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21543 Modified Files: ErrorCode.java Log Message: no message Index: ErrorCode.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/common/ErrorCode.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ErrorCode.java 8 Mar 2006 05:17:08 -0000 1.7 --- ErrorCode.java 8 Mar 2006 23:20:38 -0000 1.8 *************** *** 109,112 **** --- 109,121 ---- public static final ErrorCode JOB_CONTROLLER_CONFIG_CLASS_NOT_DEFINED = new ErrorCode(2011,"job controller config class is not defined in framework configuration"); public static final ErrorCode JOB_CONTROLLER_CONFIG_CLASS_NOT_VALID = new ErrorCode(2012,"job controller config class is not a valid"); + public static final ErrorCode NONE_OR_MULTIPLE_BASIC_JOB_PROCESSOR_ELEMENTS_FOUND = new ErrorCode(2013,"None or multiple basic job processor elements found in job controller"); + public static final ErrorCode BASIC_JOB_PROCESSOR_CLASS_NAME_NOT_DEFINED = new ErrorCode(2014,"basic-job-processor-class-name is not defined in basic-job-processor element."); + public static final ErrorCode NONE_OR_MULTIPLE_POOL_JOB_PROCESSOR_ELEMENTS_FOUND = new ErrorCode(2015,"None or multiple pool job processor elements found in job controller"); + public static final ErrorCode POOL_JOB_PROCESSOR_CLASS_NAME_NOT_DEFINED = new ErrorCode(2016,"pool-job-processor-class-name is not defined in pool-job-processor element."); + public static final ErrorCode NONE_OR_MULTIPLE_POOL_JOB_LOADER_ELEMENTS_FOUND = new ErrorCode(2017,"None or multiple pool job loader elements found in job controller"); + public static final ErrorCode POOL_JOB_LOADER_CLASS_NAME_NOT_DEFINED = new ErrorCode(2018,"pool-job-loader-class-name is not defined in pool-job-loader element."); + public static final ErrorCode NONE_OR_MULTIPLE_JOB_POOL_ELEMENTS_FOUND = new ErrorCode(2019,"None or multiple job pool elements found in job controller"); + public static final ErrorCode POOL_JOB_POOL_CLASS_NAME_NOT_DEFINED = new ErrorCode(2020,"job-pool-class-name is not defined in job-pool element."); + } |
From: Suresh <sur...@us...> - 2006-03-08 05:19:03
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22184 Modified Files: BasicJobControllerConfig.java batch-config.xml framework-config.xml FrameworkConfig.java JobConfigFactory.java JobControllerConfig.java PoolJobControllerConfig.java Log Message: no message Index: BasicJobControllerConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/BasicJobControllerConfig.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BasicJobControllerConfig.java 3 Mar 2006 04:19:56 -0000 1.1 --- BasicJobControllerConfig.java 8 Mar 2006 05:18:55 -0000 1.2 *************** *** 14,38 **** /** ! * ! * @author Suresh Pragada */ public abstract class BasicJobControllerConfig extends JobControllerConfig { protected final static String CONFIG_PROPERTY_PREFIX = "basic-job-controller-"; ! protected String mBasicJobProcessorClassName=null; ! protected Map mBasicJobProcessorConfigProps=null; public String getBasicJobProcessorClassName() { ! return this.mBasicJobProcessorClassName; } public Map getBasicJobProcessorConfigProperties() { ! return this.mBasicJobProcessorConfigProps; } ! protected String getJobControllerConfigPropertyPrefix() { --- 14,66 ---- /** ! * BasicJobControllerConfig provides the configuration for the BasicJobController. ! * ! * @author Suresh Pragada ! * @version 1.0 ! * @since 1.0 */ public abstract class BasicJobControllerConfig extends JobControllerConfig { + /** + * Common configuration property prefix for basic job controller. + */ protected final static String CONFIG_PROPERTY_PREFIX = "basic-job-controller-"; ! /** ! * Basic job processor class name. ! */ ! protected String basicJobProcessorClassName=null; + /** + * Map contains the properties required by the basic job processor. + */ + protected Map basicJobProcessorConfigProps=null; + + /** + * Gets the basic job processor class name. + * + * @return Returns the basic job processor class name. + */ public String getBasicJobProcessorClassName() { ! return this.basicJobProcessorClassName; } + /** + * Gets the map contains the properties required by basic job processor. + * + * @return Returns the map contains the properties required by basic job processor. + */ public Map getBasicJobProcessorConfigProperties() { ! return this.basicJobProcessorConfigProps; } ! ! /** ! * Returns the common property prefix of basic job cotroller. ! * ! * @return Returns the common property prefix. ! */ protected String getJobControllerConfigPropertyPrefix() { *************** *** 44,47 **** --- 72,77 ---- * So, override all the props like loader, process and pool here along with controller * config props. + * + * @param newProps Map contains new properties. */ public void overrideConfigProperties(Map newProps) *************** *** 50,54 **** /** ! * Override the loader, processor and pool here. */ } --- 80,84 ---- /** ! * Override the processor here. */ } Index: batch-config.xml =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/batch-config.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** batch-config.xml 8 Mar 2006 00:30:49 -0000 1.4 --- batch-config.xml 8 Mar 2006 05:18:55 -0000 1.5 *************** *** 2,12 **** <batch-config> <job-config job-name="process_file_abc"> ! <job-controller job-controller-class-name="org.jmonks.batchserver.framework.controller.pool.PoolJobController" ! job-controller-config-class-name="org.jmonks.batchserver.framework.config.PoolControllerConfig"> <pool-job-loader pool-job-loader-class-name="com.mycompany.batch.processfileabc.AbcJobLoader"> <property key="pool-job-loader-key1">loader-value1</property> </pool-job-loader> ! <pool-job-processor pool-job-processor-class-name="com.mycompany.batch.processfileabc.AbcJobLoader"> ! <thread-count>1</thread-count> <property key="pool-job-processor-key1">processor-value1</property> </pool-job-processor> --- 2,10 ---- <batch-config> <job-config job-name="process_file_abc"> ! <job-controller job-controller-class-name="org.jmonks.batchserver.framework.controller.pool.PoolJobController"> <pool-job-loader pool-job-loader-class-name="com.mycompany.batch.processfileabc.AbcJobLoader"> <property key="pool-job-loader-key1">loader-value1</property> </pool-job-loader> ! <pool-job-processor pool-job-processor-class-name="com.mycompany.batch.processfileabc.AbcJobLoader" thread-count="1"> <property key="pool-job-processor-key1">processor-value1</property> </pool-job-processor> *************** *** 18,23 **** </job-config> <job-config job-name="process_file_xyz"> ! <job-controller job-controller-class-name="org.jmonks.batchserver.framework.controller.basic.BasicJobController" ! job-controller-config-class-name="org.jmonks.batchserver.framework.config.BasicJobControllerConfig"> <basic-job-processor basic-job-processor-class-name="com.mycompany.batch.processfilexyz.XyzProcessor"> <property key="basic-job-processor-key1">processor-value1</property> --- 16,20 ---- </job-config> <job-config job-name="process_file_xyz"> ! <job-controller job-controller-class-name="org.jmonks.batchserver.framework.controller.basic.BasicJobController"> <basic-job-processor basic-job-processor-class-name="com.mycompany.batch.processfilexyz.XyzProcessor"> <property key="basic-job-processor-key1">processor-value1</property> Index: FrameworkConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/FrameworkConfig.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** FrameworkConfig.java 7 Mar 2006 03:43:06 -0000 1.4 --- FrameworkConfig.java 8 Mar 2006 05:18:55 -0000 1.5 *************** *** 22,25 **** --- 22,26 ---- import org.w3c.dom.Document; import org.w3c.dom.Element; + import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; *************** *** 66,69 **** --- 67,74 ---- */ private RepositoryConfig repositoryConfig=null; + /** + * JobControllerConfig varaible to hold JobControllerConfig object. + */ + private JobControllerConfig controllerConfig=null; /** *************** *** 130,133 **** --- 135,148 ---- throw new ConfigurationException(ErrorCode.NONE_OR_MULITPLE_REPOSITORY_CONFIG_TAGS); } + + NodeList controllerConfigNodeList=frameworkConfigElement.getElementsByTagName(JobControllerConfig.TAG_NAME); + if(controllerConfigNodeList.getLength()==1) + { + this.controllerConfig=new JobControllerConfig(((Element)controllerConfigNodeList.item(0))); + } + else + { + throw new ConfigurationException(ErrorCode.NONE_OR_MULITPLE_JOB_CONTROLLER_CONFIG_TAGS); + } } catch(IOException ioException) *************** *** 199,202 **** --- 214,227 ---- /** + * Returns the job controller configuration defined in framework configuration as a JobControllerConfig object. + * + * @return Returns the JobControllerConfig object. + */ + public JobControllerConfig getJobControllerConfig() + { + return this.controllerConfig; + } + + /** * <p> * JobConfigFactoryConfig class holds the configuration information required *************** *** 603,612 **** } ! /** * <p> * Returns the string representation of FrameworkConfig class in the format * <br> {FrameworkConfig [jobConfigFactoryConfig = value] [loggingConfig = value] ! * [mgmtMntrConfig = value] [repositoryConfig = value]} * </p> * --- 628,737 ---- } ! ! /** ! * <p> ! * ControllerConfig holds the configuration related to the controller components. ! * It holds the information like factory specific config objects related to each ! * controller componenet and other information. ! * </p> ! * <p> ! * It represents the following XML block in itself and provides the methods to access ! * those values. ! * <br><br> ! * <pre> ! * <job-controller-config> ! * <job-controller controller-class-name="org.jmonks.batchserver.framework.controller.pool.PoolJobController" ! * xml-factory-config-class-name="org.jmonks.batchserver.framework.config.xml.XMLPoolJobController" ! * db-factory-config-class-name="org.jmonks.batchserver.framework.config.xml.DBPoolJobController"/> ! * </job-controller-config> ! * </pre> ! * </p> ! */ ! public class JobControllerConfig ! { ! /** ! * Tag name represents the controller config in framework configuration file. ! */ ! private static final String TAG_NAME = "job-controller-config"; ! /** ! * Tag name defines the each controller. ! */ ! private static final String JOB_CONTROLLER_TAG_NAME = "job-controller"; ! /** ! * Attribute name defines the controller class name. ! */ ! private static final String JOB_CONTROLLER_CLASS_ATTRIB_NAME = "controller-class-name"; ! /** ! * Map holds the controller configuration details. controller class name will be used ! * as a key to identify the properties related to that particular controller. ! */ ! private Map controllerProperties=new HashMap(); ! ! private JobControllerConfig(Element controllerConfigElement) ! { ! NodeList controllerNodeList=controllerConfigElement.getElementsByTagName(JobControllerConfig.JOB_CONTROLLER_TAG_NAME); ! for(int i=0;i<controllerNodeList.getLength();i++) ! { ! Element controllerElement=(Element)controllerNodeList.item(i); ! String controllerClassName=controllerElement.getAttribute(JobControllerConfig.JOB_CONTROLLER_CLASS_ATTRIB_NAME); ! if(controllerClassName==null) ! throw new ConfigurationException(ErrorCode.CONTROLLER_CLASS_NAME_ATTRIB_NOT_FOUND); ! else ! { ! Map controllerPropertyMap=new HashMap(); ! this.controllerProperties.put(controllerClassName, controllerPropertyMap); ! NamedNodeMap controllerAttributes=controllerElement.getAttributes(); ! for(int j=0;j<controllerAttributes.getLength();j++) ! { ! Node controllerAttribute=controllerAttributes.item(j); ! String attribName=controllerAttribute.getNodeName(); ! /** ! * Skip the controller-class-name attribute here. ! */ ! if(!controllerClassName.equals(attribName)) ! { ! controllerPropertyMap.put(attribName,controllerAttribute.getNodeValue()); ! } ! } ! } ! } ! } ! ! /** ! * Gets the controller configuration class name from the controller config related ! * to the requested factory. ! * ! * @param controllerClassName Complete class name of the controller. ! * @param factoryIdentier Name of the factory identifier attribute. ! * ! * @return Returns the controller configuration class name of that particular factory, null, if it couldnt found. ! */ ! public String getConfigClassName(String controllerClassName,String factoryIdentifier) ! { ! Map controllerMap=(Map)this.controllerProperties.get(controllerClassName); ! return (String)controllerMap.get(factoryIdentifier); ! } ! /** ! * <p> ! * Returns the string representation of JobControllerConfig class in the format ! * <br> {JobControllerConfig [controllerProperties = value]} ! * </p> ! * ! * @return Returns the string representation of JobControllerConfig. ! */ ! public String toString() ! { ! StringBuffer stringValue=new StringBuffer("{JobControllerConfig "); ! stringValue.append("[controllerProperties = " + this.controllerProperties + "]"); ! stringValue.append("}"); ! return stringValue.toString(); ! } ! ! } /** * <p> * Returns the string representation of FrameworkConfig class in the format * <br> {FrameworkConfig [jobConfigFactoryConfig = value] [loggingConfig = value] ! * [mgmtMntrConfig = value] [repositoryConfig = value][controllerConfig = value]} * </p> * *************** *** 620,623 **** --- 745,749 ---- stringValue.append("[mgmtMntrConfig = " + this.mgmtMntrConfig + "]"); stringValue.append("[repositoryConfig = " + this.repositoryConfig + "]"); + stringValue.append("[controllerConfig = " + this.controllerConfig + "]"); stringValue.append("}"); return stringValue.toString(); Index: JobConfigFactory.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/JobConfigFactory.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** JobConfigFactory.java 7 Mar 2006 23:33:06 -0000 1.3 --- JobConfigFactory.java 8 Mar 2006 05:18:55 -0000 1.4 *************** *** 64,71 **** { Class factoryClass=Class.forName(factoryClassName); ! Constructor factoryConstructor=factoryClass.getConstructor(Map.class); if(JobConfigFactory.class.isAssignableFrom(factoryClass)) { ! factoryObject=(JobConfigFactory)factoryConstructor.newInstance(factoryConfig.getJobConfigFactoryProperties()); } else --- 64,71 ---- { Class factoryClass=Class.forName(factoryClassName); ! Constructor factoryConstructor=factoryClass.getConstructor(new Class[]{Map.class}); if(JobConfigFactory.class.isAssignableFrom(factoryClass)) { ! factoryObject=(JobConfigFactory)factoryConstructor.newInstance(new Object[]{factoryConfig.getJobConfigFactoryProperties()}); } else Index: framework-config.xml =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/framework-config.xml,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** framework-config.xml 7 Mar 2006 23:33:06 -0000 1.5 --- framework-config.xml 8 Mar 2006 05:18:55 -0000 1.6 *************** *** 25,27 **** --- 25,35 ---- </job-config-reader-config> --> + <job-controller-config> + <job-controller controller-class-name="org.jmonks.batchserver.framework.controller.pool.PoolJobController" + xml-factory-config-class-name="org.jmonks.batchserver.framework.config.xml.XMLPoolJobController" + db-factory-config-class-name="org.jmonks.batchserver.framework.config.xml.DBPoolJobController"/> + <job-controller controller-class-name="org.jmonks.batchserver.framework.controller.pool.BasicJobController" + xml-factory-config-class-name="org.jmonks.batchserver.framework.config.xml.XMLBasicJobController" + db-factory-config-class-name="org.jmonks.batchserver.framework.config.xml.DBBasicJobController"/> + </job-controller-config> </framework-config> \ No newline at end of file Index: JobControllerConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/JobControllerConfig.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** JobControllerConfig.java 3 Mar 2006 04:19:56 -0000 1.1 --- JobControllerConfig.java 8 Mar 2006 05:18:55 -0000 1.2 *************** *** 10,44 **** package org.jmonks.batchserver.framework.config; import java.util.Map; /** * ! * @author Suresh Pragada */ public abstract class JobControllerConfig { ! protected String mJobControllerClassName=null; ! ! protected Map mJobControllerConfigProps=null; public String getJobControllerClasName() { ! return this.mJobControllerClassName; } ! public Map getJobControllerConfigProperties() { ! return this.mJobControllerConfigProps; } /** ! * Overrides all the config properties by taking the prefix from sub classes. */ public void overrideConfigProperties(Map newProps) { ! } ! protected abstract String getJobControllerConfigPropertyPrefix(); } --- 10,106 ---- package org.jmonks.batchserver.framework.config; + import java.util.Iterator; import java.util.Map; /** + * <p> + * JobControllerConfig represents the configuration needed for the Controller componenet. + * There could be different implementation of the controller componenet. Each controller + * componenet can have different configurations. So, this class provides the basic features + * required by all the controllers. Each controller will have specific controller config which + * extends this base interface and provide the extra features required by that specific + * controller implementation. + * </p> + * <p> + * By specifying the controller class name, job defines the controller that it wants to use. + * Each controller will take some additional parameters for their opertations. So + * every controller will have the class name and properties. + * </p> * ! * @author Suresh Pragada ! * @version 1.0 ! * @since 1.0 */ public abstract class JobControllerConfig { ! /** ! * Class name that defines the kind of controller job wants to use. ! */ ! protected String jobControllerClassName=null; + /** + * Map holds the required properties support the specified controller. + */ + protected Map jobControllerConfigProps=null; + + /** + * Gets the job controller class name. + * + * @return Returns the controller class name. + */ public String getJobControllerClasName() { ! return this.jobControllerClassName; } ! /** ! * Gets the map contains the properties required by the controller. ! * ! * @return Returns the properites in a map. ! */ public Map getJobControllerConfigProperties() { ! return this.jobControllerConfigProps; } /** ! * Overrides all the configuration properties defined for the controller by ! * the new properties in the incoming map. This identifies the properties needs to be ! * modified by getting the prefix for this controller by calling the method ! * <b>getJobControllerConfigPropertyPrefix</b> on the controller specific config. ! * If any property defined newProps starting with controller config prefix, ! * doesnt exist in controller defined props, it will add that property to the ! * controller map. ! * ! * @param newProps Map contains the new properties. */ public void overrideConfigProperties(Map newProps) { ! if(newProps==null ) ! return; ! ! String configPrefix=this.getJobControllerConfigPropertyPrefix(); ! if(configPrefix==null) ! configPrefix=""; ! ! for(Iterator iterator=newProps.keySet().iterator();iterator.hasNext();) ! { ! String key=(String)iterator.next(); ! ! if(key.startsWith(configPrefix)) ! { ! this.jobControllerConfigProps.put(key, newProps.get(key)); ! } ! ! } } ! ! /** ! * Gets the common prefix all the properties of this controller cann be identified with. ! * Each controller can have different properties. This defines the common prefix of all those ! * properties. ! * ! * @return Returns the prefix of all the properties. ! */ protected abstract String getJobControllerConfigPropertyPrefix(); } Index: PoolJobControllerConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/PoolJobControllerConfig.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PoolJobControllerConfig.java 3 Mar 2006 04:19:56 -0000 1.1 --- PoolJobControllerConfig.java 8 Mar 2006 05:18:55 -0000 1.2 *************** *** 14,61 **** /** * ! * @author Suresh Pragada */ public abstract class PoolJobControllerConfig extends JobControllerConfig { protected final static String CONFIG_PROPERTY_PREFIX = "pool-job-controller-"; ! protected String mPoolJobLoaderClassName=null; ! protected Map mPoolJobLoaderConfigProps=null; ! protected String mPoolJobProcessorClassName=null; ! protected Map mPoolJobProcessorConfigProps=null; ! protected String mPoolClassName=null; ! protected Map mPoolConfigProps=null; public String getPoolJobLoaderClassName() { ! return this.mPoolJobLoaderClassName; } public Map getPoolJobLoaderConfigProperties() { ! return this.mPoolJobLoaderConfigProps; } public String getPoolJobProcessorClassName() { ! return this.mPoolJobProcessorClassName; } public Map getPoolJobProcessorConfigProperties() { ! return this.mPoolJobProcessorConfigProps; } public String getPoolClassName() { ! return this.mPoolClassName; } public Map getPoolConfigProperties() { ! return this.mPoolConfigProps; } protected String getJobControllerConfigPropertyPrefix() { --- 14,123 ---- /** + * <p> + * PoolJobControllerConfig represents the controller congiguration needed by + * PoolJobController. + * </p> * ! * @author Suresh Pragada ! * @since 1.0 ! * @version 1.0 */ public abstract class PoolJobControllerConfig extends JobControllerConfig { + /** + * Common pool controller property prefix. + */ protected final static String CONFIG_PROPERTY_PREFIX = "pool-job-controller-"; ! /** ! * Pool job loader class name. ! */ ! protected String poolJobLoaderClassName=null; ! /** ! * Map contains the properties needed by pool job loader. ! */ ! protected Map poolJobLoaderConfigProps=null; ! /** ! * Pool job processor class name. ! */ ! protected String poolJobProcessorClassName=null; ! /** ! * Map contains the properties needed by pool job processor. ! */ ! protected Map poolJobProcessorConfigProps=null; ! /** ! * Pool class name. ! */ ! protected String poolClassName=null; ! /** ! * Map contains the properties needed by pool class. ! */ ! protected Map poolConfigProps=null; + /** + * Gets the pool job loader class name. + * + * @return Returns the pool job loader class name. + */ public String getPoolJobLoaderClassName() { ! return this.poolJobLoaderClassName; } + /** + * Gets the map contains the properties needed by pool job loader. + * + * @return Returns the map contains the properties. + */ public Map getPoolJobLoaderConfigProperties() { ! return this.poolJobLoaderConfigProps; } + /** + * Gets the pool job processor class name. + * + * @return Returns the pool job processor class name. + */ public String getPoolJobProcessorClassName() { ! return this.poolJobProcessorClassName; } + /** + * Gets the map contains the properties needed by pool job processor. + * + * @return Returns the map contains properties. + */ public Map getPoolJobProcessorConfigProperties() { ! return this.poolJobProcessorConfigProps; } + /** + * Gets the pool class name. + * + * @return Retruns the pool class name. + */ public String getPoolClassName() { ! return this.poolClassName; } + /** + * Gets the map contains properties needed by the pool class. + * + * @return Returns the map contains properties. + */ public Map getPoolConfigProperties() { ! return this.poolConfigProps; } + /** + * Gets the common pool controller property prefix. + * + * @return Returns the common property prefix. + */ protected String getJobControllerConfigPropertyPrefix() { *************** *** 67,70 **** --- 129,134 ---- * So, override all the props like loader, process and pool here along with controller * config props. + * + * @param newProps Properties needs to be overriden. */ public void overrideConfigProperties(Map newProps) |
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/xml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21676 Modified Files: XMLBasicJobControllerConfig.java XMLJobConfig.java XMLJobControllerConfig.java XMLPoolJobControllerConfig.java Log Message: no message Index: XMLBasicJobControllerConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/xml/XMLBasicJobControllerConfig.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** XMLBasicJobControllerConfig.java 3 Mar 2006 04:19:57 -0000 1.1 --- XMLBasicJobControllerConfig.java 8 Mar 2006 05:17:48 -0000 1.2 *************** *** 15,28 **** /** * ! * @author Suresh Pragada */ public class XMLBasicJobControllerConfig extends BasicJobControllerConfig { ! /** Creates a new instance of XMLBasicJobControllerConfig */ XMLBasicJobControllerConfig(Element controllerConfigElement) { } - } --- 15,48 ---- /** + * <p> + * XMLBasicJobControllerConfig loads the XML job controller configuration. This loads + * the following XML block in <job-config> from job configuration file. + * <br><br> + * <pre> + * <job-controller job-controller-class-name="org.jmonks.batchserver.framework.controller.basic.BasicJobController"> + * <basic-job-processor basic-job-processor-class-name="com.mycompany.batch.processfilexyz.XyzProcessor"> + * <property key="basic-job-processor-key1">processor-value1</property> + * </basic-job-processor> + * <property key="basic-job-controller-restart">true</property> + * </job-controller> + * </pre> + * </p> * ! * @author Suresh Pragada ! * @version 1.0 ! * @since 1.0 */ public class XMLBasicJobControllerConfig extends BasicJobControllerConfig { ! /** ! * Loads the XML job controller configuration into XMLBasicJobControllerConfig object. ! * ! * @param controllerConfigElement XML DOM Element represents the <job-controller> element; ! * ! * @throws ConfigurationException If controller class name or job processor name doest not found. ! */ XMLBasicJobControllerConfig(Element controllerConfigElement) { } } Index: XMLPoolJobControllerConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/xml/XMLPoolJobControllerConfig.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** XMLPoolJobControllerConfig.java 3 Mar 2006 04:19:57 -0000 1.1 --- XMLPoolJobControllerConfig.java 8 Mar 2006 05:17:48 -0000 1.2 *************** *** 15,24 **** /** ! * ! * @author Suresh Pragada */ public class XMLPoolJobControllerConfig extends PoolJobControllerConfig { ! /** Creates a new instance of XMLPoolJobControllerConfig */ XMLPoolJobControllerConfig(Element controllerConfigElement) { --- 15,50 ---- /** ! * <p> ! * XMLPoolJobControllerConfig loads the controller configuration from XML Job controller ! * configuration. This reads the following XML block and loads the XMLPoolJobControllerConfig. ! * <br><br> ! * <pre> ! * <job-controller job-controller-class-name="org.jmonks.batchserver.framework.controller.pool.PoolJobController"> ! * <pool-job-loader pool-job-loader-class-name="com.mycompany.batch.processfileabc.AbcJobLoader"> ! * <property key="pool-job-loader-key1">loader-value1</property> ! * </pool-job-loader> ! * <pool-job-processor pool-job-processor-class-name="com.mycompany.batch.processfileabc.AbcJobLoader" thread-count="1"> ! * <property key="pool-job-processor-key1">processor-value1</property> ! * </pool-job-processor> ! * <job-pool job-pool-class-name="org.jmonks.batchserver.framework.controller.pool.DefaultJobPool"> ! * <property key="job-pool-size">50000</property> ! * </job-pool> ! * <property key="pool-job-controller-restart">true</property> ! * </job-controller> ! * </pre> ! * </p> ! * @author Suresh Pragada ! * @version 1.0 ! * @since 1.0 */ public class XMLPoolJobControllerConfig extends PoolJobControllerConfig { ! /** ! * Loads the XMLPoolJobControllerConfig from XML DOM Element <job-controller> ! * ! * @param controllerConfigElement XML DOM Element represents the <job-controller> element. ! * ! * @throws ConfigurationException If controller class name not defined or required controller properties missing. ! */ XMLPoolJobControllerConfig(Element controllerConfigElement) { Index: XMLJobControllerConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/xml/XMLJobControllerConfig.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** XMLJobControllerConfig.java 8 Mar 2006 00:31:12 -0000 1.2 --- XMLJobControllerConfig.java 8 Mar 2006 05:17:48 -0000 1.3 *************** *** 11,14 **** --- 11,19 ---- package org.jmonks.batchserver.framework.config.xml; + import java.lang.reflect.Constructor; + import java.lang.reflect.InvocationTargetException; + import org.jmonks.batchserver.framework.common.ErrorCode; + import org.jmonks.batchserver.framework.config.ConfigurationException; + import org.jmonks.batchserver.framework.config.FrameworkConfig; import org.jmonks.batchserver.framework.config.JobControllerConfig; import org.w3c.dom.Element; *************** *** 23,31 **** * Element name that identifies the job controller configuration. */ ! public static final String JOB_CONTROLLER_CONFIG_ELEMENT_NAME = "job-controller"; ! public static JobControllerConfig getJobControllerConfig(Element controllerConfigElement) { ! return null; } } --- 28,93 ---- * Element name that identifies the job controller configuration. */ ! public static final String JOB_CONTROLLER_ELEMENT_NAME = "job-controller"; ! /** ! * Attribute name that identifies the job controller class name. ! */ ! public static final String JOB_CONTROLLER_CLASS_ATTRIBUTE_NAME = "job-controller-class-name"; ! /** ! * Element name that identifies the job controller configuration class name. ! */ ! public static final String JOB_CONTROLLER_CONFIG_FACTORY_CLASS_ATTRIBUTE_NAME = "xml-factory-config-class-name"; ! /** ! * ! * @throws ConfigurationException If controller config class name is not defined. ! */ public static JobControllerConfig getJobControllerConfig(Element controllerConfigElement) { ! JobControllerConfig controllerConfig=null; ! ! String controllerClassName=controllerConfigElement.getAttribute(XMLJobControllerConfig.JOB_CONTROLLER_CLASS_ATTRIBUTE_NAME); ! if(controllerClassName==null) ! throw new ConfigurationException(ErrorCode.JOB_CONTROLLER_CLASS_NOT_DEFINED); ! else ! { ! try ! { ! String controllerConfigClassName=FrameworkConfig.getInstance().getJobControllerConfig().getConfigClassName(controllerClassName, XMLJobControllerConfig.JOB_CONTROLLER_CONFIG_FACTORY_CLASS_ATTRIBUTE_NAME); ! if(controllerConfigClassName==null) ! throw new ConfigurationException(ErrorCode.JOB_CONTROLLER_CLASS_NOT_DEFINED); ! else ! { ! Class configClass=Class.forName(controllerConfigClassName); ! Constructor constructor=configClass.getConstructor(new Class[]{Element.class}); ! controllerConfig=(JobControllerConfig)constructor.newInstance(new Object[]{controllerConfigElement}); ! } ! } ! catch(InstantiationException exception) ! { ! exception.printStackTrace(); ! throw new ConfigurationException(ErrorCode.JOB_CONTROLLER_CONFIG_CLASS_NOT_VALID); ! } ! catch(NoSuchMethodException exception) ! { ! exception.printStackTrace(); ! throw new ConfigurationException(ErrorCode.JOB_CONTROLLER_CONFIG_CLASS_NOT_VALID); ! } ! catch(ClassNotFoundException exception) ! { ! exception.printStackTrace(); ! throw new ConfigurationException(ErrorCode.JOB_CONTROLLER_CONFIG_CLASS_NOT_VALID); ! } ! catch(IllegalAccessException exception) ! { ! exception.printStackTrace(); ! throw new ConfigurationException(ErrorCode.JOB_CONTROLLER_CONFIG_CLASS_NOT_VALID); ! } ! catch(InvocationTargetException exception) ! { ! exception.printStackTrace(); ! throw new ConfigurationException(ErrorCode.JOB_CONTROLLER_CONFIG_CLASS_NOT_VALID); ! } ! } ! ! return controllerConfig; } } Index: XMLJobConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/xml/XMLJobConfig.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** XMLJobConfig.java 8 Mar 2006 00:31:12 -0000 1.3 --- XMLJobConfig.java 8 Mar 2006 05:17:48 -0000 1.4 *************** *** 26,31 **** * <pre> * <job-config job-name="process_file_xyz"> ! * <job-controller job-controller-class-name="org.jmonks.batchserver.framework.controller.basic.BasicJobController" ! * job-controller-config-class-name="org.jmonks.batchserver.framework.config.BasicJobControllerConfig"> * <basic-job-processor basic-job-processor-class-name="com.mycompany.batch.processfilexyz.XyzProcessor"> * <property key="basic-job-processor-key1">processor-value1</property> --- 26,30 ---- * <pre> * <job-config job-name="process_file_xyz"> ! * <job-controller job-controller-class-name="org.jmonks.batchserver.framework.controller.basic.BasicJobController"> * <basic-job-processor basic-job-processor-class-name="com.mycompany.batch.processfilexyz.XyzProcessor"> * <property key="basic-job-processor-key1">processor-value1</property> *************** *** 62,66 **** { this.jobName=jobConfigElement.getAttribute(XMLJobConfig.JOB_NAME_ATTRIBUTE_NAME); ! NodeList controllerConfigNodeList=jobConfigElement.getElementsByTagName(XMLJobControllerConfig.JOB_CONTROLLER_CONFIG_ELEMENT_NAME); if(controllerConfigNodeList.getLength()==1) { --- 61,65 ---- { this.jobName=jobConfigElement.getAttribute(XMLJobConfig.JOB_NAME_ATTRIBUTE_NAME); ! NodeList controllerConfigNodeList=jobConfigElement.getElementsByTagName(XMLJobControllerConfig.JOB_CONTROLLER_ELEMENT_NAME); if(controllerConfigNodeList.getLength()==1) { |
From: Suresh <sur...@us...> - 2006-03-08 05:17:13
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21288 Modified Files: ErrorCode.java Log Message: no message Index: ErrorCode.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/common/ErrorCode.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ErrorCode.java 8 Mar 2006 00:30:35 -0000 1.6 --- ErrorCode.java 8 Mar 2006 05:17:08 -0000 1.7 *************** *** 91,94 **** --- 91,96 ---- public static final ErrorCode MGMT_MNTR_CLASS_NAME_ATTRIB_NOT_FOUND = new ErrorCode(1009,"Attribute mgmt-mntr-class-name not found in mgmt-mntr-config element"); public static final ErrorCode REPOSITORY_CLASS_NAME_ATTRIB_NOT_FOUND = new ErrorCode(1010,"Attribute repository-class-name not found in repository-config element"); + public static final ErrorCode CONTROLLER_CLASS_NAME_ATTRIB_NOT_FOUND = new ErrorCode(1011,"Attribute controller-class-name not found in job-controller element"); + public static final ErrorCode NONE_OR_MULITPLE_JOB_CONTROLLER_CONFIG_TAGS = new ErrorCode(1012,"None or multiple job-controller-config elements found in framework configuration"); /** *************** *** 104,107 **** --- 106,112 ---- public static final ErrorCode NO_BATCH_CONFIG_ELEMENT_IN_XML_JOB_CONFIGURATION = new ErrorCode(2008,"could not load the batch-config element from the defined XML job configuration file"); public static final ErrorCode NONE_OR_MULTIPLE_JOB_CONTROLLER_CONFIGS = new ErrorCode(2009,"None or multiple job-controller configurations found in job-config element"); + public static final ErrorCode JOB_CONTROLLER_CLASS_NOT_DEFINED = new ErrorCode(2010,"job-controller-class-name is not defined in job-controller"); + public static final ErrorCode JOB_CONTROLLER_CONFIG_CLASS_NOT_DEFINED = new ErrorCode(2011,"job controller config class is not defined in framework configuration"); + public static final ErrorCode JOB_CONTROLLER_CONFIG_CLASS_NOT_VALID = new ErrorCode(2012,"job controller config class is not a valid"); } |
From: Suresh <sur...@us...> - 2006-03-08 00:31:17
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/xml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17000 Modified Files: XMLJobConfig.java XMLJobConfigFactory.java XMLJobControllerConfig.java Log Message: no message Index: XMLJobConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/xml/XMLJobConfig.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** XMLJobConfig.java 7 Mar 2006 23:33:23 -0000 1.2 --- XMLJobConfig.java 8 Mar 2006 00:31:12 -0000 1.3 *************** *** 11,19 **** package org.jmonks.batchserver.framework.config.xml; import org.jmonks.batchserver.framework.config.JobConfig; import org.w3c.dom.Element; /** ! * XMLJobConfig provides the implementation of JobConfig * @author Suresh Pragada * @since 1.0 --- 11,40 ---- package org.jmonks.batchserver.framework.config.xml; + import org.jmonks.batchserver.framework.common.ErrorCode; + import org.jmonks.batchserver.framework.config.ConfigurationException; import org.jmonks.batchserver.framework.config.JobConfig; import org.w3c.dom.Element; + import org.w3c.dom.NodeList; /** ! * <p> ! * XMLJobConfig provides the implementation of JobConfig by reading the ! * job configuration from XML DOM element <job-config> configured in the ! * job configuration file. This reads and represents the following piece of XML ! * block from job configuration file. ! * <br><br> ! * <pre> ! * <job-config job-name="process_file_xyz"> ! * <job-controller job-controller-class-name="org.jmonks.batchserver.framework.controller.basic.BasicJobController" ! * job-controller-config-class-name="org.jmonks.batchserver.framework.config.BasicJobControllerConfig"> ! * <basic-job-processor basic-job-processor-class-name="com.mycompany.batch.processfilexyz.XyzProcessor"> ! * <property key="basic-job-processor-key1">processor-value1</property> ! * </basic-job-processor> ! * <property key="basic-job-controller-restart">true</property> ! * </job-controller> ! * </job-config> ! * </pre> ! * </p> ! * * @author Suresh Pragada * @since 1.0 *************** *** 22,31 **** public class XMLJobConfig extends JobConfig { ! /** Creates a new instance of XMLJobConfig */ XMLJobConfig(Element jobConfigElement) { ! /** ! * Load the configuration properties ! */ } --- 43,73 ---- public class XMLJobConfig extends JobConfig { ! /** ! * Element name that identifies the job configuration. ! */ ! public static final String JOB_CONFIG_ELEMENT_NAME = "job-config"; ! /** ! * Attribute name that identifies the job name. ! */ ! public static final String JOB_NAME_ATTRIBUTE_NAME = "job-name"; ! /** ! * Loads the job name and controller configuration into the job configuration object. ! * ! * @param jobConfigElement XML DOM Element that represents the <job-confg> ! * element in batch job configuration file. ! * ! * @throws ConfigurationException If more than one job controllers are found in job configuration. ! */ XMLJobConfig(Element jobConfigElement) { ! this.jobName=jobConfigElement.getAttribute(XMLJobConfig.JOB_NAME_ATTRIBUTE_NAME); ! NodeList controllerConfigNodeList=jobConfigElement.getElementsByTagName(XMLJobControllerConfig.JOB_CONTROLLER_CONFIG_ELEMENT_NAME); ! if(controllerConfigNodeList.getLength()==1) ! { ! Element controllerConfigElement=(Element)controllerConfigNodeList.item(0); ! this.jobControllerConfig=XMLJobControllerConfig.getJobControllerConfig(controllerConfigElement); ! } ! else ! throw new ConfigurationException(ErrorCode.NONE_OR_MULTIPLE_JOB_CONTROLLER_CONFIGS); } Index: XMLJobControllerConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/xml/XMLJobControllerConfig.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** XMLJobControllerConfig.java 3 Mar 2006 04:19:57 -0000 1.1 --- XMLJobControllerConfig.java 8 Mar 2006 00:31:12 -0000 1.2 *************** *** 20,23 **** --- 20,28 ---- public abstract class XMLJobControllerConfig extends JobControllerConfig { + /** + * Element name that identifies the job controller configuration. + */ + public static final String JOB_CONTROLLER_CONFIG_ELEMENT_NAME = "job-controller"; + public static JobControllerConfig getJobControllerConfig(Element controllerConfigElement) { Index: XMLJobConfigFactory.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/xml/XMLJobConfigFactory.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** XMLJobConfigFactory.java 7 Mar 2006 23:33:23 -0000 1.2 --- XMLJobConfigFactory.java 8 Mar 2006 00:31:12 -0000 1.3 *************** *** 64,75 **** private static final String PROPERTY_JOB_CONFIG_FILE_CLASSPATH_LOCATION = "job-config-file-classpath-location"; /** - * Element name that identifies the job configuration. - */ - private static final String JOB_CONFIG_ELEMENT_NAME = "job-config"; - /** - * Attribute name that identifies the job name. - */ - private static final String JOB_NAME_ATTRIBUTE_NAME = "job-name"; - /** * Property map holds the properites required by this factory. */ --- 64,67 ---- *************** *** 165,173 **** throw new IllegalArgumentException("jobName cannot be null."); ! NodeList jobConfigNodeList=this.batchConfigElement.getElementsByTagName(XMLJobConfigFactory.JOB_CONFIG_ELEMENT_NAME); for(int i=0;i<jobConfigNodeList.getLength();i++) { Element jobConfigElement=(Element)jobConfigNodeList.item(i); ! String elementJobName=jobConfigElement.getAttribute(XMLJobConfigFactory.JOB_NAME_ATTRIBUTE_NAME); if(jobName.equals(elementJobName)) { --- 157,165 ---- throw new IllegalArgumentException("jobName cannot be null."); ! NodeList jobConfigNodeList=this.batchConfigElement.getElementsByTagName(XMLJobConfig.JOB_CONFIG_ELEMENT_NAME); for(int i=0;i<jobConfigNodeList.getLength();i++) { Element jobConfigElement=(Element)jobConfigNodeList.item(i); ! String elementJobName=jobConfigElement.getAttribute(XMLJobConfig.JOB_NAME_ATTRIBUTE_NAME); if(jobName.equals(elementJobName)) { |
From: Suresh <sur...@us...> - 2006-03-08 00:30:58
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16848 Modified Files: batch-config.xml JobConfig.java Log Message: no message Index: JobConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/JobConfig.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** JobConfig.java 7 Mar 2006 23:33:06 -0000 1.3 --- JobConfig.java 8 Mar 2006 00:30:49 -0000 1.4 *************** *** 34,38 **** * Controller configuration of the job. */ ! private JobControllerConfig jobControllerConfig; /** --- 34,38 ---- * Controller configuration of the job. */ ! protected JobControllerConfig jobControllerConfig; /** Index: batch-config.xml =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/batch-config.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** batch-config.xml 3 Mar 2006 04:14:11 -0000 1.3 --- batch-config.xml 8 Mar 2006 00:30:49 -0000 1.4 *************** *** 17,21 **** </job-controller> </job-config> ! <job-config> <job-controller job-controller-class-name="org.jmonks.batchserver.framework.controller.basic.BasicJobController" job-controller-config-class-name="org.jmonks.batchserver.framework.config.BasicJobControllerConfig"> --- 17,21 ---- </job-controller> </job-config> ! <job-config job-name="process_file_xyz"> <job-controller job-controller-class-name="org.jmonks.batchserver.framework.controller.basic.BasicJobController" job-controller-config-class-name="org.jmonks.batchserver.framework.config.BasicJobControllerConfig"> |
From: Suresh <sur...@us...> - 2006-03-08 00:30:41
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16726 Modified Files: ErrorCode.java Log Message: no message Index: ErrorCode.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/common/ErrorCode.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ErrorCode.java 7 Mar 2006 23:25:28 -0000 1.5 --- ErrorCode.java 8 Mar 2006 00:30:35 -0000 1.6 *************** *** 103,106 **** --- 103,107 ---- public static final ErrorCode XML_JOB_CONFIG_FACTORY_INVALID_CLASSPATH_LOCATION = new ErrorCode(2006,"defined classpath location for the XML Job Configiguation file is not valid"); public static final ErrorCode NO_BATCH_CONFIG_ELEMENT_IN_XML_JOB_CONFIGURATION = new ErrorCode(2008,"could not load the batch-config element from the defined XML job configuration file"); + public static final ErrorCode NONE_OR_MULTIPLE_JOB_CONTROLLER_CONFIGS = new ErrorCode(2009,"None or multiple job-controller configurations found in job-config element"); } |
From: Suresh <sur...@us...> - 2006-03-07 23:33:29
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/xml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20701 Modified Files: XMLJobConfig.java XMLJobConfigFactory.java Log Message: no message Index: XMLJobConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/xml/XMLJobConfig.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** XMLJobConfig.java 3 Mar 2006 04:19:57 -0000 1.1 --- XMLJobConfig.java 7 Mar 2006 23:33:23 -0000 1.2 *************** *** 15,20 **** /** ! * ! * @author Suresh Pragada */ public class XMLJobConfig extends JobConfig --- 15,22 ---- /** ! * XMLJobConfig provides the implementation of JobConfig ! * @author Suresh Pragada ! * @since 1.0 ! * @version 1.0 */ public class XMLJobConfig extends JobConfig Index: XMLJobConfigFactory.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/xml/XMLJobConfigFactory.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** XMLJobConfigFactory.java 3 Mar 2006 04:19:57 -0000 1.1 --- XMLJobConfigFactory.java 7 Mar 2006 23:33:23 -0000 1.2 *************** *** 11,37 **** package org.jmonks.batchserver.framework.config.xml; import java.util.Map; import org.jmonks.batchserver.framework.config.JobConfig; import org.jmonks.batchserver.framework.config.JobConfigFactory; /** * ! * @author Suresh Pragada */ public class XMLJobConfigFactory extends JobConfigFactory { ! private Map mConfigFactoryProps=null; ! /** Creates a new instance of XMLJobConfigFactory */ public XMLJobConfigFactory(Map configFactoryProps) { } ! public JobConfig getJobConfig(String jobName) { /** ! * Look up XML configuration for jobName and pass that element. */ ! return new XMLJobConfig(null); } } --- 11,236 ---- package org.jmonks.batchserver.framework.config.xml; + import java.io.File; + import java.io.FileInputStream; + import java.io.FileNotFoundException; + import java.io.IOException; + import java.io.InputStream; import java.util.Map; + import javax.xml.parsers.DocumentBuilder; + import javax.xml.parsers.DocumentBuilderFactory; + import javax.xml.parsers.ParserConfigurationException; + import org.jmonks.batchserver.framework.common.ErrorCode; + import org.jmonks.batchserver.framework.config.ConfigurationException; import org.jmonks.batchserver.framework.config.JobConfig; import org.jmonks.batchserver.framework.config.JobConfigFactory; + import org.w3c.dom.Document; + import org.w3c.dom.Element; + import org.w3c.dom.NodeList; + import org.xml.sax.SAXException; /** + * <p> + * XMLJobConfigFactory reads the job configuration from XML file to create the + * configuration objects needed by the job. This factory looks for few properties + * in the config properties map to identify the source of the XML file. The source of + * the XML file can be defined as absolute path on the file system or resource on the + * class path. + * </p> + * <p> + * Following are the two properties, this factory looks to find the source. If it find + * these two it will give priority to the physical absolute path location. + * <table> + * <tr><td><b>property key</b></td><td><b>property value</b></td></tr> + * <tr><td>job-config-file-absolute-location</td><td>/batchserver/config/batch-config.xml</td></tr> + * <tr><td>job-config-file-classpath-location</td><td>batch-config.xml</td></tr> + * </table> + * These properties can be configured using <property> element in the <job-config-factory-config> element + * in the framework configuration file. + * </p> * ! * @author Suresh Pragada ! * @version 1.0 ! * @since 1.0 */ public class XMLJobConfigFactory extends JobConfigFactory { ! /** ! * Constant defines the property name of config file absolute location. ! */ ! private static final String PROPERTY_JOB_CONFIG_FILE_ABSOLUTE_LOCATION = "job-config-file-absolute-location"; ! /** ! * Constant defines the property name of config file classpath location. ! */ ! private static final String PROPERTY_JOB_CONFIG_FILE_CLASSPATH_LOCATION = "job-config-file-classpath-location"; ! /** ! * Element name that identifies the job configuration. ! */ ! private static final String JOB_CONFIG_ELEMENT_NAME = "job-config"; ! /** ! * Attribute name that identifies the job name. ! */ ! private static final String JOB_NAME_ATTRIBUTE_NAME = "job-name"; ! /** ! * Property map holds the properites required by this factory. ! */ ! private Map configFactoryProps=null; ! ! /** ! * batch-config element in the XML configuration file. ! */ ! private Element batchConfigElement=null; ! ! /** ! * This constructor initializes the factory by accepting the required properties ! * map as a parameter to the constructor. If it doesnt find any required properties ! * to initialize the factory, throws ConfigurationException with the appropriate error code. ! * ! * @param configFactoryProps Map consists of all the properties defined for this factory. ! * ! * @throws ConfigurationException If required properties are missing. ! */ public XMLJobConfigFactory(Map configFactoryProps) { + this.configFactoryProps=configFactoryProps; + + String absoluteLocation=(String)this.configFactoryProps.get(XMLJobConfigFactory.PROPERTY_JOB_CONFIG_FILE_ABSOLUTE_LOCATION); + String classpathLocation=(String)this.configFactoryProps.get(XMLJobConfigFactory.PROPERTY_JOB_CONFIG_FILE_CLASSPATH_LOCATION); + if(absoluteLocation==null && classpathLocation==null) + throw new ConfigurationException(ErrorCode.XML_JOB_CONFIG_FACTORY_PROPERTIES_MISSING); + else if(absoluteLocation!=null) + { + /** + * Look for the absolute location property and load the stream. + * If file is not found or the given entry is not a file throw configuration exception. + */ + try + { + File jobConfigFile=new File(absoluteLocation); + if(jobConfigFile.exists() && jobConfigFile.isFile()) + { + InputStream inputStream=new FileInputStream(jobConfigFile); + if(!this.createBatchConfigElement(inputStream)) + throw new ConfigurationException(ErrorCode.NO_BATCH_CONFIG_ELEMENT_IN_XML_JOB_CONFIGURATION); + } + else + throw new ConfigurationException(ErrorCode.XML_JOB_CONFIG_FACTORY_INVALID_ABS_LOCATION); + } + catch(FileNotFoundException exception) + { + exception.printStackTrace(); + throw new ConfigurationException(ErrorCode.XML_JOB_CONFIG_FACTORY_INVALID_ABS_LOCATION); + } + } + else if(classpathLocation!=null) + { + /** + * Look for the classpath location property and load the file using classloader. + * If we dont find this file on classpath, throw configuration exception. + */ + InputStream inputStream=XMLJobConfigFactory.class.getClassLoader().getResourceAsStream(classpathLocation); + if(inputStream==null) + throw new ConfigurationException(ErrorCode.XML_JOB_CONFIG_FACTORY_INVALID_CLASSPATH_LOCATION); + else + { + if(!this.createBatchConfigElement(inputStream)) + throw new ConfigurationException(ErrorCode.NO_BATCH_CONFIG_ELEMENT_IN_XML_JOB_CONFIGURATION); + } + } } ! ! /** ! * 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 job configuration file, it returns null. ! * ! * @param jobName Name of the job. ! * ! * @return Returns the job config object if found, null, otherwise. ! * ! * @throws IllegalArgumentException If jobName passed as parameter is null. ! * @throws IllegalStateException If factory is not initialized properly. ! */ public JobConfig getJobConfig(String jobName) { + JobConfig jobConfig=null; /** ! * Look for all the job-config elements and pass the element whose job-name ! * attribute matches the input jobName parameter to the XMLJobConfig. */ ! if(this.batchConfigElement==null) ! throw new IllegalStateException("Factory is not initialized properly. Batch config element is null."); ! ! if(jobName==null) ! throw new IllegalArgumentException("jobName cannot be null."); ! ! NodeList jobConfigNodeList=this.batchConfigElement.getElementsByTagName(XMLJobConfigFactory.JOB_CONFIG_ELEMENT_NAME); ! for(int i=0;i<jobConfigNodeList.getLength();i++) ! { ! Element jobConfigElement=(Element)jobConfigNodeList.item(i); ! String elementJobName=jobConfigElement.getAttribute(XMLJobConfigFactory.JOB_NAME_ATTRIBUTE_NAME); ! if(jobName.equals(elementJobName)) ! { ! jobConfig=new XMLJobConfig(jobConfigElement); ! break; ! } ! } ! return jobConfig; } + + /** + * Creates the DOM Element represents the batch-config element from the given stream + * and assigns it to the class instance varaibale batchConfigElement. + * + * @param jobConfigStream InputStream of XML job configuration file. + * @return Returns true, if it could load the element from the given inputstream, false, otherwise. + */ + private boolean createBatchConfigElement(InputStream jobConfigStream) + { + boolean created=false; + + try + { + DocumentBuilderFactory documentBuilderFactory=DocumentBuilderFactory.newInstance(); + documentBuilderFactory.setValidating(true); + DocumentBuilder documentBuilder=documentBuilderFactory.newDocumentBuilder(); + Document document=documentBuilder.parse(jobConfigStream); + this.batchConfigElement=document.getDocumentElement(); + + if(this.batchConfigElement!=null) + created=true; + } + catch(ParserConfigurationException exception) + { + exception.printStackTrace(); + } + catch(SAXException exception) + { + exception.printStackTrace(); + } + catch(IOException exception) + { + exception.printStackTrace(); + } + + return created; + } + + /** + * <p> + * Returns the string representation of XMLJobConfigFactory class in the format + * <br> {XMLJobConfigFactory [configProperties = value] [element = value]} + * </p> + * + * @return Returns the string representation of XMLJobConfigFactory. + */ + public String toString() + { + StringBuffer stringValue=new StringBuffer("{XMLJobConfigFactory "); + stringValue.append("[configProperties = " + this.configFactoryProps + "]"); + stringValue.append("[element = " + this.batchConfigElement + "]"); + stringValue.append("}"); + return stringValue.toString(); + } + } |
From: Suresh <sur...@us...> - 2006-03-07 23:33:09
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20476 Modified Files: framework-config.xml JobConfig.java JobConfigFactory.java Log Message: no message Index: JobConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/JobConfig.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** JobConfig.java 4 Mar 2006 04:40:49 -0000 1.2 --- JobConfig.java 7 Mar 2006 23:33:06 -0000 1.3 *************** *** 14,36 **** /** * ! * @author Suresh Pragada */ public abstract class JobConfig { ! protected String mJobName=null; ! protected Object mJobControllerConfig=null; ! ! private JobControllerConfig mJobControllerConfig1; ! public Object getJobControllerConfig() { ! return this.mJobControllerConfig; } public String getJobName() { ! return this.mJobName; } } --- 14,75 ---- /** + * <p> + * JobConfig represents the configuration needed to execute the job. This provides + * interface to the different implementations of JobConfig. Each factory will provide + * its own implementation of JobConfig. + * </p> * ! * @author Suresh Pragada ! * @version 1.0 ! * @since 1.0 */ public abstract class JobConfig { ! /** ! * Name of the job this configuration belongs to. ! */ ! protected String jobName=null; ! /** ! * Controller configuration of the job. ! */ ! private JobControllerConfig jobControllerConfig; ! /** ! * Returns the Controller configuraiton of the job this JobConfig represents. ! * ! * @return Returns controller configuration of this job. ! */ ! public JobControllerConfig getJobControllerConfig() { ! return this.jobControllerConfig; } + /** + * Returns the name of the job. + * + * @return Returns the name of the job. + */ public String getJobName() { ! return this.jobName; } + + /** + * <p> + * Returns the string representation of JobConfig class in the format + * <br> {JobConfig [name = value] [controllerConfig = value]} + * </p> + * + * @return Returns the string representation of JobConfig. + */ + public String toString() + { + StringBuffer stringValue=new StringBuffer("{JobConfig "); + stringValue.append("[name = " + this.jobName + "]"); + stringValue.append("[controllerConfig = " + this.jobControllerConfig + "]"); + stringValue.append("}"); + return stringValue.toString(); + } + } Index: JobConfigFactory.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/JobConfigFactory.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** JobConfigFactory.java 7 Mar 2006 03:43:06 -0000 1.2 --- JobConfigFactory.java 7 Mar 2006 23:33:06 -0000 1.3 *************** *** 11,24 **** package org.jmonks.batchserver.framework.config; import org.jmonks.batchserver.framework.common.ErrorCode; /** * <p> ! * This class returns the factory class which in turn returns the job configuration ! * objects from the defined factory. This class determines which factory needs to * be returned is based on the configFactoryClassName defined JobConfigFactoryConfig * object passed as input parameter. This class is based on the AbstractFacotry pattern. * </p> ! * * @author Suresh Pragada * @version 1.0 --- 11,37 ---- package org.jmonks.batchserver.framework.config; + import java.lang.reflect.Constructor; + import java.lang.reflect.InvocationTargetException; + import java.util.Map; import org.jmonks.batchserver.framework.common.ErrorCode; /** * <p> ! * This class returns the factory class which in turn returns the job configuration ! * objects from the defined factory. This class determines which factory needs to * be returned is based on the configFactoryClassName defined JobConfigFactoryConfig * object passed as input parameter. This class is based on the AbstractFacotry pattern. * </p> ! * <p> ! * This will get the following XML block from framework configuration as JobConfigFactoryConfig ! * object. ! * <br><br> ! * <pre> ! * <job-config-factory-config job-config-factory-class-name="org.jmonks.batchserver.framework.config.xml.XMLJobConfigFactory"> ! * <property key="job-config-file-absolute-location">/batchserver/config/batch-config.xml</property> ! * </job-config-factory-config> ! * </pre> ! * </p> ! * * @author Suresh Pragada * @version 1.0 *************** *** 32,36 **** * name in the given object, instantiates and return that factory. * ! * @param factoryConfig Job configuration factory config object contains the details need to * create the factory. * --- 45,49 ---- * name in the given object, instantiates and return that factory. * ! * @param factoryConfig Job configuration factory config object contains the details need to * create the factory. * *************** *** 43,79 **** public static JobConfigFactory getJobConfigFactory(FrameworkConfig.JobConfigFactoryConfig factoryConfig) { if(factoryConfig==null) throw new IllegalArgumentException("Input factory configuration cannot be null."); ! String factoryClassName=factoryConfig.getJobConfigFactoryClassName(); ! try { - Class factoryClass=Class.forName(factoryClassName); ! if(factoryClass instanceof JobConfigFactory.class) { ! ! } else throw new ConfigurationException(ErrorCode.JOB_CONFIG_FACTORY_CLASS_NOT_VALID); ! ! } ! catch(ClassNotFoundException exception) { exception.printStackTrace(); throw new ConfigurationException(ErrorCode.JOB_CONFIG_FACTORY_CLASS_NOT_FOUND); } ! return null; } /** ! * Returns the request JobConfig object from the defined factory. * * @param jobName Name of the job whose configuration is needed. * ! * @return Returns the requested Job Configuration object. ! * ! * @throws ConfigurationException If requested job is not configured in the factroy source. */ public abstract JobConfig getJobConfig(String jobName); --- 56,111 ---- public static JobConfigFactory getJobConfigFactory(FrameworkConfig.JobConfigFactoryConfig factoryConfig) { + JobConfigFactory factoryObject=null; if(factoryConfig==null) throw new IllegalArgumentException("Input factory configuration cannot be null."); ! String factoryClassName=factoryConfig.getJobConfigFactoryClassName(); ! try { Class factoryClass=Class.forName(factoryClassName); ! Constructor factoryConstructor=factoryClass.getConstructor(Map.class); ! if(JobConfigFactory.class.isAssignableFrom(factoryClass)) { ! factoryObject=(JobConfigFactory)factoryConstructor.newInstance(factoryConfig.getJobConfigFactoryProperties()); ! } else throw new ConfigurationException(ErrorCode.JOB_CONFIG_FACTORY_CLASS_NOT_VALID); ! } ! catch(ClassNotFoundException exception) { exception.printStackTrace(); throw new ConfigurationException(ErrorCode.JOB_CONFIG_FACTORY_CLASS_NOT_FOUND); } + catch(NoSuchMethodException exception) + { + exception.printStackTrace(); + throw new ConfigurationException(ErrorCode.JOB_CONFIG_FACTORY_CLASS_CONSTRUCTOR_NOT_FOUND); + } + catch(InstantiationException exception) + { + exception.printStackTrace(); + throw new ConfigurationException(ErrorCode.JOB_CONFIG_FACTORY_CLASS_NOT_VALID); + } + catch(IllegalAccessException exception) + { + exception.printStackTrace(); + throw new ConfigurationException(ErrorCode.JOB_CONFIG_FACTORY_CLASS_NOT_VALID); + } + catch(InvocationTargetException exception) + { + exception.printStackTrace(); + throw new ConfigurationException(ErrorCode.JOB_CONFIG_FACTORY_CLASS_NOT_VALID); + } ! return factoryObject; } /** ! * Returns the requested JobConfig object from the defined factory. If requested ! * job configuration is not found in that factory, it returns null. * * @param jobName Name of the job whose configuration is needed. * ! * @return Returns the requested Job Configuration object if found, null otherwise. */ public abstract JobConfig getJobConfig(String jobName); Index: framework-config.xml =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/framework-config.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** framework-config.xml 7 Mar 2006 03:43:06 -0000 1.4 --- framework-config.xml 7 Mar 2006 23:33:06 -0000 1.5 *************** *** 1,8 **** <framework-config> <job-config-factory-config job-config-factory-class-name="org.jmonks.batchserver.framework.config.xml.XMLJobConfigFactory"> ! <property key="config-file-absolute-location">/batchserver/config/batch-config.xml</property> <!-- Following is the another way to configure the XML Job configuration. ! <property key="config-file-classpath-location">batch-config.xml</property> --> </job-config-factory-config> --- 1,8 ---- <framework-config> <job-config-factory-config job-config-factory-class-name="org.jmonks.batchserver.framework.config.xml.XMLJobConfigFactory"> ! <property key="job-config-file-absolute-location">/batchserver/config/batch-config.xml</property> <!-- Following is the another way to configure the XML Job configuration. ! <property key="job-config-file-classpath-location">batch-config.xml</property> --> </job-config-factory-config> |
From: Suresh <sur...@us...> - 2006-03-07 23:25:38
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16597 Modified Files: ErrorCode.java Log Message: no message Index: ErrorCode.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/common/ErrorCode.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ErrorCode.java 7 Mar 2006 03:42:43 -0000 1.4 --- ErrorCode.java 7 Mar 2006 23:25:28 -0000 1.5 *************** *** 96,104 **** */ public static final ErrorCode JOB_NOT_CONFIGURED = new ErrorCode(2001,"job is not configured in the job configuration source"); ! public static final ErrorCode JOB_CONFIG_FACTORY_CLASS_NOT_VALID = new ErrorCode(2002,"defined configuration factory class is not valid"); ! public static final ErrorCode JOB_CONFIG_FACTORY_CLASS_NOT_FOUND = new ErrorCode(2003,"defined configuration factory class could not be found"); ! public static final ErrorCode MISSING_PROPS_XML_CONFIG_FACTORY = new ErrorCode(2003,"required properties are missing in xml config factory configuration"); ! public static final ErrorCode UNABLE_TO_LOAD_XML_JOB_CONFIG_FILE = new ErrorCode(2004,"configured xml job configuration file cannot be loaded"); ! public static final ErrorCode INVALID_JOB_CONFIG_FILE_FORMAT = new ErrorCode(2005,"xml job configuration file is not in a valid format"); } --- 96,106 ---- */ public static final ErrorCode JOB_NOT_CONFIGURED = new ErrorCode(2001,"job is not configured in the job configuration source"); ! public static final ErrorCode JOB_CONFIG_FACTORY_CLASS_NOT_VALID = new ErrorCode(2002,"defined configuration factory class is not assignable to the JobConfigFactory super class or cannot be instantiated because of illegal access to constructor or exception in constructor"); ! public static final ErrorCode JOB_CONFIG_FACTORY_CLASS_NOT_FOUND = new ErrorCode(2003,"defined configuration factory class could not be found on the classpath"); ! public static final ErrorCode JOB_CONFIG_FACTORY_CLASS_CONSTRUCTOR_NOT_FOUND = new ErrorCode(2004,"constructor takes map as parameter not found in defined config factory class"); ! public static final ErrorCode XML_JOB_CONFIG_FACTORY_PROPERTIES_MISSING = new ErrorCode(2005,"required properties for XMLJobConfigFactory are missing"); ! public static final ErrorCode XML_JOB_CONFIG_FACTORY_INVALID_ABS_LOCATION = new ErrorCode(2006,"defined absolute file path for the XML Job Configuration file is not valid"); ! public static final ErrorCode XML_JOB_CONFIG_FACTORY_INVALID_CLASSPATH_LOCATION = new ErrorCode(2006,"defined classpath location for the XML Job Configiguation file is not valid"); ! public static final ErrorCode NO_BATCH_CONFIG_ELEMENT_IN_XML_JOB_CONFIGURATION = new ErrorCode(2008,"could not load the batch-config element from the defined XML job configuration file"); } |
From: Suresh <sur...@us...> - 2006-03-07 03:43:10
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19583 Modified Files: framework-config.xml FrameworkConfig.java JobConfigFactory.java Log Message: no message Index: JobConfigFactory.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/JobConfigFactory.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** JobConfigFactory.java 3 Mar 2006 04:19:56 -0000 1.1 --- JobConfigFactory.java 7 Mar 2006 03:43:06 -0000 1.2 *************** *** 11,27 **** package org.jmonks.batchserver.framework.config; /** ! * ! * @author Suresh Pragada */ public abstract class JobConfigFactory { ! /** Creates a new instance of JobConfigFactory */ public static JobConfigFactory getJobConfigFactory(FrameworkConfig.JobConfigFactoryConfig factoryConfig) { return null; } public abstract JobConfig getJobConfig(String jobName); - } --- 11,80 ---- package org.jmonks.batchserver.framework.config; + import org.jmonks.batchserver.framework.common.ErrorCode; + /** ! * <p> ! * This class returns the factory class which in turn returns the job configuration ! * objects from the defined factory. This class determines which factory needs to ! * be returned is based on the configFactoryClassName defined JobConfigFactoryConfig ! * object passed as input parameter. This class is based on the AbstractFacotry pattern. ! * </p> ! * ! * @author Suresh Pragada ! * @version 1.0 ! * @since 1.0 */ public abstract class JobConfigFactory { ! /** ! * This factory method will return the appropriated job configuration factory based ! * on the input values in JobConfigFactoryConfig object. This looks for the factory class ! * name in the given object, instantiates and return that factory. ! * ! * @param factoryConfig Job configuration factory config object contains the details need to ! * create the factory. ! * ! * @return Returns the approproated JobConfigFactory object. ! * ! * @throws ConfigurationException If defined factory class is not a valid Job config factory and if any ! * required properties are missing for the factory. ! * @throws IllegalArgumentException If input factory configuration is null. ! */ public static JobConfigFactory getJobConfigFactory(FrameworkConfig.JobConfigFactoryConfig factoryConfig) { + if(factoryConfig==null) + throw new IllegalArgumentException("Input factory configuration cannot be null."); + + String factoryClassName=factoryConfig.getJobConfigFactoryClassName(); + try + { + + Class factoryClass=Class.forName(factoryClassName); + if(factoryClass instanceof JobConfigFactory.class) + { + + } + else + throw new ConfigurationException(ErrorCode.JOB_CONFIG_FACTORY_CLASS_NOT_VALID); + + } + catch(ClassNotFoundException exception) + { + exception.printStackTrace(); + throw new ConfigurationException(ErrorCode.JOB_CONFIG_FACTORY_CLASS_NOT_FOUND); + } + return null; } + /** + * Returns the request JobConfig object from the defined factory. + * + * @param jobName Name of the job whose configuration is needed. + * + * @return Returns the requested Job Configuration object. + * + * @throws ConfigurationException If requested job is not configured in the factroy source. + */ public abstract JobConfig getJobConfig(String jobName); } Index: FrameworkConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/FrameworkConfig.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** FrameworkConfig.java 6 Mar 2006 04:36:48 -0000 1.3 --- FrameworkConfig.java 7 Mar 2006 03:43:06 -0000 1.4 *************** *** 22,25 **** --- 22,26 ---- import org.w3c.dom.Document; import org.w3c.dom.Element; + import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; *************** *** 30,34 **** * framework-config.xml file and gives configuration in the form of * configuration objects when needed. Framework configuration will be defined ! * in the file framework-config.xml located in the class path org.jmonks.batchserver.framework.config. * </p> * --- 31,35 ---- * framework-config.xml file and gives configuration in the form of * configuration objects when needed. Framework configuration will be defined ! * in the file framework-config.xml and will be accessed using class path loader. * </p> * *************** *** 47,51 **** * Declaration of XML file holds the framework configuration. */ ! private static final String FRAMEWORK_CONFIG_FILE = "org.jmonks.batchserver.framework.config.framework-config.xml"; /** --- 48,52 ---- * Declaration of XML file holds the framework configuration. */ ! private static final String FRAMEWORK_CONFIG_FILE = "framework-config.xml"; /** *************** *** 237,242 **** * Job config factory class name. */ ! private String factoryClassName=null; private Map jobConfigFactoryProperties=new HashMap(); --- 238,246 ---- * Job config factory class name. */ ! private String jobConfigFactoryClassName=null; + /** + * Map holds the properites required by job config factory. + */ private Map jobConfigFactoryProperties=new HashMap(); *************** *** 250,255 **** private JobConfigFactoryConfig(Element jobConfigFactoryElement) { ! this.factoryClassName=jobConfigFactoryElement.getAttribute(JobConfigFactoryConfig.FACTORY_CLASS_ATTRIBUTE_NAME); ! if(this.factoryClassName==null) throw new ConfigurationException(ErrorCode.JOB_CONFIG_FACTORY_CLASS_NAME_ATTRIB_NOT_FOUND); --- 254,259 ---- private JobConfigFactoryConfig(Element jobConfigFactoryElement) { ! this.jobConfigFactoryClassName=jobConfigFactoryElement.getAttribute(JobConfigFactoryConfig.FACTORY_CLASS_ATTRIBUTE_NAME); ! if(this.jobConfigFactoryClassName==null) throw new ConfigurationException(ErrorCode.JOB_CONFIG_FACTORY_CLASS_NAME_ATTRIB_NOT_FOUND); *************** *** 263,267 **** public String getJobConfigFactoryClassName() { ! return null; } --- 267,271 ---- public String getJobConfigFactoryClassName() { ! return this.jobConfigFactoryClassName; } *************** *** 272,277 **** public Map getJobConfigFactoryProperties() { ! return null; } } --- 276,299 ---- public Map getJobConfigFactoryProperties() { ! return this.jobConfigFactoryProperties; } + + /** + * <p> + * Returns the string representation of JobConfigFactoryConfig class in the format + * <br> {JobConfigFactoryConfig [configFactoryclassName = value] [properties = value]} + * </p> + * + * @return Returns the string representation of JobConfigFactoryConfig. + */ + public String toString() + { + StringBuffer stringValue=new StringBuffer("{JobConfigFactoryConfig "); + stringValue.append("[configFactoryclassName = " + this.jobConfigFactoryClassName + "]"); + stringValue.append("[properties = " + this.jobConfigFactoryProperties + "]"); + stringValue.append("}"); + return stringValue.toString(); + } + } *************** *** 288,296 **** * <br><br> * <pre> ! * <logging-config> ! * <logging-directory>/batchserver/logs</logging-directory> ! * <logging-level>DEBUG</logging-level> ! * <job-base-package-name>com.mycompany.batch</job-base-package-name> ! * </logging-config> * </pre> * </p> --- 310,314 ---- * <br><br> * <pre> ! * <logging-config logging-direcotry="/batchserver/logs" logging-level="DEBUG" job-base-package-name="com.mycompany.batch"/> * </pre> * </p> *************** *** 304,307 **** --- 322,350 ---- /** + * Attribute name defines the logging directory. + */ + private static final String LOGGING_DIRECTORY_ATTRIB_NAME = "logging-directory"; + /** + * Attribute name defines the logging level. + */ + private static final String LOGGING_LEVEL_ATTRIB_NAME = "logging-level"; + /** + * Attribute name defines the base package name. + */ + private static final String BASE_PACKAGE_ATTRIB_NAME = "job-base-package-name"; + /** + * Direcotry where all the log files needs to be written. + */ + private String loggingDirectory=null; + /** + * Logging level. + */ + private String loggingLevel="ERROR"; + /** + * Base package name of the application(job). + */ + private String basePackageName=null; + + /** * This constructor will read the logging configuration from * the given DOM element which represents the tag <logging-config>. *************** *** 312,315 **** --- 355,367 ---- private LoggingConfig(Element loggingConfigElement) { + this.loggingDirectory=loggingConfigElement.getAttribute(LoggingConfig.LOGGING_DIRECTORY_ATTRIB_NAME); + if(this.loggingDirectory==null) + throw new ConfigurationException(ErrorCode.LOGGING_DIRECTORY_NOT_DEFINED); + + this.loggingLevel=loggingConfigElement.getAttribute(LoggingConfig.LOGGING_LEVEL_ATTRIB_NAME); + if(this.loggingLevel==null) + this.loggingLevel="ERROR"; + + this.basePackageName=loggingConfigElement.getAttribute(LoggingConfig.BASE_PACKAGE_ATTRIB_NAME); } *************** *** 321,325 **** public String getLoggingDirecotry() { ! return null; } --- 373,377 ---- public String getLoggingDirecotry() { ! return this.loggingDirectory; } *************** *** 331,335 **** public String getFrameworkLogLevel() { ! return null; } --- 383,387 ---- public String getFrameworkLogLevel() { ! return this.loggingLevel; } *************** *** 342,347 **** public String getBasePackageName() { ! return null; } } --- 394,418 ---- public String getBasePackageName() { ! return this.basePackageName; } + + /** + * <p> + * Returns the string representation of LoggingConfig class in the format + * <br> {LoggingConfig [loggingDirectory = value] [loggingLevel = value] [basePackageName = value]} + * </p> + * + * @return Returns the string representation of LoggingConfig. + */ + public String toString() + { + StringBuffer stringValue=new StringBuffer("{LoggingConfig "); + stringValue.append("[loggingDirectory = " + this.loggingDirectory + "]"); + stringValue.append("[loggingLevel = " + this.loggingLevel + "]"); + stringValue.append("[basePackageName = " + this.basePackageName + "]"); + stringValue.append("}"); + return stringValue.toString(); + } + } *************** *** 368,371 **** --- 439,457 ---- */ private static final String TAG_NAME = "mgmt-mntr-config"; + + /** + * Attribute name defines the mgmt mntr class name. + */ + private static final String MGMT_MNTR_CLASS_ATTRIB_NAME = "mgmt-mntr-class-name"; + + /** + * Mgmt mntr class name. + */ + private String mgmtMntrClassName=null; + + /** + * Supporting properties for the defined manager. + */ + private Map mgmtMntrConfigProperties=new HashMap(); /** *************** *** 377,381 **** --- 463,471 ---- private MgmtMntrConfig(Element mgmtMntrConfigElement) { + this.mgmtMntrClassName=mgmtMntrConfigElement.getAttribute(MgmtMntrConfig.MGMT_MNTR_CLASS_ATTRIB_NAME); + if(this.mgmtMntrClassName==null) + throw new ConfigurationException(ErrorCode.MGMT_MNTR_CLASS_NAME_ATTRIB_NOT_FOUND); + FrameworkUtil.loadPropertiesFromElementToMap(mgmtMntrConfigElement, this.mgmtMntrConfigProperties); } *************** *** 387,391 **** public String getMgmtMntrClassName() { ! return null; } --- 477,481 ---- public String getMgmtMntrClassName() { ! return this.mgmtMntrClassName; } *************** *** 397,402 **** public Map getMgmtMntrProperties() { ! return null; } } --- 487,509 ---- public Map getMgmtMntrProperties() { ! return this.mgmtMntrConfigProperties; } + + /** + * <p> + * Returns the string representation of MgmtMntrConfig class in the format + * <br> {MgmtMntrConfig [mgmtMntrClassName = value] [properties = value]} + * </p> + * + * @return Returns the string representation of MgmtMntrConfig. + */ + public String toString() + { + StringBuffer stringValue=new StringBuffer("{MgmtMntrConfig "); + stringValue.append("[mgmtMntrClassName = " + this.mgmtMntrClassName + "]"); + stringValue.append("[properties = " + this.mgmtMntrConfigProperties + "]"); + stringValue.append("}"); + return stringValue.toString(); + } } *************** *** 425,428 **** --- 532,550 ---- */ private static final String TAG_NAME = "repository-config"; + + /** + * Attribute name defines the repository class name. + */ + private static final String REPOSITORY_CLASS_ATTRIB_NAME = "repository-class-name"; + + /** + * Repository implementation class name. + */ + private String repositoryClassName=null; + + /** + * Map holds the required properties of the defined repository class. + */ + private Map repositoryConfigProperties=new HashMap(); /** *************** *** 436,439 **** --- 558,566 ---- private RepositoryConfig(Element repositoryConfigElement) { + this.repositoryClassName=repositoryConfigElement.getAttribute(RepositoryConfig.REPOSITORY_CLASS_ATTRIB_NAME); + if(this.repositoryClassName==null) + throw new ConfigurationException(ErrorCode.REPOSITORY_CLASS_NAME_ATTRIB_NOT_FOUND); + + FrameworkUtil.loadPropertiesFromElementToMap(repositoryConfigElement, this.repositoryConfigProperties); } *************** *** 445,449 **** public String getRepositoryClassName() { ! return null; } --- 572,576 ---- public String getRepositoryClassName() { ! return this.repositoryClassName; } *************** *** 455,460 **** public Map getRepositoryConfigProperties() { ! return null; } } } --- 582,626 ---- public Map getRepositoryConfigProperties() { ! return this.repositoryConfigProperties; } + + /** + * <p> + * Returns the string representation of RepositoryConfig class in the format + * <br> {RepositoryConfig [repositoryClassName = value] [properties = value]} + * </p> + * + * @return Returns the string representation of RepositoryConfig. + */ + public String toString() + { + StringBuffer stringValue=new StringBuffer("{RepositoryConfig "); + stringValue.append("[repositoryClassName = " + this.repositoryClassName + "]"); + stringValue.append("[properties = " + this.repositoryConfigProperties + "]"); + stringValue.append("}"); + return stringValue.toString(); + } + } + + /** + * <p> + * Returns the string representation of FrameworkConfig class in the format + * <br> {FrameworkConfig [jobConfigFactoryConfig = value] [loggingConfig = value] + * [mgmtMntrConfig = value] [repositoryConfig = value]} + * </p> + * + * @return Returns the string representation of FrameworkConfig. + */ + public String toString() + { + StringBuffer stringValue=new StringBuffer("{FrameworkConfig "); + stringValue.append("[jobConfigFactoryConfig = " + this.configFactoryConfig + "]"); + stringValue.append("[loggingConfig = " + this.logginConfig + "]"); + stringValue.append("[mgmtMntrConfig = " + this.mgmtMntrConfig + "]"); + stringValue.append("[repositoryConfig = " + this.repositoryConfig + "]"); + stringValue.append("}"); + return stringValue.toString(); + } + } Index: framework-config.xml =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/framework-config.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** framework-config.xml 6 Mar 2006 04:36:48 -0000 1.3 --- framework-config.xml 7 Mar 2006 03:43:06 -0000 1.4 *************** *** 4,8 **** <!-- Following is the another way to configure the XML Job configuration. ! <property key="config-file-classpath-location">org.jmonks.batchserver.framework.config.batch-config.xml</property> --> </job-config-factory-config> --- 4,8 ---- <!-- Following is the another way to configure the XML Job configuration. ! <property key="config-file-classpath-location">batch-config.xml</property> --> </job-config-factory-config> *************** *** 11,19 **** <property key="repository-filename">batchserver_repository.db</property> </repository-config> ! <logging-config> ! <logging-directory>/batchserver/logs</logging-directory> ! <logging-level>DEBUG</logging-level> ! <job-base-package-name>com.mycompany.batch</job-base-package-name> ! </logging-config> <mgmt-mntr-config mgmt-mntr-class-name="org.jmonks.batchserver.framework.mgmtmntr.DefaultMgmtMntrManager"> <property key="port-range">15000-20000</property> --- 11,15 ---- <property key="repository-filename">batchserver_repository.db</property> </repository-config> ! <logging-config logging-direcotry="/batchserver/logs" logging-level="DEBUG" job-base-package-name="com.mycompany.batch"/> <mgmt-mntr-config mgmt-mntr-class-name="org.jmonks.batchserver.framework.mgmtmntr.DefaultMgmtMntrManager"> <property key="port-range">15000-20000</property> |