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