Thread: [Batchserver-cvs] batchserver/src/org/jmonks/batchserver/framework/config framework-config.xml,1.4,1
Brought to you by:
suresh_pragada
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> |