/** * Used by the configuration to create a new Scheduler during system startup.<p> * * @param configuredJobs the jobs from the configuration */ public CmsScheduleManager(List<CmsScheduledJobInfo> configuredJobs) { m_configuredJobs = configuredJobs; int size = 0; if (m_configuredJobs != null) { size = m_configuredJobs.size(); } if (CmsLog.INIT.isInfoEnabled()) { CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_SCHEDULER_CREATED_1, new Integer(size))); } }
/** * Used by the configuration to create a new Scheduler during system startup.<p> * * @param configuredJobs the jobs from the configuration */ public CmsScheduleManager(List configuredJobs) { m_configuredJobs = configuredJobs; int size = 0; if (m_configuredJobs != null) { size = m_configuredJobs.size(); } if (CmsLog.INIT.isInfoEnabled()) { CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_SCHEDULER_CREATED_1, new Integer(size))); } }
/** * Shuts down this instance of the OpenCms scheduler manager.<p> */ public synchronized void shutDown() { m_adminCms = null; if (CmsLog.INIT.isInfoEnabled()) { CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_SHUTDOWN_1, this.getClass().getName())); } if (m_scheduler != null) { try { m_scheduler.shutdown(); } catch (SchedulerException e) { LOG.error(Messages.get().getBundle().key(Messages.LOG_SHUTDOWN_ERROR_0)); } } m_scheduler = null; }
/** * Shuts down this instance of the OpenCms scheduler manager.<p> */ public synchronized void shutDown() { m_adminCms = null; if (CmsLog.INIT.isInfoEnabled()) { CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_SHUTDOWN_1, this.getClass().getName())); } if (m_scheduler != null) { try { m_scheduler.shutdown(); } catch (SchedulerException e) { LOG.error(Messages.get().getBundle().key(Messages.LOG_SHUTDOWN_ERROR_0)); } } m_scheduler = null; }
/** * Sets the job name.<p> * * @param jobName the job name to set */ public void setJobName(String jobName) { checkFrozen(); if (CmsStringUtil.isEmpty(jobName) || !jobName.trim().equals(jobName)) { throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_BAD_JOB_NAME_1, jobName)); } m_jobName = jobName; }
/** * Sets the job name.<p> * * @param jobName the job name to set */ public void setJobName(String jobName) { checkFrozen(); if (CmsStringUtil.isEmpty(jobName) || !jobName.trim().equals(jobName)) { throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_BAD_JOB_NAME_1, jobName)); } m_jobName = jobName; }
/** * Implementation of the Quartz job interface.<p> * * The architecture is that this scheduler manager generates * a new (empty) instance of itself for every OpenCms job scheduled with Quartz. * When the Quartz job is executed, the configured * implementation of {@link I_CmsScheduledJob} will be called from this method.<p> * * @see org.quartz.Job#execute(org.quartz.JobExecutionContext) */ public void execute(JobExecutionContext context) { JobDataMap jobData = context.getJobDetail().getJobDataMap(); CmsScheduledJobInfo jobInfo = (CmsScheduledJobInfo)jobData.get(SCHEDULER_JOB_INFO); if (jobInfo == null) { LOG.error(Messages.get().getBundle().key(Messages.LOG_INVALID_JOB_1, context.getJobDetail().getFullName())); // can not continue return; } executeJob(jobInfo); }
/** * Sets the job parameters.<p> * * @param parameters the parameters to set */ public void setParameters(SortedMap<String, String> parameters) { checkFrozen(); if (parameters == null) { throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_BAD_JOB_PARAMS_0)); } // make sure the parameters are a sorted map m_parameters = new TreeMap<String, String>(parameters); }
/** * Sets the job parameters.<p> * * @param parameters the parameters to set */ public void setParameters(SortedMap parameters) { checkFrozen(); if (parameters == null) { throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_BAD_JOB_PARAMS_0)); } // make sure the parameters are a sorted map m_parameters = new TreeMap(parameters); }
/** * Checks if this job info configuration is frozen.<p> * * @throws CmsRuntimeException in case the configuration is already frozen */ protected void checkFrozen() throws CmsRuntimeException { if (m_frozen) { throw new CmsRuntimeException(Messages.get().container(Messages.ERR_JOB_INFO_FROZEN_1, getJobName())); } }
/** * Checks if this job info configuration is frozen.<p> * * @throws CmsRuntimeException in case the configuration is already frozen */ protected void checkFrozen() throws CmsRuntimeException { if (m_frozen) { throw new CmsRuntimeException(Messages.get().container(Messages.ERR_JOB_INFO_FROZEN_1, getJobName())); } }
throw new SchedulerConfigException(Messages.get().getBundle().key(Messages.ERR_MAX_THREAD_COUNT_BOUNDS_0)); throw new SchedulerConfigException(Messages.get().getBundle().key(Messages.ERR_INIT_THREAD_COUNT_BOUNDS_0)); throw new SchedulerConfigException(Messages.get().getBundle().key(Messages.ERR_SCHEDULER_PRIORITY_BOUNDS_0)); LOG.debug(Messages.get().getBundle().key( Messages.LOG_USING_THREAD_CLASSLOADER_1, Thread.currentThread().getName()));
/** * Sets the context information for the user executing the job.<p> * * This will also "freeze" the context information that is set.<p> * * @param contextInfo the context information for the user executing the job * * @see CmsContextInfo#freeze() */ public void setContextInfo(CmsContextInfo contextInfo) { checkFrozen(); if (contextInfo == null) { throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_BAD_CONTEXT_INFO_0)); } m_context = contextInfo; }
throw new SchedulerConfigException(Messages.get().getBundle().key(Messages.ERR_MAX_THREAD_COUNT_BOUNDS_0)); throw new SchedulerConfigException(Messages.get().getBundle().key(Messages.ERR_INIT_THREAD_COUNT_BOUNDS_0)); Messages.get().getBundle().key(Messages.ERR_SCHEDULER_PRIORITY_BOUNDS_0)); Messages.get().getBundle().key( Messages.LOG_USING_THREAD_CLASSLOADER_1, Thread.currentThread().getName()));
/** * Sets the context information for the user executing the job.<p> * * This will also "freeze" the context information that is set.<p> * * @param contextInfo the context information for the user executing the job * * @see CmsContextInfo#freeze() */ public void setContextInfo(CmsContextInfo contextInfo) { checkFrozen(); if (contextInfo == null) { throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_BAD_CONTEXT_INFO_0)); } m_context = contextInfo; }
LOG.debug(Messages.get().getBundle().key( Messages.LOG_REUSING_INSTANCE_1, m_jobInstance.getClass().getName())); LOG.error(Messages.get().getBundle().key(Messages.LOG_CLASS_NOT_FOUND_1, getClassName()), e); } catch (IllegalAccessException e) { LOG.error(Messages.get().getBundle().key(Messages.LOG_ILLEGAL_ACCESS_0), e); } catch (InstantiationException e) { LOG.error(Messages.get().getBundle().key(Messages.LOG_INSTANCE_GENERATION_0), e); } catch (ClassCastException e) { LOG.error(Messages.get().getBundle().key(Messages.LOG_BAD_INTERFACE_0), e); LOG.debug(Messages.get().getBundle().key(Messages.LOG_JOB_CREATED_1, getClassName()));
if (LOG.isDebugEnabled()) { LOG.debug( Messages.get().getBundle().key(Messages.LOG_THREAD_POOL_WAITING_1, new Integer(i))); if ((activeCount > 0) && LOG.isInfoEnabled()) { LOG.info( Messages.get().getBundle().key(Messages.LOG_THREAD_POOL_STILL_ACTIVE_1, new Integer(activeCount))); LOG.debug(Messages.get().getBundle().key(Messages.LOG_THREAD_POOL_SHUTDOWN_0));
try { if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key( Messages.LOG_THREAD_POOL_WAITING_1, new Integer(i))); LOG.info(Messages.get().getBundle().key( Messages.LOG_THREAD_POOL_STILL_ACTIVE_1, new Integer(activeCount))); LOG.debug(Messages.get().getBundle().key(Messages.LOG_THREAD_POOL_SHUTDOWN_0));
/** * Given a job ID, this directly executes the corresponding job.<p> * * @param jobId the job id */ public void executeDirectly(String jobId) { final CmsScheduledJobInfo jobInfo = (CmsScheduledJobInfo)getJob(jobId).clone(); if (jobInfo == null) { LOG.error(Messages.get().getBundle().key(Messages.LOG_INVALID_JOB_1, "null")); return; } Thread thread = new Thread() { /** * @see java.lang.Thread#run() */ @Override public void run() { executeJob(jobInfo); } }; thread.start(); }
m_scheduler = schedulerFactory.getScheduler(); } catch (Exception e) { LOG.error(Messages.get().getBundle().key(Messages.LOG_NO_SCHEDULER_0), e); CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_SCHEDULER_INITIALIZED_0)); LOG.error(Messages.get().getBundle().key(Messages.LOG_CANNOT_START_SCHEDULER_0), e); CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_SCHEDULER_STARTED_0)); CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_SCHEDULER_CONFIG_FINISHED_0));