Search in sources :

Example 26 with JobDataMap

use of org.quartz.JobDataMap in project searchcode-server by boyter.

the class IndexGitHistoryJob method execute.

public void execute(JobExecutionContext context) throws JobExecutionException {
    if (!Singleton.getSharedService().getBackgroundJobsEnabled()) {
        return;
    }
    Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
    JobDataMap data = context.getJobDetail().getJobDataMap();
    String repoLocations = data.get("REPOLOCATIONS").toString();
// Get all the current change sets for the project
// loop through each and get the changes and index
}
Also used : JobDataMap(org.quartz.JobDataMap)

Example 27 with JobDataMap

use of org.quartz.JobDataMap 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();
    }
}
Also used : JobDataMap(org.quartz.JobDataMap) JobExecutionException(org.quartz.JobExecutionException) HashMap(java.util.HashMap) SiteContext(org.craftercms.engine.service.context.SiteContext) ServletContext(javax.servlet.ServletContext) ScriptFactory(org.craftercms.engine.scripting.ScriptFactory) JobExecutionException(org.quartz.JobExecutionException)

Example 28 with JobDataMap

use of org.quartz.JobDataMap in project engine by craftercms.

the class SchedulingUtils method createScriptJob.

public static JobDetail createScriptJob(SiteContext siteContext, String jobName, String scriptUrl, ServletContext servletContext) {
    JobDataMap dataMap = new JobDataMap();
    dataMap.put(SITE_CONTEXT_DATA_KEY, siteContext);
    dataMap.put(SCRIPT_URL_DATA_KEY, scriptUrl);
    dataMap.put(SERVLET_CONTEXT_DATA_KEY, servletContext);
    JobDetail job = newJob(ScriptJob.class).withIdentity(jobName).setJobData(dataMap).build();
    return job;
}
Also used : JobDataMap(org.quartz.JobDataMap) JobDetail(org.quartz.JobDetail) ScriptJob(org.craftercms.engine.scripting.impl.ScriptJob)

Example 29 with JobDataMap

use of org.quartz.JobDataMap in project ddf by codice.

the class CommandJob method checkInput.

private String checkInput(JobExecutionContext context) throws CommandException {
    String command = null;
    if (context == null) {
        LOGGER.debug("No JobExecutionContext found. Could not fire {}", CommandJob.class.getSimpleName());
        throw new CommandException();
    }
    JobDataMap mergedJobDataMap = context.getMergedJobDataMap();
    if (mergedJobDataMap == null) {
        LOGGER.debug("No input found. Could not fire {}", CommandJob.class.getSimpleName());
        throw new CommandException();
    }
    if (mergedJobDataMap.getString(COMMAND_KEY) != null) {
        command = mergedJobDataMap.getString(COMMAND_KEY);
    }
    return command;
}
Also used : JobDataMap(org.quartz.JobDataMap)

Example 30 with JobDataMap

use of org.quartz.JobDataMap in project jmxtrans by jmxtrans.

the class ServerJob method execute.

@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
    JobDataMap map = context.getMergedJobDataMap();
    Server server = (Server) map.get(Server.class.getName());
    log.debug("+++++ Started server job: {}", server);
    try {
        jmxUtils.processServer(server);
    } catch (Exception e) {
        throw new JobExecutionException(e);
    }
    log.debug("+++++ Finished server job: {}", server);
}
Also used : JobDataMap(org.quartz.JobDataMap) JobExecutionException(org.quartz.JobExecutionException) Server(com.googlecode.jmxtrans.model.Server) JobExecutionException(org.quartz.JobExecutionException)

Aggregations

JobDataMap (org.quartz.JobDataMap)56 Trigger (org.quartz.Trigger)21 SchedulerException (org.quartz.SchedulerException)20 JobDetail (org.quartz.JobDetail)18 TriggerBuilder.newTrigger (org.quartz.TriggerBuilder.newTrigger)11 Scheduler (org.quartz.Scheduler)10 JobExecutionException (org.quartz.JobExecutionException)9 ApplicationContext (org.springframework.context.ApplicationContext)9 ArrayList (java.util.ArrayList)6 Date (java.util.Date)6 HashMap (java.util.HashMap)6 TriggerBean (org.akaza.openclinica.bean.admin.TriggerBean)6 Command (org.openhab.core.types.Command)5 SchedulerContext (org.quartz.SchedulerContext)5 SimpleTrigger (org.quartz.SimpleTrigger)5 IOException (java.io.IOException)4 InetSocketAddress (java.net.InetSocketAddress)4 SocketChannel (java.nio.channels.SocketChannel)4 Locale (java.util.Locale)4 DatasetBean (org.akaza.openclinica.bean.extract.DatasetBean)4