[Batchserver-cvs] batchserver/src/org/jmonks/batchserver/framework/config ConfigurationException.jav
Brought to you by:
suresh_pragada
From: Suresh <sur...@us...> - 2006-03-14 23:02:31
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18605 Modified Files: ConfigurationException.java framework-config.xml framework-config.xsd FrameworkConfig.java Log Message: no message Index: framework-config.xsd =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/framework-config.xsd,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** framework-config.xsd 13 Mar 2006 14:32:37 -0000 1.1 --- framework-config.xsd 14 Mar 2006 23:02:19 -0000 1.2 *************** *** 6,10 **** <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"/> --- 6,10 ---- <xsd:complexType name="FrameworkConfigType"> <xsd:element name="job-config-factory-config" type="JobConfigFactoryConfigType"/> ! <xsd:element name="framework-logging-config" type="FrameworkLoggingConfigType"/> <xsd:element name="repository-config" type="RepositoryConfigType"/> <xsd:element name="mgmt-mntr-config" type="MgmtMntrConfigType"/> *************** *** 18,24 **** </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> --- 18,25 ---- </xsd:complexType> ! <xsd:complexType name="FrameworkLoggingConfigType"> ! <xsd:attribute name="framework-logging-level" type="LogLevelType" use="required"/> ! <xsd:attribute name="job-logging-direcotry" type="xsd:string" use="required"/> ! <xsd:attribute name="job-logging-level" type="LogLevelType" use="required"/> <xsd:attribute name="job-base-package-name" type="xsd:string" use="required"/> </xsd:complexType> *************** *** 54,58 **** --- 55,63 ---- <xsd:simpleType name="LogLevelType"> <xsd:restriction base="xsd:string"> + <xsd:enumeration value="ALL"/> + <xsd:enumeration value="TRACE"/> <xsd:enumeration value="DEBUG"/> + <xsd:enumeration value="INFO"/> + <xsd:enumeration value="WARN"/> <xsd:enumeration value="ERROR"/> </xsd:restriction> Index: framework-config.xml =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/framework-config.xml,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** framework-config.xml 14 Mar 2006 05:45:25 -0000 1.11 --- framework-config.xml 14 Mar 2006 23:02:19 -0000 1.12 *************** *** 18,22 **** <property key="repository-filename">batchserver_repository.db</property> </repository-config> ! <logging-config job-logging-directory="/batchserver/logs" job-base-package-name="com.mycompany.batch" job-logging-level="ERROR"/> <mgmt-mntr-config mgmt-mntr-class-name="org.jmonks.batchserver.framework.mgmtmntr.DefaultMgmtMntrManager"> <property key="port-range">15000-20000</property> --- 18,23 ---- <property key="repository-filename">batchserver_repository.db</property> </repository-config> ! <framework-logging-config framework-logging-level="DEBUG" job-logging-directory="/batchserver/logs" ! job-base-package-name="com.mycompany.batch" job-logging-level="INFO"/> <mgmt-mntr-config mgmt-mntr-class-name="org.jmonks.batchserver.framework.mgmtmntr.DefaultMgmtMntrManager"> <property key="port-range">15000-20000</property> Index: FrameworkConfig.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/FrameworkConfig.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** FrameworkConfig.java 14 Mar 2006 05:45:25 -0000 1.8 --- FrameworkConfig.java 14 Mar 2006 23:02:19 -0000 1.9 *************** *** 61,67 **** private JobConfigFactoryConfig configFactoryConfig=null; /** ! * LoggingConfig variable to hold the LoggingConfig object. */ ! private LoggingConfig logginConfig=null; /** * MgmtMntrConfig variable to hold the MgmtMntrConfig object. --- 61,67 ---- private JobConfigFactoryConfig configFactoryConfig=null; /** ! * FrameworkLoggingConfig variable to hold the FrameworkLoggingConfig object. */ ! private FrameworkLoggingConfig frameworkLoggingConfig=null; /** * MgmtMntrConfig variable to hold the MgmtMntrConfig object. *************** *** 77,87 **** private JobControllerConfig controllerConfig=null; ! /** * Private constructor to make sure FrameworkCongi cannot be instantiated. This will * read the framework configuration file and create the instances of of JobConfigFactoryConfig, ! * LoggingConfig, MgmtMntrConfig and RepositoryConfig by passing the correct DOM elements to their * constructors. This does the validation of configuration file against the defined XML schema file. * In case of errors it throws the ConfigurationException with the correct error code. ! * * @throws RuntimeException If framework configuration file is not properly formed and validation is failed. * @throws ConfigurationException If configuration file could not be found. --- 77,88 ---- private JobControllerConfig controllerConfig=null; ! /** ! * * Private constructor to make sure FrameworkCongi cannot be instantiated. This will * read the framework configuration file and create the instances of of JobConfigFactoryConfig, ! * FrameworkLoggingConfig, MgmtMntrConfig and RepositoryConfig by passing the correct DOM elements to their * constructors. This does the validation of configuration file against the defined XML schema file. * In case of errors it throws the ConfigurationException with the correct error code. ! * * @throws RuntimeException If framework configuration file is not properly formed and validation is failed. * @throws ConfigurationException If configuration file could not be found. *************** *** 130,144 **** } logger.debug("Job Config Factory configuration has been loaded and the configuration is : " + this.configFactoryConfig); ! NodeList loggingConfigNodeList=frameworkConfigElement.getElementsByTagName(LoggingConfig.TAG_NAME); if(loggingConfigNodeList.getLength()==1) { ! this.logginConfig=new LoggingConfig(((Element)loggingConfigNodeList.item(0))); } 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.debug("Logging configuration has been loaded and the configuration is : " + this.logginConfig); NodeList mgmtMntrConfigNodeList=frameworkConfigElement.getElementsByTagName(MgmtMntrConfig.TAG_NAME); if(mgmtMntrConfigNodeList.getLength()==1) --- 131,145 ---- } logger.debug("Job Config Factory configuration has been loaded and the configuration is : " + this.configFactoryConfig); ! NodeList loggingConfigNodeList=frameworkConfigElement.getElementsByTagName(FrameworkLoggingConfig.TAG_NAME); if(loggingConfigNodeList.getLength()==1) { ! this.frameworkLoggingConfig=new FrameworkLoggingConfig(((Element)loggingConfigNodeList.item(0))); } else { throw new ConfigurationException(ConfigurationException.FRAMEWORK_CONFIG, "Found " + loggingConfigNodeList.getLength() + " " + ! FrameworkLoggingConfig.TAG_NAME + " element(s) in the framework configuration, where only one such element is allowed."); } ! logger.debug("Logging configuration has been loaded and the configuration is : " + this.frameworkLoggingConfig); NodeList mgmtMntrConfigNodeList=frameworkConfigElement.getElementsByTagName(MgmtMntrConfig.TAG_NAME); if(mgmtMntrConfigNodeList.getLength()==1) *************** *** 178,181 **** --- 179,183 ---- { ioException.printStackTrace(); + logger.error(ioException.getMessage(),ioException); throw new ConfigurationException(ConfigurationException.FRAMEWORK_CONFIG, ioException.getMessage()); } *************** *** 183,186 **** --- 185,189 ---- { parserConfigException.printStackTrace(); + logger.error(parserConfigException.getMessage(), parserConfigException); throw new ConfigurationException(ConfigurationException.FRAMEWORK_CONFIG, parserConfigException.getMessage()); } *************** *** 188,191 **** --- 191,195 ---- { saxException.printStackTrace(); + logger.error(saxException.getMessage(), saxException); throw new ConfigurationException(ConfigurationException.FRAMEWORK_CONFIG, saxException.getMessage()); } *************** *** 215,225 **** /** ! * Returns the logging configuration defined in the framework configuration as a LoggingConfig object. ! * ! * @return Returns the LoggingConfig object. */ ! public LoggingConfig getLoggingConfig() { ! return this.logginConfig; } --- 219,229 ---- /** ! * Returns the logging configuration defined in the framework configuration as a FrameworkLoggingConfig object. ! * ! * @return Returns the FrameworkLoggingConfig object. */ ! public FrameworkLoggingConfig getFrameworkLoggingConfig() { ! return this.frameworkLoggingConfig; } *************** *** 358,365 **** /** * <p> ! * LoggingConfig class holds configuration required to enable the framework logging * by LoggingManager. This configuration would be like the directory needs to write ! * job log files and logging level and base package name to be used to create the ! * logging handlers. This class can be accessed by all the classes in the framework * but cannot be instantiated outside of this class. * </p> --- 362,370 ---- /** * <p> ! * FrameworkLoggingConfig class holds configuration required to enable the framework logging * by LoggingManager. This configuration would be like the directory needs to write ! * job log files and logging level of the framework logs and job logs and base package name ! * to be used to create the logging handlers. ! * This class can be accessed by all the classes in the framework * but cannot be instantiated outside of this class. * </p> *************** *** 368,406 **** * <br><br> * <pre> ! * <logging-config logging-direcotry="/batchserver/logs" logging-level="DEBUG" job-base-package-name="com.mycompany.batch"/> * </pre> * </p> */ ! public class LoggingConfig { /** * Tag name represents the logging config in framework configuration file. */ ! private static final String TAG_NAME = "logging-config"; /** ! * Attribute name defines the logging directory. */ ! private static final String LOGGING_DIRECTORY_ATTRIB_NAME = "job-logging-directory"; /** ! * Attribute name defines the logging level. */ ! private static final String LOGGING_LEVEL_ATTRIB_NAME = "job-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; /** --- 373,420 ---- * <br><br> * <pre> ! * <framework-logging-config framework-logging-level="DEBUG" job-logging-direcotry="/batchserver/logs" ! * job-base-package-name="com.mycompany.batch" job-logging-level="DEBUG"/> * </pre> * </p> */ ! public class FrameworkLoggingConfig { /** * Tag name represents the logging config in framework configuration file. */ ! private static final String TAG_NAME = "framework-logging-config"; /** ! * Attribute name defines the framework logging level. ! */ ! private static final String FRAMEWORK_LOGGING_LEVEL_ATTRIB_NAME = "framework-logging-level"; ! /** ! * Attribute name defines the job logging directory. */ ! private static final String JOB_LOGGING_DIRECTORY_ATTRIB_NAME = "job-logging-directory"; /** ! * Attribute name defines the job logging level. */ ! private static final String JOB_LOGGING_LEVEL_ATTRIB_NAME = "job-logging-level"; /** ! * Attribute name defines the job base package name. */ ! private static final String JOB_BASE_PACKAGE_ATTRIB_NAME = "job-base-package-name"; ! /** ! * Framework logging level. ! */ ! private String frameworkLoggingLevel="DEBUG"; /** * Direcotry where all the log files needs to be written. */ ! private String jobLoggingDirectory=null; /** ! * Job logging level. */ ! private String jobLoggingLevel="ERROR"; /** * Base package name of the application(job). */ ! private String jobBasePackageName=null; /** *************** *** 411,445 **** * @param loggingConfigElement DOM Element represents <logging-config> tag in framework configuration file. */ ! private LoggingConfig(Element loggingConfigElement) { logger.trace("Entering LoggingConfig 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.basePackageName=loggingConfigElement.getAttribute(LoggingConfig.BASE_PACKAGE_ATTRIB_NAME); logger.trace("Exiting LoggingConfig Constructor"); } /** ! * Returns the logging directory name, where to all the job logs needs to be written. * * @return Returns the logging directory name. */ ! public String getLoggingDirecotry() { ! return this.loggingDirectory; } /** ! * Returns the log level to use for the logging. * * @return Returns the log level. */ ! public String getFrameworkLogLevel() { ! return this.loggingLevel; } --- 425,476 ---- * @param loggingConfigElement DOM Element represents <logging-config> tag in framework configuration file. */ ! private FrameworkLoggingConfig(Element loggingConfigElement) { logger.trace("Entering LoggingConfig Constructor"); ! this.jobLoggingDirectory=loggingConfigElement.getAttribute(FrameworkLoggingConfig.JOB_LOGGING_DIRECTORY_ATTRIB_NAME); ! if(jobLoggingDirectory==null || "".equals(jobLoggingDirectory)) ! throw new ConfigurationException(ConfigurationException.FRAMEWORK_CONFIG, FrameworkLoggingConfig.JOB_LOGGING_DIRECTORY_ATTRIB_NAME + " attribute value cannot be null."); ! this.frameworkLoggingLevel=loggingConfigElement.getAttribute(FrameworkLoggingConfig.FRAMEWORK_LOGGING_LEVEL_ATTRIB_NAME); ! if(this.frameworkLoggingLevel== null || "".equals(this.frameworkLoggingLevel)) ! this.frameworkLoggingLevel="DEBUG"; ! ! this.jobLoggingLevel=loggingConfigElement.getAttribute(FrameworkLoggingConfig.JOB_LOGGING_LEVEL_ATTRIB_NAME); ! if(this.jobLoggingLevel== null || "".equals(this.jobLoggingLevel)) ! this.jobLoggingLevel="ERROR"; ! ! this.jobBasePackageName=loggingConfigElement.getAttribute(FrameworkLoggingConfig.JOB_BASE_PACKAGE_ATTRIB_NAME); logger.trace("Exiting LoggingConfig Constructor"); } /** ! * Returns the job logging directory name, where to all the job logs needs to be written. * * @return Returns the logging directory name. */ ! public String getJobLoggingDirecotry() { ! return this.jobLoggingDirectory; } /** ! * Returns the framework log level to use for the logging. * * @return Returns the log level. */ ! public String getFrameworkLoggingLevel() { ! return this.frameworkLoggingLevel; ! } ! ! /** ! * Returns the job log level to use for the logging. ! * ! * @return Returns the log level. ! */ ! public String getJobLoggingLevel() ! { ! return this.jobLoggingLevel; } *************** *** 450,472 **** * @return Returns the jobs base package name. */ ! 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(); --- 481,505 ---- * @return Returns the jobs base package name. */ ! public String getJobBasePackageName() { ! return this.jobBasePackageName; } /** * <p> ! * Returns the string representation of FrameworkLoggingConfig class in the format ! * <br> {FrameworkLoggingConfig [jobLoggingDirectory = value] [frameworkLoggingLevel = value] ! * [jobBasePackageName = value] [jobLoggingLevel = value]} * </p> ! * ! * @return Returns the string representation of FrameworkLoggingConfig. */ public String toString() { StringBuffer stringValue=new StringBuffer("{LoggingConfig "); ! stringValue.append("[jobLoggingDirectory = " + this.jobLoggingDirectory + "]"); ! stringValue.append("[frameworkLoggingLevel = " + this.frameworkLoggingLevel + "]"); ! stringValue.append("[jobBasePackageName = " + this.jobBasePackageName + "]"); ! stringValue.append("[jobLoggingLevel = " + this.jobLoggingLevel + "]"); stringValue.append("}"); return stringValue.toString(); *************** *** 776,780 **** * <p> * Returns the string representation of FrameworkConfig class in the format ! * <br> {FrameworkConfig [jobConfigFactoryConfig = value] [loggingConfig = value] * [mgmtMntrConfig = value] [repositoryConfig = value][controllerConfig = value]} * </p> --- 809,813 ---- * <p> * Returns the string representation of FrameworkConfig class in the format ! * <br> {FrameworkConfig [jobConfigFactoryConfig = value] [frameworkLoggingConfig = value] * [mgmtMntrConfig = value] [repositoryConfig = value][controllerConfig = value]} * </p> *************** *** 786,790 **** 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 + "]"); --- 819,823 ---- StringBuffer stringValue=new StringBuffer("{FrameworkConfig "); stringValue.append("[jobConfigFactoryConfig = " + this.configFactoryConfig + "]"); ! stringValue.append("[frameworkLoggingConfig = " + this.frameworkLoggingConfig + "]"); stringValue.append("[mgmtMntrConfig = " + this.mgmtMntrConfig + "]"); stringValue.append("[repositoryConfig = " + this.repositoryConfig + "]"); Index: ConfigurationException.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/config/ConfigurationException.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ConfigurationException.java 13 Mar 2006 14:32:37 -0000 1.5 --- ConfigurationException.java 14 Mar 2006 23:02:19 -0000 1.6 *************** *** 41,44 **** --- 41,48 ---- */ public static final String LOGGING_CONFIG = "logging-config"; + /** + * Constant defines the source of repository config component. + */ + public static final String REPOSITORY_CONFIG = "repository-config"; |