use of org.quartz.JobExecutionException in project OpenClinica by OpenClinica.
the class ImportSpringJob method executeInternal.
@Override
protected void executeInternal(final JobExecutionContext context) throws JobExecutionException {
ApplicationContext appContext;
try {
appContext = (ApplicationContext) context.getScheduler().getContext().get("applicationContext");
TransactionTemplate transactionTemplate = (TransactionTemplate) appContext.getBean("sharedTransactionTemplate");
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
executeInternalInTransaction(context);
}
});
} catch (SchedulerException e) {
throw new JobExecutionException(e);
}
}
use of org.quartz.JobExecutionException in project sling by apache.
the class QuartzJobExecutor method execute.
/**
* @see org.quartz.Job#execute(org.quartz.JobExecutionContext)
*/
@Override
public void execute(final JobExecutionContext context) throws JobExecutionException {
final JobDataMap data = context.getJobDetail().getJobDataMap();
final JobDesc desc = new JobDesc(data);
final Logger logger = (Logger) data.get(QuartzScheduler.DATA_MAP_LOGGER);
// check run on information
if (!shouldRun(logger, desc)) {
return;
}
String origThreadName = Thread.currentThread().getName();
try {
Thread.currentThread().setName(origThreadName + "-" + desc.name);
logger.debug("Executing job {}", desc);
if (desc.job instanceof org.apache.sling.commons.scheduler.Job) {
@SuppressWarnings("unchecked") final Map<String, Serializable> configuration = (Map<String, Serializable>) data.get(QuartzScheduler.DATA_MAP_CONFIGURATION);
final JobContext jobCtx = new JobContextImpl(desc.name, configuration);
((org.apache.sling.commons.scheduler.Job) desc.job).execute(jobCtx);
} else if (desc.job instanceof Runnable) {
((Runnable) desc.job).run();
} else {
logger.error("Scheduled job {} is neither a job nor a runnable: {}", desc);
}
} catch (final Throwable t) {
// if this is a quartz exception, rethrow it
if (t instanceof JobExecutionException) {
throw (JobExecutionException) t;
}
// there is nothing we can do here, so we just log
logger.error("Exception during job execution of " + desc + " : " + t.getMessage(), t);
} finally {
Thread.currentThread().setName(origThreadName);
}
}
use of org.quartz.JobExecutionException in project oxCore by GluuFederation.
the class TimerJob method execute.
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
try {
TimerEvent timerEvent = (TimerEvent) context.getJobDetail().getJobDataMap().get(KEY_TIMER_EVENT);
if (timerEvent == null) {
return;
}
log.debug("Fire timer event [{}] with qualifiers {}", timerEvent.getTargetEvent().getClass().getName(), timerEvent.getQualifiers());
beanManager.fireEvent(timerEvent.getTargetEvent(), timerEvent.getQualifiers());
} catch (Exception ex) {
throw new JobExecutionException(ex);
}
}
use of org.quartz.JobExecutionException in project bamboobsc by billchen198318.
the class ClearTempDataJobImpl method executeInternal.
@Override
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
if (ContextLoader.getCurrentWebApplicationContext() == null) {
log.warn("ApplicationContext no completed, AppContext.getApplicationContext() == null");
return;
}
log.info("begin....");
try {
/**
* document reference:
* com.netsteadfast.greenstep.support.CleanTempUploadForContextInitAndDestroy.java
*/
this.loginForBackgroundProgram();
List<SysVO> systems = ApplicationSiteUtils.getSystems();
if (systems == null || systems.size() < 1) {
return;
}
for (SysVO sys : systems) {
UploadSupportUtils.cleanTempUpload(sys.getSysId());
}
/**
* document reference:
* com.netsteadfast.greenstep.bsc.support.CleanJasperReportTempDataForContextInitAndDestroy.java
*
*/
NamedParameterJdbcTemplate namedParameterJdbcTemplate = (NamedParameterJdbcTemplate) AppContext.getBean("namedParameterJdbcTemplate");
Map<String, Object> paramMap = new HashMap<String, Object>();
namedParameterJdbcTemplate.update("delete from bb_swot_report_mst", paramMap);
namedParameterJdbcTemplate.update("delete from bb_swot_report_dtl", paramMap);
} catch (ServiceException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
this.logoutForBackgroundProgram();
} catch (Exception e) {
e.printStackTrace();
}
}
log.info("end....");
}
use of org.quartz.JobExecutionException in project engine by craftercms.
the class ScriptJob method execute.
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
JobDataMap dataMap = context.getJobDetail().getJobDataMap();
String scriptUrl = dataMap.getString(SCRIPT_URL_DATA_KEY);
SiteContext siteContext = (SiteContext) dataMap.get(SITE_CONTEXT_DATA_KEY);
ServletContext servletContext = (ServletContext) dataMap.get(SERVLET_CONTEXT_DATA_KEY);
ScriptFactory scriptFactory = siteContext.getScriptFactory();
if (scriptFactory == null) {
throw new JobExecutionException("No script factory associate to site context '" + siteContext.getSiteName() + "'");
}
SiteContext.setCurrent(siteContext);
try {
Map<String, Object> variables = new HashMap<>();
GroovyScriptUtils.addJobScriptVariables(variables, servletContext);
scriptFactory.getScript(scriptUrl).execute(variables);
} catch (Exception e) {
throw new JobExecutionException("Error executing script job at " + scriptUrl, e);
} finally {
SiteContext.clear();
}
}
Aggregations