Thread: [Batchserver-cvs] batchserver/src/org/jmonks/batchserver/framework/common ErrorCode.java,1.14,1.15 F
Brought to you by:
suresh_pragada
From: Suresh <sur...@us...> - 2006-05-19 18:55:23
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/common In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv31715/org/jmonks/batchserver/framework/common Modified Files: ErrorCode.java FrameworkUtil.java Log Message: no message Index: FrameworkUtil.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/common/FrameworkUtil.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** FrameworkUtil.java 13 Mar 2006 14:32:37 -0000 1.7 --- FrameworkUtil.java 19 May 2006 18:55:17 -0000 1.8 *************** *** 14,19 **** * </p> * <p> ! * Note : This class does not maintain any state. Keep all the methods as static and make ! * sure taken appropriate steps in case of that method is accessed by mulitple threads. * </p> * --- 14,18 ---- * </p> * <p> ! * Note : This class does not maintain any state. Keep all the methods as static * </p> * *************** *** 86,103 **** /** * <p> ! * Loads the property elements exists in the given element to the given map. ! * This looks for the <property> elements in the given element and looks ! * for the value of "key" attribute and the values of <property> element ! * and load them as key values pairs. * </p> * <p> * Property elements should be in the following format.<br><br> ! * <property key="some-config-key1">some-config-value1</property> * </p> * ! * @param configElement DOM Element consists of <property> elements. * @param propertyMap Map to be loaded with property key values. * ! * @throws IllegalArgumentException If either configElement or propertyMap is null. */ public static void loadPropertiesFromStringToMap(String propertiesString,Map propertyMap) --- 85,101 ---- /** * <p> ! * Loads the property key value pairs exists in the given string to the given map. ! * This looks for the properties in concantenated by ":" and each property in turn ! * concatenated by "=". * </p> * <p> * Property elements should be in the following format.<br><br> ! * key1=value1:key2=value2 * </p> * ! * @param propertiesString String consists of properties. * @param propertyMap Map to be loaded with property key values. * ! * @throws IllegalArgumentException If either propertiesString or propertyMap is null. */ public static void loadPropertiesFromStringToMap(String propertiesString,Map propertyMap) *************** *** 114,124 **** { String property=propertiesTokenizer.nextToken(); ! StringTokenizer propertyTokenizer=new StringTokenizer(property,"="); ! String key=propertyTokenizer.nextToken(); ! String value=propertyTokenizer.nextToken(); ! propertyMap.put(key,value); } logger.exiting(FrameworkUtil.class.getName(),"loadPropertiesFromStringToMap"); ! } ! } \ No newline at end of file --- 112,124 ---- { String property=propertiesTokenizer.nextToken(); ! if(property!=null && !"".equals(property.trim())) ! { ! StringTokenizer propertyTokenizer=new StringTokenizer(property,"="); ! String key=propertyTokenizer.nextToken(); ! String value=propertyTokenizer.nextToken(); ! propertyMap.put(key,value); ! } } logger.exiting(FrameworkUtil.class.getName(),"loadPropertiesFromStringToMap"); ! } } \ No newline at end of file Index: ErrorCode.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/common/ErrorCode.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** ErrorCode.java 3 May 2006 22:11:18 -0000 1.14 --- ErrorCode.java 19 May 2006 18:55:17 -0000 1.15 *************** *** 4,10 **** * <p> * The ErrorCode represents the error condition can generate in the system ! * and holds error code and message. This is like a enum class to make sure ! * the exit codes being passed around the application are valid (defined). ! * No instances of this class can be created from outside and cannot be instantiated. * </p> * --- 4,11 ---- * <p> * The ErrorCode represents the error condition can generate in the system ! * and holds error code and message. This is also used to represent the status code ! * for any processor/controller/job. This is like a enum class to make sure ! * the exit codes being passed around the application are valid (defined) and ! * allows the flexibility to append the context specific messages to the error codes. * </p> * *************** *** 27,32 **** /** * <p> ! * Private constructor make sure no instances will be created of this class ! * from outside of this class. * </p> * --- 28,33 ---- /** * <p> ! * Protected constructor to make sure no instances will be created of this class ! * from outside of this class and it is extensible. * </p> * *************** *** 48,52 **** { return this.code; - } --- 49,52 ---- *************** *** 62,65 **** --- 62,99 ---- /** + * Creates a new erorcode with the same errorcode and appends the given + * message to the existing message and returns the new error code. + * + * @param messageToBeAppended Message that needs to be appended to the existing message. + * + * @return Returns a new error code contains the same error code and appended message. + */ + public ErrorCode appendMessage(String messageToBeAppended) + { + return new ErrorCode(this.code, this.message+" " + messageToBeAppended); + } + + /** + * Equality will be based on the code the two error codes contain. + * + * @see java.lang.Object#equals(java.lang.Object) + */ + public boolean equals(Object errorCode) + { + return (errorCode!=null) && (this.getClass()==errorCode.getClass()) && + (this.code==((ErrorCode)errorCode).getCode()); + } + + /** + * Code represented by error code will be returned as a hash code. + * + * @see java.lang.Object#hashCode() + */ + public int hashCode() + { + return this.code; + } + + /** * <p> * Returns the string representation of ErrorCode class in the format *************** *** 78,93 **** } /** ! * Configuration Error Codes. */ - public static final ErrorCode JOB_COMPLETED_SUCCESSFULLY = new ErrorCode(0,"Job successfully completed."); - public static final ErrorCode FRAMEWORK_CONFIGURATION_ERROR = new ErrorCode(1001,"Error while accessing or parsing the framework configuration file."); public static final ErrorCode JOB_CONFIG_FACTORY_CONFIGURATION_ERROR = new ErrorCode(1002,"Job configuration factory cannot be created by the given factory configuration."); public static final ErrorCode JOB_CONFIGURATION_ERROR = new ErrorCode(1003,"Error while loading the job configuration from the defined factory."); public static final ErrorCode JOB_IS_NOT_CONFIGURED = new ErrorCode(1004,"Job is not configured"); ! public static final ErrorCode JOB_CONTROLLER_CONFIGURATION_ERROR = new ErrorCode(1005,"Job controller configuration is not defined properly."); ! ! public static final ErrorCode BASIC_JOB_PROCESSOR_EXCEPTION = new ErrorCode(1006,"Controller caught exception while executing process method on basic job processor."); ! } --- 112,163 ---- } + /** + * Represents job got completed successfully. + */ + public static final ErrorCode JOB_COMPLETED_SUCCESSFULLY = new ErrorCode(0,"Job completed successfully."); + /** + * Represents job got completed with errors. This represents the partial success. + */ + public static final ErrorCode JOB_COMPLETED_WITH_ERRORS = new ErrorCode(1, "Job completed with some errors."); /** ! * Represents the configuration error used to invoke the job. ! */ ! public static final ErrorCode JOB_INVOKATION_CONFIGURAION_ERROR = new ErrorCode(1000,"Error while parsing the configuraion passed to invoke job."); ! /** ! * Represents the framework configuration error. */ public static final ErrorCode FRAMEWORK_CONFIGURATION_ERROR = new ErrorCode(1001,"Error while accessing or parsing the framework configuration file."); + /** + * Represents the job config factory configuration error. + */ public static final ErrorCode JOB_CONFIG_FACTORY_CONFIGURATION_ERROR = new ErrorCode(1002,"Job configuration factory cannot be created by the given factory configuration."); + /** + * Represents the job configuration error. + */ public static final ErrorCode JOB_CONFIGURATION_ERROR = new ErrorCode(1003,"Error while loading the job configuration from the defined factory."); + /** + * Represents the job is not configured error. + */ public static final ErrorCode JOB_IS_NOT_CONFIGURED = new ErrorCode(1004,"Job is not configured"); ! /** ! * Represents the job controller configuration error. ! */ ! public static final ErrorCode JOB_CONTROLLER_CONFIGURATION_ERROR = new ErrorCode(1005,"Job controller configuration is not defined properly."); ! /** ! * Represents error because of the exception in basic job processor. ! */ ! public static final ErrorCode BASIC_JOB_PROCESSOR_EXCEPTION = new ErrorCode(1102,"Basic Job Controller caught exception while executing process method on basic job processor."); ! /** ! * Represents error because of the exception in pool job loader. ! */ ! public static final ErrorCode POOL_JOB_LOADER_EXCEPTION = new ErrorCode(1201,"Exception while executing the loader to load the pool."); ! /** ! * Represents error because of the exception in pool job processor. ! */ ! public static final ErrorCode POOL_JOB_PROCESSOR_EXCEPTION = new ErrorCode(1202,"Exception while executing the processor to process the pool."); ! /** ! * Rpresents miscellaneous Error codes. ! */ ! public static final ErrorCode CUSTOM_ERROR_CODE = new ErrorCode(1301, "Custome Error = "); ! } |