[Batchserver-cvs] batchserver/src/org/jmonks/batchserver/framework/config framework-config.xsd,NONE,
Brought to you by:
suresh_pragada
From: Suresh <sur...@us...> - 2006-03-13 14:32:45
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19442/config Modified Files: BasicJobControllerConfig.java ConfigurationException.java framework-config.xml FrameworkConfig.java JobConfigFactory.java JobControllerConfig.java PoolJobControllerConfig.java Added Files: framework-config.xsd Log Message: no message --- NEW FILE: framework-config.xsd --- <?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="framework-config" type="FrameworkConfigType"/> <xsd:complexType name="FrameworkConfigType"> <xsd:element name="job-config-factory-config" type="JobConfigFactoryConfigType"/> <xsd:element name="logging-config" type="LoggingConfigType"/> <xsd:element name="repository-config" type="RepositoryConfigType"/> <xsd:element name="mgmt-mntr-config" type="MgmtMntrConfigType"/> <xsd:element name="job-controller-config" type="JobControllerConfigType"/> </xsd:complexType> <xsd:complexType name="JobConfigFactoryConfigType"> <xsd:attribute name="job-config-factory-class-name" type="xsd:string" use="required"/> <xsd:element name="property" type="PropertyType" minOccurs="0" maxOccurs="unbounded"/> </xsd:complexType> <xsd:complexType name="LoggingConfigType"> <xsd:attribute name="logging-direcotry" type="xsd:string" use="required"/> <xsd:attribute name="logging-level" type="LogLevelType" use="required"/> <xsd:attribute name="job-base-package-name" type="xsd:string" use="required"/> </xsd:complexType> <xsd:complexType name="RepositoryConfigType"> <xsd:attribute name="repository-class-name" type="xsd:string" use="required"/> <xsd:element name="property" type="PropertyType" minOccurs="0" maxOccurs="unbounded"/> </xsd:complexType> <xsd:complexType name="MgmtMntrConfigType"> <xsd:attribute name="mgmt-mntr-class-name" type="xsd:string" use="required"/> <xsd:element name="property" type="PropertyType" minOccurs="0" maxOccurs="unbounded"/> </xsd:complexType> <xsd:complexType name="JobControllerConfigType"> <xsd:element name="job-controller" type="JobControllerType" minOccurs="0" maxOccurs="unbounded"/> </xsd:complexType> <xsd:complexType name="PropertyType"> <xsd:simpleContent> <xsd:extension base="xsd:string"> <xsd:attribute name="key" type="xsd:string" use="required"/> </xsd:extension> </xsd:simpleContent> </xsd:complexType> <xsd:complexType name="JobControllerType"> <xsd:attribute name="controller-class-name" type="xsd:string" use="required"/> <xsd:attribute name="xml-factory-config-class-name" type="xsd:string" use="required"/> <xsd:attribute name="db-factory-config-class-name" type="xsd:string" use="required"/> </xsd:complexType> <xsd:simpleType name="LogLevelType"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="DEBUG"/> <xsd:enumeration value="ERROR"/> </xsd:restriction> </xsd:simpleType> </xsd:schema> Index: BasicJobControllerConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/BasicJobControllerConfig.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** BasicJobControllerConfig.java 10 Mar 2006 08:14:51 -0000 1.5 --- BasicJobControllerConfig.java 13 Mar 2006 14:32:37 -0000 1.6 *************** *** 14,17 **** --- 14,18 ---- import java.util.Iterator; import java.util.Map; + import java.util.logging.Logger; /** *************** *** 43,46 **** --- 44,49 ---- */ protected int basicJobProcessorThreadCount=1; + + private static Logger logger=Logger.getLogger(BasicJobControllerConfig.class.getName()); /** * Gets the basic job processor class name. *************** *** 84,87 **** --- 87,91 ---- public void overrideConfigProperties(Map newProps) { + logger.entering(BasicJobControllerConfig.class.getName(),"overrideConfigProperties"); super.overrideConfigProperties(newProps); *************** *** 95,100 **** --- 99,106 ---- { this.basicJobProcessorConfigProps.put(key, newProps.get(key)); + logger.fine("Overriden the property " + key + " with " + newProps.get(key)); } } + logger.exiting(BasicJobControllerConfig.class.getName(),"overrideConfigProperties"); } Index: FrameworkConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/FrameworkConfig.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** FrameworkConfig.java 9 Mar 2006 04:44:07 -0000 1.6 --- FrameworkConfig.java 13 Mar 2006 14:32:37 -0000 1.7 *************** *** 10,22 **** package org.jmonks.batchserver.framework.config; - import java.io.IOException; import java.io.InputStream; import java.util.HashMap; 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.common.FrameworkUtil; import org.w3c.dom.Document; --- 10,22 ---- package org.jmonks.batchserver.framework.config; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.Map; + import java.util.logging.Level; + import java.util.logging.Logger; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.jmonks.batchserver.framework.common.FrameworkUtil; import org.w3c.dom.Document; *************** *** 26,29 **** --- 26,30 ---- import org.w3c.dom.NodeList; import org.xml.sax.SAXException; + import org.xml.sax.helpers.DefaultHandler; /** *************** *** 41,44 **** --- 42,46 ---- public final class FrameworkConfig { + private static Logger logger=Logger.getLogger(FrameworkConfig.class.getName()); /** * FrameworkConfig singleton instance varaible. *************** *** 49,55 **** * Declaration of XML file holds the framework configuration. */ ! private static final String FRAMEWORK_CONFIG_FILE = "framework-config.xml"; /** * JobConfigFactoryConfig variable to hold the JobConfigFactoryObject object. */ --- 51,61 ---- * Declaration of XML file holds the framework configuration. */ ! private static final String FRAMEWORK_CONFIG_FILE = "/org/jmonks/batchserver/framework/config/framework-config.xml"; /** + * Name of the tag represents the complete framework configuration. + */ + private static final String FRAMEWORK_CONFIG_TAG_NAME = "framework-confg"; + /** * JobConfigFactoryConfig variable to hold the JobConfigFactoryObject object. */ *************** *** 84,98 **** private FrameworkConfig() { try { InputStream configFileStream=FrameworkConfig.class.getResourceAsStream(FrameworkConfig.FRAMEWORK_CONFIG_FILE); if(configFileStream==null) ! throw new ConfigurationException(ErrorCode.FRAMEWORK_CONFIG_FILE_NOT_FOUND); ! DocumentBuilderFactory documentBuilderFactory=DocumentBuilderFactory.newInstance(); documentBuilderFactory.setValidating(true); DocumentBuilder documentBuilder=documentBuilderFactory.newDocumentBuilder(); Document document=documentBuilder.parse(configFileStream); Element frameworkConfigElement=document.getDocumentElement(); NodeList jobConfigFactoryConfigNodeList=frameworkConfigElement.getElementsByTagName(JobConfigFactoryConfig.TAG_NAME); --- 90,122 ---- private FrameworkConfig() { + logger.entering(FrameworkConfig.class.getName(),"DefaultConstructor"); try { InputStream configFileStream=FrameworkConfig.class.getResourceAsStream(FrameworkConfig.FRAMEWORK_CONFIG_FILE); if(configFileStream==null) ! throw new ConfigurationException(ConfigurationException.FRAMEWORK_CONFIG, "Framework configuration file " + ! FrameworkConfig.FRAMEWORK_CONFIG_FILE + " cannot be accessed from the classpath."); ! ! logger.fine("Framework configuration file has been accessed"); ! if(System.getProperty("javax.xml.parsers.DocumentBuilderFactory")==null) ! System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"); ! DocumentBuilderFactory documentBuilderFactory=DocumentBuilderFactory.newInstance(); documentBuilderFactory.setValidating(true); + documentBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage","http://www.w3.org/2001/XMLSchema"); + InputStream xsdStream=FrameworkConfig.class.getResourceAsStream("framework-config.xsd"); + documentBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource",xsdStream); + DocumentBuilder documentBuilder=documentBuilderFactory.newDocumentBuilder(); + documentBuilder.setErrorHandler(new DefaultHandler()); Document document=documentBuilder.parse(configFileStream); + logger.fine("Framework configuration file has been parsed."); Element frameworkConfigElement=document.getDocumentElement(); + if(FrameworkConfig.FRAMEWORK_CONFIG_TAG_NAME.equals(frameworkConfigElement.getTagName())) + { + throw new ConfigurationException(ConfigurationException.FRAMEWORK_CONFIG, "Expected the root element of framework configuration to be " + + FrameworkConfig.FRAMEWORK_CONFIG_TAG_NAME + ", but encountered the tag with the name " + frameworkConfigElement.getTagName() + + " accessed from the location " + FrameworkConfig.FRAMEWORK_CONFIG_FILE + "."); + } NodeList jobConfigFactoryConfigNodeList=frameworkConfigElement.getElementsByTagName(JobConfigFactoryConfig.TAG_NAME); *************** *** 103,109 **** else { ! throw new ConfigurationException(ErrorCode.NONE_OR_MULITPLE_JOB_CONFIG_FACTORY_CONFIG_TAGS); } ! NodeList loggingConfigNodeList=frameworkConfigElement.getElementsByTagName(LoggingConfig.TAG_NAME); if(loggingConfigNodeList.getLength()==1) --- 127,134 ---- else { ! throw new ConfigurationException(ConfigurationException.FRAMEWORK_CONFIG, "Found " + jobConfigFactoryConfigNodeList.getLength() + " " + ! JobConfigFactoryConfig.TAG_NAME + " element(s) in the framework configuration, where only one such element is allowed."); } ! logger.config("Job Config Factory configuration has been loaded and the configuration is : " + this.configFactoryConfig); NodeList loggingConfigNodeList=frameworkConfigElement.getElementsByTagName(LoggingConfig.TAG_NAME); if(loggingConfigNodeList.getLength()==1) *************** *** 113,119 **** else { ! throw new ConfigurationException(ErrorCode.NONE_OR_MULITPLE_LOGGING_CONFIG_TAGS); } ! NodeList mgmtMntrConfigNodeList=frameworkConfigElement.getElementsByTagName(MgmtMntrConfig.TAG_NAME); if(mgmtMntrConfigNodeList.getLength()==1) --- 138,145 ---- else { ! throw new ConfigurationException(ConfigurationException.FRAMEWORK_CONFIG, "Found " + loggingConfigNodeList.getLength() + " " + ! LoggingConfig.TAG_NAME + " element(s) in the framework configuration, where only one such element is allowed."); } ! logger.config("Logging configuration has been loaded and the configuration is : " + this.logginConfig); NodeList mgmtMntrConfigNodeList=frameworkConfigElement.getElementsByTagName(MgmtMntrConfig.TAG_NAME); if(mgmtMntrConfigNodeList.getLength()==1) *************** *** 123,129 **** else { ! throw new ConfigurationException(ErrorCode.NONE_OR_MULITPLE_MGMT_MNTR_CONFIG_TAGS); } ! NodeList repositoryConfigNodeList=frameworkConfigElement.getElementsByTagName(RepositoryConfig.TAG_NAME); if(repositoryConfigNodeList.getLength()==1) --- 149,156 ---- else { ! throw new ConfigurationException(ConfigurationException.FRAMEWORK_CONFIG, "Found " + mgmtMntrConfigNodeList.getLength() + " " + ! MgmtMntrConfig.TAG_NAME + " element(s) in the framework configuration, where only one such element is allowed."); } ! logger.config("MgmtMntr configuration has been loaded and the configuration is : " + this.mgmtMntrConfig); NodeList repositoryConfigNodeList=frameworkConfigElement.getElementsByTagName(RepositoryConfig.TAG_NAME); if(repositoryConfigNodeList.getLength()==1) *************** *** 133,139 **** else { ! throw new ConfigurationException(ErrorCode.NONE_OR_MULITPLE_REPOSITORY_CONFIG_TAGS); } ! NodeList controllerConfigNodeList=frameworkConfigElement.getElementsByTagName(JobControllerConfig.TAG_NAME); if(controllerConfigNodeList.getLength()==1) --- 160,167 ---- else { ! throw new ConfigurationException(ConfigurationException.FRAMEWORK_CONFIG, "Found " + repositoryConfigNodeList.getLength() + " " + ! RepositoryConfig.TAG_NAME + " element(s) in the framework configuration, where only one such element is allowed."); } ! logger.config("Repository configuration has been loaded and the configuration is : " + this.repositoryConfig); NodeList controllerConfigNodeList=frameworkConfigElement.getElementsByTagName(JobControllerConfig.TAG_NAME); if(controllerConfigNodeList.getLength()==1) *************** *** 143,164 **** else { ! throw new ConfigurationException(ErrorCode.NONE_OR_MULITPLE_JOB_CONTROLLER_CONFIG_TAGS); } } catch(IOException ioException) { ioException.printStackTrace(); ! throw new RuntimeException(ioException); } catch(ParserConfigurationException parserConfigException) { parserConfigException.printStackTrace(); ! throw new RuntimeException(parserConfigException); } catch(SAXException saxException) { saxException.printStackTrace(); ! throw new RuntimeException(saxException); } } --- 171,195 ---- else { ! throw new ConfigurationException(ConfigurationException.FRAMEWORK_CONFIG, "Found " + controllerConfigNodeList.getLength() + " " + ! JobControllerConfig.TAG_NAME + " element(s) in the framework configuration, where only one such element is allowed."); } + logger.config("Job Controller configuration has been loaded and the configuration is : " + this.controllerConfig); } catch(IOException ioException) { ioException.printStackTrace(); ! throw new ConfigurationException(ConfigurationException.FRAMEWORK_CONFIG, ioException.getMessage()); } catch(ParserConfigurationException parserConfigException) { parserConfigException.printStackTrace(); ! throw new ConfigurationException(ConfigurationException.FRAMEWORK_CONFIG, parserConfigException.getMessage()); } catch(SAXException saxException) { saxException.printStackTrace(); ! throw new ConfigurationException(ConfigurationException.FRAMEWORK_CONFIG, saxException.getMessage()); } + logger.exiting(FrameworkConfig.class.getName(), "DefaultConstrutor"); } *************** *** 279,287 **** 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); FrameworkUtil.loadPropertiesFromElementToMap(jobConfigFactoryElement,jobConfigFactoryProperties); } --- 310,321 ---- private JobConfigFactoryConfig(Element jobConfigFactoryElement) { + logger.entering(JobConfigFactoryConfig.class.getName(),"Constructor"); this.jobConfigFactoryClassName=jobConfigFactoryElement.getAttribute(JobConfigFactoryConfig.FACTORY_CLASS_ATTRIBUTE_NAME); ! if(this.jobConfigFactoryClassName==null || "".equals(this.jobConfigFactoryClassName)) ! throw new ConfigurationException(ConfigurationException.FRAMEWORK_CONFIG, JobConfigFactoryConfig.FACTORY_CLASS_ATTRIBUTE_NAME + ! " attribute value cannot be null."); FrameworkUtil.loadPropertiesFromElementToMap(jobConfigFactoryElement,jobConfigFactoryProperties); + logger.exiting(JobConfigFactoryConfig.class.getName(),"Constructor"); } *************** *** 365,369 **** * Logging level. */ ! private String loggingLevel="ERROR"; /** * Base package name of the application(job). --- 399,403 ---- * Logging level. */ ! private String loggingLevel="SEVERE"; /** * Base package name of the application(job). *************** *** 380,392 **** 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); } --- 414,427 ---- private LoggingConfig(Element loggingConfigElement) { + logger.entering(LoggingConfig.class.getName(),"Constructor"); this.loggingDirectory=loggingConfigElement.getAttribute(LoggingConfig.LOGGING_DIRECTORY_ATTRIB_NAME); ! if(loggingDirectory==null || "".equals(loggingDirectory)) ! throw new ConfigurationException(ConfigurationException.FRAMEWORK_CONFIG, LoggingConfig.LOGGING_DIRECTORY_ATTRIB_NAME + ! " attribute value cannot be null."); this.loggingLevel=loggingConfigElement.getAttribute(LoggingConfig.LOGGING_LEVEL_ATTRIB_NAME); ! this.setLoggingLevel(loggingLevel); this.basePackageName=loggingConfigElement.getAttribute(LoggingConfig.BASE_PACKAGE_ATTRIB_NAME); + logger.exiting(LoggingConfig.class.getName(),"Constructor"); } *************** *** 423,426 **** --- 458,483 ---- /** + * This method validates the defined logging level and sets "SEVERE" + * if the defines logging level is not a valid one. + * + * @param loggingLevel Level defined framework logging configuration. + */ + private void setLoggingLevel(String loggingLevel) + { + try + { + /** + * Just to make sure Level could recognize the given level. + */ + Level.parse(loggingLevel); + this.loggingLevel=loggingLevel; + } + catch(Exception exception) + { + this.loggingLevel="SEVERE"; + logger.severe("Defined level of logging " + loggingLevel + " is not a valid and changed to default SEVERE level"); + } + } + /** * <p> * Returns the string representation of LoggingConfig class in the format *************** *** 488,496 **** 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); } --- 545,557 ---- private MgmtMntrConfig(Element mgmtMntrConfigElement) { + logger.entering(MgmtMntrConfig.class.getName(),"Constructor"); this.mgmtMntrClassName=mgmtMntrConfigElement.getAttribute(MgmtMntrConfig.MGMT_MNTR_CLASS_ATTRIB_NAME); ! if(this.mgmtMntrClassName==null || "".equals(this.mgmtMntrClassName)) ! throw new ConfigurationException(ConfigurationException.FRAMEWORK_CONFIG, MgmtMntrConfig.MGMT_MNTR_CLASS_ATTRIB_NAME + ! " attribute value cannot be null."); ! FrameworkUtil.loadPropertiesFromElementToMap(mgmtMntrConfigElement, this.mgmtMntrConfigProperties); + logger.exiting(MgmtMntrConfig.class.getName(),"Constructor"); } *************** *** 583,591 **** 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); } --- 644,656 ---- private RepositoryConfig(Element repositoryConfigElement) { + logger.entering(RepositoryConfig.class.getName(),"Constructor"); this.repositoryClassName=repositoryConfigElement.getAttribute(RepositoryConfig.REPOSITORY_CLASS_ATTRIB_NAME); ! if(this.repositoryClassName==null || "".equals(this.repositoryClassName)) ! throw new ConfigurationException(ConfigurationException.FRAMEWORK_CONFIG, RepositoryConfig.REPOSITORY_CLASS_ATTRIB_NAME + ! " attribute value cannot be null."); ! FrameworkUtil.loadPropertiesFromElementToMap(repositoryConfigElement, this.repositoryConfigProperties); + logger.exiting(RepositoryConfig.class.getName(),"Constructor"); } *************** *** 670,673 **** --- 735,739 ---- private JobControllerConfig(Element controllerConfigElement) { + logger.entering(JobControllerConfig.class.getName(),"Constructor"); NodeList controllerNodeList=controllerConfigElement.getElementsByTagName(JobControllerConfig.JOB_CONTROLLER_TAG_NAME); for(int i=0;i<controllerNodeList.getLength();i++) *************** *** 675,680 **** 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 { --- 741,747 ---- Element controllerElement=(Element)controllerNodeList.item(i); String controllerClassName=controllerElement.getAttribute(JobControllerConfig.JOB_CONTROLLER_CLASS_ATTRIB_NAME); ! if(controllerClassName==null || "".equals(controllerClassName)) ! throw new ConfigurationException(ConfigurationException.FRAMEWORK_CONFIG, JobControllerConfig.JOB_CONTROLLER_CLASS_ATTRIB_NAME + ! " attribute value cannot be null."); else { *************** *** 696,699 **** --- 763,767 ---- } } + logger.exiting(JobControllerConfig.class.getName(),"Constructor"); } Index: JobConfigFactory.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/JobConfigFactory.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** JobConfigFactory.java 8 Mar 2006 05:18:55 -0000 1.4 --- JobConfigFactory.java 13 Mar 2006 14:32:37 -0000 1.5 *************** *** 14,18 **** import java.lang.reflect.InvocationTargetException; import java.util.Map; ! import org.jmonks.batchserver.framework.common.ErrorCode; /** --- 14,18 ---- import java.lang.reflect.InvocationTargetException; import java.util.Map; ! import java.util.logging.Logger; /** *************** *** 24,28 **** * </p> * <p> ! * This will get the following XML block from framework configuration as JobConfigFactoryConfig * object. * <br><br> --- 24,28 ---- * </p> * <p> ! * This will get the following XML block from framework configuration as JobConfigFactoryConfig * object. * <br><br> *************** *** 38,43 **** * @since 1.0 */ ! public abstract class JobConfigFactory { /** * This factory method will return the appropriated job configuration factory based --- 38,45 ---- * @since 1.0 */ ! public abstract class JobConfigFactory { + private static Logger logger=Logger.getLogger(JobConfigFactory.class.getName()); + /** * This factory method will return the appropriated job configuration factory based *************** *** 54,101 **** * @throws IllegalArgumentException If input factory configuration is null. */ ! 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(new Class[]{Map.class}); ! if(JobConfigFactory.class.isAssignableFrom(factoryClass)) { factoryObject=(JobConfigFactory)factoryConstructor.newInstance(new Object[]{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; } --- 56,106 ---- * @throws IllegalArgumentException If input factory configuration is null. */ ! public static JobConfigFactory getJobConfigFactory(FrameworkConfig.JobConfigFactoryConfig factoryConfig) { + logger.entering(JobConfigFactory.class.getName(),"getJobConfigFactory"); JobConfigFactory factoryObject=null; if(factoryConfig==null) ! throw new IllegalArgumentException("Input job config factory configuration cannot be null."); String factoryClassName=factoryConfig.getJobConfigFactoryClassName(); ! try { 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 ! throw new ConfigurationException(ConfigurationException.JOB_CONFIG_FACTORY_CONFIG, factoryClass + " is not assignable to the class " + JobConfigFactory.class.getName()); ! ! logger.info("Job Configuration factory has been created."); ! } ! catch(ClassNotFoundException exception) { exception.printStackTrace(); ! throw new ConfigurationException(ConfigurationException.JOB_CONFIG_FACTORY_CONFIG, exception.getMessage()); } catch(NoSuchMethodException exception) { exception.printStackTrace(); ! throw new ConfigurationException(ConfigurationException.JOB_CONFIG_FACTORY_CONFIG, exception.getMessage()); } catch(InstantiationException exception) { exception.printStackTrace(); ! throw new ConfigurationException(ConfigurationException.JOB_CONFIG_FACTORY_CONFIG, exception.getMessage()); } catch(IllegalAccessException exception) { exception.printStackTrace(); ! throw new ConfigurationException(ConfigurationException.JOB_CONFIG_FACTORY_CONFIG, exception.getMessage()); } catch(InvocationTargetException exception) { exception.printStackTrace(); ! throw new ConfigurationException(ConfigurationException.JOB_CONFIG_FACTORY_CONFIG, exception.getMessage()); } ! logger.exiting(JobConfigFactory.class.getName(),"getJobConfigFactory"); return factoryObject; } Index: framework-config.xml =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/framework-config.xml,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** framework-config.xml 11 Mar 2006 02:16:38 -0000 1.9 --- framework-config.xml 13 Mar 2006 14:32:37 -0000 1.10 *************** *** 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-classpath-location">batch-config.xml</property> </job-config-factory-config> <!-- --- 1,6 ---- + <?xml version="1.0" encoding="UTF-8"?> <framework-config> <job-config-factory-config job-config-factory-class-name="org.jmonks.batchserver.framework.config.xml.XMLJobConfigFactory"> ! <property key="job-config-file-classpath-location">/org/jmonks/batchserver/framework/config/xml/batch-config.xml</property> </job-config-factory-config> <!-- *************** *** 15,21 **** <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> --- 16,22 ---- <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-directory="/batchserver/logs" logging-level="CONFIG" 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> *************** *** 23,27 **** <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" --- 24,28 ---- <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" Index: JobControllerConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/JobControllerConfig.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** JobControllerConfig.java 9 Mar 2006 04:44:07 -0000 1.4 --- JobControllerConfig.java 13 Mar 2006 14:32:37 -0000 1.5 *************** *** 13,16 **** --- 13,17 ---- import java.util.Iterator; import java.util.Map; + import java.util.logging.Logger; /** *************** *** 45,48 **** --- 46,51 ---- protected Map jobControllerConfigProps=new HashMap(); + private static Logger logger=Logger.getLogger(JobControllerConfig.class.getName()); + /** * Gets the job controller class name. *************** *** 80,83 **** --- 83,87 ---- public void overrideConfigProperties(Map newProps) { + logger.entering(JobControllerConfig.class.getName(),"overrideConfigProperties"); if(newProps==null ) return; *************** *** 91,94 **** --- 95,99 ---- { this.jobControllerConfigProps.put(key, newProps.get(key)); + logger.fine("Overriden the property " + key + " with " + newProps.get(key)); } } *************** *** 108,114 **** --- 113,121 ---- { this.jobControllerConfigProps.put(key, newProps.get(key)); + logger.fine("Overriden the property " + key + " with " + newProps.get(key)); } } + logger.exiting(JobControllerConfig.class.getName(),"overrideConfigProperties"); } Index: PoolJobControllerConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/PoolJobControllerConfig.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PoolJobControllerConfig.java 10 Mar 2006 08:14:51 -0000 1.5 --- PoolJobControllerConfig.java 13 Mar 2006 14:32:37 -0000 1.6 *************** *** 14,17 **** --- 14,18 ---- import java.util.Iterator; import java.util.Map; + import java.util.logging.Logger; /** *************** *** 56,59 **** --- 57,63 ---- */ protected String poolClassName=null; + + private static Logger logger=Logger.getLogger(PoolJobControllerConfig.class.getName()); + /** * Map contains the properties needed by pool class. *************** *** 144,147 **** --- 148,152 ---- super.overrideConfigProperties(newProps); + logger.entering(PoolJobControllerConfig.class.getName(),"overrideConfigProperties"); if(newProps==null ) return; *************** *** 156,159 **** --- 161,165 ---- { this.poolJobLoaderConfigProps.put(key, newProps.get(key)); + logger.fine("Overriden the property " + key + " with " + newProps.get(key)); } } *************** *** 167,170 **** --- 173,177 ---- { this.poolJobProcessorConfigProps.put(key, newProps.get(key)); + logger.fine("Overriden the property " + key + " with " + newProps.get(key)); } } *************** *** 178,185 **** { this.poolConfigProps.put(key, newProps.get(key)); } } ! ! } --- 185,192 ---- { this.poolConfigProps.put(key, newProps.get(key)); + logger.fine("Overriden the property " + key + " with " + newProps.get(key)); } } ! logger.exiting(PoolJobControllerConfig.class.getName(),"overrideConfigProperties"); } Index: ConfigurationException.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/ConfigurationException.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ConfigurationException.java 6 Mar 2006 23:54:45 -0000 1.4 --- ConfigurationException.java 13 Mar 2006 14:32:37 -0000 1.5 *************** *** 4,12 **** /** * <p> ! * Exception defines problems in either framework configuration or ! * job configuration. Configuration problems ! * cannot be detected until the runtime, so this exception will be ! * runtime exception. This will have the errorCode tells the ! * cause of the exception. * </p> * --- 4,12 ---- /** * <p> ! * ConfigurationException defines problems in either framework configuration ! * or job configuration. This is runtime exception, since, configuration ! * problems cannot be detected until the runtime. This will have component ! * name identifies either framework configuration or job configuration and the message ! * explains the complete problem. * </p> * *************** *** 18,42 **** { /** ! * Error code represents the cause of this exception. */ ! private ErrorCode errorCode=null; /** ! * Constructs an instance of <code>ConfigurationException</code> with the specified error code. ! * @param errorCode Error code represents the cause of the exception. */ ! public ConfigurationException(ErrorCode errorCode) { ! super(errorCode.getMessage()); ! this.errorCode=errorCode; } /** ! * Returns the error code represents the cause of this exception. * ! * @return Returns the error code. */ ! public ErrorCode getErrorCode() { ! return this.errorCode; } --- 18,67 ---- { /** ! * Componenet caused this exception. */ ! private String exceptionComponent=null; ! /** ! * Constant defines the source of framework config component. ! */ ! public static final String FRAMEWORK_CONFIG = "framework-config"; ! /** ! * Constant defines the source of job config component. ! */ ! public static final String JOB_CONFIG = "job-config"; ! /** ! * Constant defines the source of job config factory config component. ! */ ! public static final String JOB_CONFIG_FACTORY_CONFIG = "job-config-factory-config"; ! /** ! * Constant defines the source of controller config component. ! */ ! public static final String JOB_CONTROLLER_CONFIG = "job-controller-config"; ! /** ! * Constant defines the source of controller config component. ! */ ! public static final String LOGGING_CONFIG = "logging-config"; ! ! /** ! * Constructs an instance of <code>ConfigurationException</code> with the specified component ! * name and the message. ! * ! * @param exceptionComponent Specifies the source component of this exception. ! * @param message Messages states the problem. */ ! public ConfigurationException(String exceptionComponent,String message) { ! super(message); ! this.exceptionComponent=exceptionComponent; } /** ! * Returns the componenet caused this exception. * ! * @return Returns the component name. */ ! public String getExceptionComponent() { ! return this.exceptionComponent; } *************** *** 44,48 **** * <p> * Returns the string representation of ConfigurationException class in the format ! * <br> {ConfigurationException [errorCode = value]} * </p> * --- 69,73 ---- * <p> * Returns the string representation of ConfigurationException class in the format ! * <br> {ConfigurationException [component = value] [message = value]} * </p> * *************** *** 52,58 **** { StringBuffer stringValue=new StringBuffer("{ConfigurationException "); ! stringValue.append("[code = " + this.errorCode.toString() + "]"); stringValue.append("}"); return stringValue.toString(); } } --- 77,85 ---- { StringBuffer stringValue=new StringBuffer("{ConfigurationException "); ! stringValue.append("[component = " + this.exceptionComponent + "]"); ! stringValue.append("[message = " + this.getMessage() + "]"); stringValue.append("}"); return stringValue.toString(); } + } |