Package org.quartz

Examples of org.quartz.SchedulerContext


    public void execute(JobExecutionContext context) throws JobExecutionException {
       
        Log log = LogFactory.getLog(getClass());
       
        JobDataMap data = context.getJobDetail().getJobDataMap();
        SchedulerContext schedCtxt = null;
        try {
            schedCtxt = context.getScheduler().getContext();
        } catch (SchedulerException e) {
            throw new JobExecutionException("Error obtaining scheduler context.", e, false);
        }
       
        String fileName = data.getString(FILE_NAME);
        String listenerName = data.getString(FILE_SCAN_LISTENER_NAME);
       
        if(fileName == null)
            throw new JobExecutionException("Required parameter '" +
                    FILE_NAME + "' not found in JobDataMap");
        if(listenerName == null)
            throw new JobExecutionException("Required parameter '" +
                    FILE_SCAN_LISTENER_NAME + "' not found in JobDataMap");

        FileScanListener listener = (FileScanListener)schedCtxt.get(listenerName);
       
        if(listener == null)
            throw new JobExecutionException("FileScanListener named '" +
                    listenerName + "' not found in SchedulerContext");
       
View Full Code Here


    private void createAndInitScheduler() throws SchedulerException {
        LOG.info("Create and initializing scheduler.");
        scheduler = createScheduler();

        // Store CamelContext into QuartzContext space
        SchedulerContext quartzContext = scheduler.getContext();
        String camelContextName = getCamelContext().getManagementName();
        LOG.debug("Storing camelContextName={} into Quartz Context space.", camelContextName);
        quartzContext.put(QuartzConstants.QUARTZ_CAMEL_CONTEXT + "-" + camelContextName, getCamelContext());

        // Set camel job counts to zero. We needed this to prevent shutdown in case there are multiple Camel contexts
        // that has not completed yet, and the last one with job counts to zero will eventually shutdown.
        AtomicInteger number = (AtomicInteger) quartzContext.get(QuartzConstants.QUARTZ_CAMEL_JOBS_COUNT);
        if (number == null) {
            number = new AtomicInteger(0);
            quartzContext.put(QuartzConstants.QUARTZ_CAMEL_JOBS_COUNT, number);
        }
    }
View Full Code Here

    public void execute(JobExecutionContext context) throws JobExecutionException {
        String camelContextName = (String) context.getJobDetail().getJobDataMap().get(QuartzConstants.QUARTZ_CAMEL_CONTEXT_NAME);
        String endpointUri = (String) context.getJobDetail().getJobDataMap().get(QuartzConstants.QUARTZ_ENDPOINT_URI);

        SchedulerContext schedulerContext;
        try {
            schedulerContext = context.getScheduler().getContext();
        } catch (SchedulerException e) {
            throw new JobExecutionException("Failed to obtain scheduler context for job " + context.getJobDetail().getName());
        }

        CamelContext camelContext = (CamelContext) schedulerContext.get(QuartzConstants.QUARTZ_CAMEL_CONTEXT + "-" + camelContextName);
        if (camelContext == null) {
            throw new JobExecutionException("No CamelContext could be found with name: " + camelContextName);
        }
        QuartzEndpoint endpoint = camelContext.getEndpoint(endpointUri, QuartzEndpoint.class);
        if (endpoint == null) {
View Full Code Here

    /* (non-Javadoc)
     * @see org.quartz.Job#execute(org.quartz.JobExecutionContext)
     */
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {

        SchedulerContext schedulerContext;
        try {
            schedulerContext = jobExecutionContext.getScheduler().getContext();
        } catch (SchedulerException e) {
            throw new JobExecutionException("Failed to obtain scheduler context for job " + jobExecutionContext.getJobDetail().getName());
        }
       
        Action storedAction = (Action) schedulerContext.get(SCHEDULED_ACTION);
        storedRoute = (Route) schedulerContext.get(SCHEDULED_ROUTE);
       
        ScheduledRoutePolicy policy = (ScheduledRoutePolicy) storedRoute.getRouteContext().getRoutePolicy();
        try {
            policy.onJobExecute(storedAction, storedRoute);
        } catch (Exception e) {
View Full Code Here

    /**
     * @see org.quartz.Job#execute(org.quartz.JobExecutionContext)
     */
    public void execute(JobExecutionContext context) throws JobExecutionException {
        JobDataMap mergedJobDataMap = context.getMergedJobDataMap();
        SchedulerContext schedCtxt = null;
        try {
            schedCtxt = context.getScheduler().getContext();
        } catch (SchedulerException e) {
            throw new JobExecutionException("Error obtaining scheduler context.", e, false);
        }
       
        String fileName = mergedJobDataMap.getString(FILE_NAME);
        String listenerName = mergedJobDataMap.getString(FILE_SCAN_LISTENER_NAME);
       
        if(fileName == null) {
            throw new JobExecutionException("Required parameter '" +
                    FILE_NAME + "' not found in merged JobDataMap");
        }
        if(listenerName == null) {
            throw new JobExecutionException("Required parameter '" +
                    FILE_SCAN_LISTENER_NAME + "' not found in merged JobDataMap");
        }

        FileScanListener listener = (FileScanListener)schedCtxt.get(listenerName);
       
        if(listener == null) {
            throw new JobExecutionException("FileScanListener named '" +
                    listenerName + "' not found in SchedulerContext");
        }
View Full Code Here

    /**
     * @see org.quartz.Job#execute(org.quartz.JobExecutionContext)
     */
    public void execute(JobExecutionContext context) throws JobExecutionException {
        JobDataMap mergedJobDataMap = context.getMergedJobDataMap();
        SchedulerContext schedCtxt = null;
        try {
            schedCtxt = context.getScheduler().getContext();
        } catch (SchedulerException e) {
            throw new JobExecutionException("Error obtaining scheduler context.", e, false);
        }
       
        String fileName = mergedJobDataMap.getString(FILE_NAME);
        String listenerName = mergedJobDataMap.getString(FILE_SCAN_LISTENER_NAME);
       
        if(fileName == null) {
            throw new JobExecutionException("Required parameter '" +
                    FILE_NAME + "' not found in merged JobDataMap");
        }
        if(listenerName == null) {
            throw new JobExecutionException("Required parameter '" +
                    FILE_SCAN_LISTENER_NAME + "' not found in merged JobDataMap");
        }

        FileScanListener listener = (FileScanListener)schedCtxt.get(listenerName);
       
        if(listener == null) {
            throw new JobExecutionException("FileScanListener named '" +
                    listenerName + "' not found in SchedulerContext");
        }
View Full Code Here

TOP

Related Classes of org.quartz.SchedulerContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.