Thread: [Batchserver-cvs] batchserver/src/org/jmonks/batch/framework/controller JobController.java, NONE,
Brought to you by:
suresh_pragada
From: Suresh <sur...@us...> - 2006-09-15 20:06:32
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batch/framework/controller In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv19890 Added Files: JobController.java Log Message: no message --- NEW FILE: JobController.java --- package org.jmonks.batch.framework.controller; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.jmonks.batch.framework.JobStatistics; import org.jmonks.batch.framework.LoggingManager; import org.jmonks.batch.framework.ErrorCode; import org.jmonks.batch.framework.JobContext; import org.jmonks.batch.framework.config.ConfigurationException; import org.jmonks.batch.framework.management.JobMonitorMBean; import org.jmonks.batch.framework.management.JobManagerMBean; /** * <p> * Job Controller is the important component, which actually creates and drives * the execution of the job. This defines the logic and the flow, how the user components * needs to be written and how they would be driven while executing the job. * Framework provides two controllers called as BasicJobController and PoolJobController * which defines their own way of executing the job. * </p> * * <p> * JobController provides a factory method which returns the appropriate controller component * based on the provided controller config object. This implements the management and * monitoring interfaces to make sure all the controller implementations are manageable * and monitorable. * </p> * * @author Suresh Pragada * @version 1.0 * @since 1.0 */ public abstract class JobController implements JobMonitorMBean, JobManagerMBean { /** * JobContext associated to this controller. */ protected JobContext jobContext=null; /** * Singletone instance of job controller. */ private static JobController jobController=null; private static Logger logger=Logger.getLogger(JobController.class); /** * <p> * This factory method loads the required implementation of the controller * based on the controller configuration available in job context and sets * this context to the controller. * </p> * * @param jobContext Job context going to be associated with the controller. * * @return Returns the defined implementation of the controller. */ public static JobController getJobController(JobContext jobContext) { logger.trace("Entering getJobController = " + jobContext.getJobName()); if(jobController==null) { String jobControllerClassName=jobContext.getJobConfig().getJobControllerConfig().getJobControllerClasName(); if(jobControllerClassName==null || "".equals(jobControllerClassName)) throw new ConfigurationException(ConfigurationException.JOB_CONTROLLER_CONFIG, "job controller class name is not defined in job controller configuration"); logger.debug("job controller class name = " + jobControllerClassName); try { jobController=(JobController)Class.forName(jobControllerClassName).newInstance(); jobController.jobContext=jobContext; logger.debug("created the job controller implemenation class"); } catch(ClassNotFoundException exception) { exception.printStackTrace(); logger.error(exception.getMessage(),exception); throw new ConfigurationException(ConfigurationException.JOB_CONTROLLER_CONFIG, exception.getMessage()); } catch(InstantiationException exception) { exception.printStackTrace(); logger.error(exception.getMessage(),exception); throw new ConfigurationException(ConfigurationException.JOB_CONTROLLER_CONFIG, exception.getMessage()); } catch(IllegalAccessException exception) { exception.printStackTrace(); logger.error(exception.getMessage(),exception); throw new ConfigurationException(ConfigurationException.JOB_CONTROLLER_CONFIG, exception.getMessage()); } } logger.trace("Exiting getJobController = " + jobContext.getJobName()); return jobController; } /** * Gets the log level of the given logger name. * * @param loggerName Name of the logger wants to find the log level. * * @return Returns the log level, null, if the given logger could not be found. */ public Level getLogLevel(String loggerName) { return LoggingManager.getLogLevel(loggerName); } /** * Changes the log level for the requested logger name with the given log level. * * @param loggerName Logger name needs to be modified. * @param newLogLevel new logging level. * * @return Returns true, if log level could be changed, false, otherwise. */ public boolean changeLogLevel(String loggerName, Level level) { return LoggingManager.changeLogLevel(loggerName, level); } /** * This method will be called by the Main to process the job. This returns the * ErrorCode explaining whether the process has been failed or succeeded. * * @return Returns the ErrorCode as exit status of the job. */ public abstract ErrorCode process(); /** * Returns the statistics of this job. Statistics will be queried only * after the completion of controller processing. Querying before the completion * of processing always returns null. * * @return Returns the statistics of this job. */ public abstract JobStatistics getJobStatistics(); } |