[Batchserver-cvs] batchserver/src/org/jmonks/batchserver/framework ErrorCode.java, NONE, 1.1 Main.j
Brought to you by:
suresh_pragada
From: Suresh <sur...@us...> - 2006-08-29 02:01:35
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv21323/framework Modified Files: Main.java Added Files: ErrorCode.java Log Message: no message Index: Main.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/Main.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Main.java 23 Aug 2006 14:53:55 -0000 1.13 --- Main.java 29 Aug 2006 02:01:33 -0000 1.14 *************** *** 4,9 **** import java.util.Map; import org.apache.log4j.Logger; ! import org.jmonks.batchserver.framework.common.ErrorCode; ! import org.jmonks.batchserver.framework.common.FrameworkUtil; import org.jmonks.batchserver.framework.config.ConfigurationException; import org.jmonks.batchserver.framework.config.FrameworkConfig; --- 4,9 ---- import java.util.Map; import org.apache.log4j.Logger; ! import org.jmonks.batchserver.framework.ErrorCode; ! import org.jmonks.batchserver.framework.util.FrameworkUtil; import org.jmonks.batchserver.framework.config.ConfigurationException; import org.jmonks.batchserver.framework.config.FrameworkConfig; --- NEW FILE: ErrorCode.java --- package org.jmonks.batchserver.framework; /** * <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> * * @author Suresh Pragada * @version 1.0 * @since 1.0 */ public final class ErrorCode { public static final int FRAMEWORK_MAX_ERROR_CODE = 9999; /** * Code represents the error. */ private int code; /** * Message illustrates the code. */ private String message=null; /** * <p> * Protected constructor to make sure no instances will be created of this class * from outside of this class and it is extensible. * </p> * * @param code Code represents the error. * @param errorMsg Message illustrates the exit code. */ private ErrorCode(int code, String errorMsg) { this.code=code; this.message=errorMsg; } /** * Returns the error code represents the error. * * @return Returns the error code represents the error. */ public int getCode() { return this.code; } /** * Returns the error message illustrates the exit code. * * @return Returns the error message. */ public String getMessage() { return this.message; } /** * Creates a new ErorCode object with the same error code and appends the given * message to the existing message and returns that 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); } /** * Creates a new error code by accepting the code and message. The code * should be greater than the value "9999", maximum range being used by the framework. * * @param newCode Code to be used to construct the ErrorCode. * @param newMessage Mesage to be used to construct the ErrorCode. * * @throws java.lang.IllegalArgumentException If given code is not greater than 9999. */ public static ErrorCode createErrorCode(int newCode, String newMessage) { if(newCode>ErrorCode.FRAMEWORK_MAX_ERROR_CODE) return new ErrorCode(newCode,newMessage); else throw new IllegalArgumentException("Code to create new ErrorCode should be greater than " + ErrorCode.FRAMEWORK_MAX_ERROR_CODE); } /** * 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 * <br> {ErrorCode [code = value] [message = value]} * </p> * * @return Returns the string representation of ErrorCode. */ public String toString() { StringBuffer stringValue=new StringBuffer("{ErrorCode "); stringValue.append("[code = " + this.code + "]"); stringValue.append("[message = " + this.message + "]"); stringValue.append("}"); return stringValue.toString(); } /** * 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 the logging configuration error. */ public static final ErrorCode JOB_LOGGING_CONFIGURATION_ERROR = new ErrorCode(1006,"Job logging configuration is not defined properly."); /** * Represents the repository configuration error. */ public static final ErrorCode JOB_REPOSITORY_CONFIGURATION_ERROR = new ErrorCode(1007,"Repository configuration in framework configuration is not defined properly."); /** * Represents the connector configuration error. */ public static final ErrorCode JOB_CONNECTOR_CONFIGURATION_ERROR = new ErrorCode(1008,"Repository configuration in framework configuration is not defined properly."); /** * Represents the unknown configuration error. */ public static final ErrorCode UNKNOWN_CONFIGURATION_ERROR = new ErrorCode(1009,"Configuration error related to unknown component."); /** * 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."); } |