[Batchserver-cvs] batchserver/src/org/jmonks/batchserver/framework/config BasicJobControllerConfig.j
Brought to you by:
suresh_pragada
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) |