Java 类org.quartz.spi.TriggerFiredBundle 实例源码

项目:lams    文件:SpringBeanJobFactory.java   
/**
 * Create the job instance, populating it with property values taken
 * from the scheduler context, job data map and trigger data map.
 */
@Override
protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
    Object job = super.createJobInstance(bundle);
    BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(job);
    if (isEligibleForPropertyPopulation(bw.getWrappedInstance())) {
        MutablePropertyValues pvs = new MutablePropertyValues();
        if (this.schedulerContext != null) {
            pvs.addPropertyValues(this.schedulerContext);
        }
        pvs.addPropertyValues(getJobDetailDataMap(bundle));
        pvs.addPropertyValues(getTriggerDataMap(bundle));
        if (this.ignoredUnknownProperties != null) {
            for (String propName : this.ignoredUnknownProperties) {
                if (pvs.contains(propName) && !bw.isWritableProperty(propName)) {
                    pvs.removePropertyValue(propName);
                }
            }
            bw.setPropertyValues(pvs);
        }
        else {
            bw.setPropertyValues(pvs, true);
        }
    }
    return job;
}
项目:lams    文件:SimpleJobFactory.java   
public Job newJob(TriggerFiredBundle bundle, Scheduler Scheduler) throws SchedulerException {

        JobDetail jobDetail = bundle.getJobDetail();
        Class<? extends Job> jobClass = jobDetail.getJobClass();
        try {
            if(log.isDebugEnabled()) {
                log.debug(
                    "Producing instance of Job '" + jobDetail.getKey() + 
                    "', class=" + jobClass.getName());
            }

            return jobClass.newInstance();
        } catch (Exception e) {
            SchedulerException se = new SchedulerException(
                    "Problem instantiating class '"
                            + jobDetail.getJobClass().getName() + "'", e);
            throw se;
        }
    }
项目:lams    文件:JobExecutionContextImpl.java   
/**
 * <p>
 * Create a JobExcecutionContext with the given context data.
 * </p>
 */
public JobExecutionContextImpl(Scheduler scheduler,
        TriggerFiredBundle firedBundle, Job job) {
    this.scheduler = scheduler;
    this.trigger = firedBundle.getTrigger();
    this.calendar = firedBundle.getCalendar();
    this.jobDetail = firedBundle.getJobDetail();
    this.job = job;
    this.recovering = firedBundle.isRecovering();
    this.fireTime = firedBundle.getFireTime();
    this.scheduledFireTime = firedBundle.getScheduledFireTime();
    this.prevFireTime = firedBundle.getPrevFireTime();
    this.nextFireTime = firedBundle.getNextFireTime();

    this.jobDataMap = new JobDataMap();
    this.jobDataMap.putAll(jobDetail.getJobDataMap());
    this.jobDataMap.putAll(trigger.getJobDataMap());
}
项目:asura    文件:SimpleJobFactory.java   
public Job newJob(TriggerFiredBundle bundle) throws SchedulerException {

        JobDetail jobDetail = bundle.getJobDetail();
        Class jobClass = jobDetail.getJobClass();
        try {
            if(log.isDebugEnabled()) {
                log.debug(
                    "Producing instance of Job '" + jobDetail.getFullName() + 
                    "', class=" + jobClass.getName());
            }

            return (Job) jobClass.newInstance();
        } catch (Exception e) {
            SchedulerException se = new SchedulerException(
                    "Problem instantiating class '"
                            + jobDetail.getJobClass().getName() + "'", e);
            throw se;
        }
    }
项目:asura    文件:JobExecutionContext.java   
/**
 * <p>
 * Create a JobExcecutionContext with the given context data.
 * </p>
 */
public JobExecutionContext(Scheduler scheduler,
        TriggerFiredBundle firedBundle, Job job) {
    this.scheduler = scheduler;
    this.trigger = firedBundle.getTrigger();
    this.calendar = firedBundle.getCalendar();
    this.jobDetail = firedBundle.getJobDetail();
    this.job = job;
    this.recovering = firedBundle.isRecovering();
    this.fireTime = firedBundle.getFireTime();
    this.scheduledFireTime = firedBundle.getScheduledFireTime();
    this.prevFireTime = firedBundle.getPrevFireTime();
    this.nextFireTime = firedBundle.getNextFireTime();

    this.jobDataMap = new JobDataMap();
    this.jobDataMap.putAll(jobDetail.getJobDataMap());
    this.jobDataMap.putAll(trigger.getJobDataMap());
}
项目:asura    文件:JobStoreSupport.java   
/**
 * <p>
 * Inform the <code>JobStore</code> that the scheduler is now firing the
 * given <code>Trigger</code> (executing its associated <code>Job</code>),
 * that it had previously acquired (reserved).
 * </p>
 * 
 * @return null if the trigger or its job or calendar no longer exist, or
 *         if the trigger was not successfully put into the 'executing'
 *         state.
 */
public TriggerFiredBundle triggerFired(
        final SchedulingContext ctxt, final Trigger trigger) throws JobPersistenceException {
    return 
        (TriggerFiredBundle)executeInNonManagedTXLock(
            LOCK_TRIGGER_ACCESS,
            new TransactionCallback() {
                public Object execute(Connection conn) throws JobPersistenceException {
                    try {
                        return triggerFired(conn, ctxt, trigger);
                    } catch (JobPersistenceException jpe) {
                        // If job didn't exisit, we still want to commit our work and return null.
                        if (jpe.getErrorCode() == SchedulerException.ERR_PERSISTENCE_JOB_DOES_NOT_EXIST) {
                            return null;
                        } else {
                            throw jpe;
                        }
                    }
                }
            });
}
项目:yadaframework    文件:YadaQuartzJobFactory.java   
protected void initJob(TriggerFiredBundle bundle, Object job) {
    // The following code is copied from SpringBeanJobFactory in spring-context-support-4.2.5.RELEASE
    BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(job);
    if (isEligibleForPropertyPopulation(bw.getWrappedInstance())) {
        MutablePropertyValues pvs = new MutablePropertyValues();
        if (schedulerContext != null) {
            pvs.addPropertyValues(this.schedulerContext);
        }
        pvs.addPropertyValues(bundle.getJobDetail().getJobDataMap());
        pvs.addPropertyValues(bundle.getTrigger().getJobDataMap());
        if (this.ignoredUnknownProperties != null) {
            for (String propName : this.ignoredUnknownProperties) {
                if (pvs.contains(propName) && !bw.isWritableProperty(propName)) {
                    pvs.removePropertyValue(propName);
                }
            }
            bw.setPropertyValues(pvs);
        }
        else {
            bw.setPropertyValues(pvs, true);
        }
    }
}
项目:spring4-understanding    文件:SpringBeanJobFactory.java   
/**
 * Create the job instance, populating it with property values taken
 * from the scheduler context, job data map and trigger data map.
 */
@Override
protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
    Object job = super.createJobInstance(bundle);
    BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(job);
    if (isEligibleForPropertyPopulation(bw.getWrappedInstance())) {
        MutablePropertyValues pvs = new MutablePropertyValues();
        if (this.schedulerContext != null) {
            pvs.addPropertyValues(this.schedulerContext);
        }
        pvs.addPropertyValues(bundle.getJobDetail().getJobDataMap());
        pvs.addPropertyValues(bundle.getTrigger().getJobDataMap());
        if (this.ignoredUnknownProperties != null) {
            for (String propName : this.ignoredUnknownProperties) {
                if (pvs.contains(propName) && !bw.isWritableProperty(propName)) {
                    pvs.removePropertyValue(propName);
                }
            }
            bw.setPropertyValues(pvs);
        }
        else {
            bw.setPropertyValues(pvs, true);
        }
    }
    return job;
}
项目:elastic-jobx    文件:SpringJobFactory.java   
@Override
public Job newJob(final TriggerFiredBundle bundle, final Scheduler scheduler) throws SchedulerException {
    Preconditions.checkNotNull(applicationContext, "applicationContext cannot be null, should call setApplicationContext first.");
    Job job = null;
    try {
        for (Job each : applicationContext.getBeansOfType(Job.class).values()) {
            if (AopUtils.getTargetClass(each) == bundle.getJobDetail().getJobClass()) {
                job = each;
                break;
            }
        }
        if (null == job) {
            throw new NoSuchBeanDefinitionException("");
        }
    } catch (final BeansException ex) {
        log.info("Elastic job: cannot found bean for class: '{}'. This job is not managed for spring.", bundle.getJobDetail().getJobClass().getCanonicalName());
        return super.newJob(bundle, scheduler);
    }
    JobDataMap jobDataMap = new JobDataMap();
    jobDataMap.putAll(scheduler.getContext());
    jobDataMap.putAll(bundle.getJobDetail().getJobDataMap());
    jobDataMap.putAll(bundle.getTrigger().getJobDataMap());
    Job target = (Job) AopTargetUtils.getTarget(job);
    setBeanProps(target, jobDataMap);
    return target;
}
项目:step    文件:ExecutionJobFactory.java   
@Override
public Job newJob(TriggerFiredBundle arg0, Scheduler arg1) throws SchedulerException {
    JobDataMap data = arg0.getJobDetail().getJobDataMap();
    ExecutionRunnable task;
    Execution execution;
    if(data.containsKey(Executor.EXECUTION_ID)) {
        String executionID = data.getString(Executor.EXECUTION_ID);
        execution = context.getExecutionAccessor().get(executionID);
    } else {
        String executionTaskID = data.getString(Executor.EXECUTION_TASK_ID);
        ExecutionParameters executionParams = (ExecutionParameters) data.get(Executor.EXECUTION_PARAMETERS);
        execution = executionRunnableFactory.createExecution(executionParams, executionTaskID);         
    }
    task = executionRunnableFactory.newExecutionRunnable(execution);

    ExecutionJob job = new ExecutionJob(task);
    return job;
}
项目:Portofino    文件:PortofinoJobFactory.java   
@Override
public Job newJob(TriggerFiredBundle bundle, Scheduler scheduler) throws SchedulerException {
    final Job job = super.newJob(bundle, scheduler);
    Injections.inject(job, servletContext, null);
    return new Job() {
        @Override
        public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
            job.execute(jobExecutionContext);
            try {
                //In a different class to make the database module optional at runtime
                SessionCleaner.closeSessions(servletContext);
            } catch (NoClassDefFoundError e) {
                logger.debug("Database module not available, not closing sessions", e);
            }
        }
    };
}
项目:class-guard    文件:SpringBeanJobFactory.java   
/**
 * Create the job instance, populating it with property values taken
 * from the scheduler context, job data map and trigger data map.
 */
@Override
protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
    Object job = super.createJobInstance(bundle);
    BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(job);
    if (isEligibleForPropertyPopulation(bw.getWrappedInstance())) {
        MutablePropertyValues pvs = new MutablePropertyValues();
        if (this.schedulerContext != null) {
            pvs.addPropertyValues(this.schedulerContext);
        }
        pvs.addPropertyValues(getJobDetailDataMap(bundle));
        pvs.addPropertyValues(getTriggerDataMap(bundle));
        if (this.ignoredUnknownProperties != null) {
            for (String propName : this.ignoredUnknownProperties) {
                if (pvs.contains(propName) && !bw.isWritableProperty(propName)) {
                    pvs.removePropertyValue(propName);
                }
            }
            bw.setPropertyValues(pvs);
        }
        else {
            bw.setPropertyValues(pvs, true);
        }
    }
    return job;
}
项目:st-toolset    文件:GuiceJobFactory.java   
@Override
public Job newJob(final TriggerFiredBundle triggerFiredBundle, final Scheduler schdlr) throws SchedulerException {
    // Get the job detail so we can get the job class
    final JobDetail jobDetail = triggerFiredBundle.getJobDetail();
    final Class jobClass = jobDetail.getJobClass();

    try {
        // Get a new instance of that class from Guice so we can do dependency injection
        return (Job) injector.getInstance(jobClass);
    } catch (Exception e) {
        // Something went wrong.  Print out the stack trace here so SLF4J doesn't hide it.
        LOGGER.error("Problem with building job.", e);

        // Rethrow the exception as an UnsupportedOperationException
        throw new UnsupportedOperationException(e);
    }
}
项目:syncope    文件:AutowiringSpringBeanJobFactory.java   
@Override
protected Object createJobInstance(final TriggerFiredBundle bundle) throws Exception {
    Object job = beanFactory.getBean(bundle.getJobDetail().getKey().getName());
    if (isEligibleForPropertyPopulation(job)) {
        BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(job);
        MutablePropertyValues pvs = new MutablePropertyValues();
        if (this.schedulerContext != null) {
            pvs.addPropertyValues(this.schedulerContext);
        }
        pvs.addPropertyValues(bundle.getJobDetail().getJobDataMap());
        pvs.addPropertyValues(bundle.getTrigger().getJobDataMap());
        if (this.ignoredUnknownProperties != null) {
            for (String propName : this.ignoredUnknownProperties) {
                if (pvs.contains(propName) && !bw.isWritableProperty(propName)) {
                    pvs.removePropertyValue(propName);
                }
            }
            bw.setPropertyValues(pvs);
        } else {
            bw.setPropertyValues(pvs, true);
        }
    }
    return job;
}
项目:opennmszh    文件:ReportJobFactory.java   
/** {@inheritDoc} */
public Job newJob(TriggerFiredBundle bundle) throws SchedulerException {

    JobDetail jobDetail = bundle.getJobDetail();
    Class<ReportJob> jobClass = getJobClass(jobDetail);

    ReportJob job = null;

    try {
        job = jobClass.newInstance();
        job.setReportd(getReportd());
        return job;
    } catch (Throwable e) {
        SchedulerException se = new SchedulerException("failed to create job class: "+ jobDetail.getJobClass().getName()+"; "+
                                                       e.getLocalizedMessage(), e);
        throw se;
    }
}
项目:opennmszh    文件:ImportJobFactory.java   
/** {@inheritDoc} */
public Job newJob(TriggerFiredBundle bundle) throws SchedulerException {

    JobDetail jobDetail = bundle.getJobDetail();
    Class<ImportJob> jobClass = getJobClass(jobDetail);

    ImportJob job = null;

    try {
        job = jobClass.newInstance();
        job.setProvisioner(getProvisioner());
        return job;
    } catch (Throwable e) {
        SchedulerException se = new SchedulerException("failed to create job class: "+jobDetail.getJobClass().getName()+"; "+
                                                       e.getLocalizedMessage(), e);
        throw se;
    }
}
项目:quartz-couchdb-store    文件:CouchDbStore.java   
@Override
public List<TriggerFiredResult> triggersFired(List<OperableTrigger> triggers) throws JobPersistenceException {
    if (logger.isInfoEnabled()) {
        logger.info("Triggers fired " + triggers.size());
        logger.trace(triggers);
    }

    List<CouchDbTrigger> couchdbTriggers = fetchCouchDbTriggers(triggers);
    Map<String, Calendar> triggerCalendars = fetchCalendars(triggers);
    Map<JobKey, JobDetail> jobDetailMap = fetchJobDetails(triggers);

    List<TriggerFiredResult> firedResults = new ArrayList<TriggerFiredResult>();
    List<CouchDbTrigger> firedTriggers = triggerStore.triggersFired(couchdbTriggers, triggerCalendars);
    for (CouchDbTrigger firedTrigger : firedTriggers) {

        Date prevFireTime = find(couchdbTriggers, firedTrigger.getKey()).getPreviousFireTime();
        Calendar calendar = triggerCalendars.get(firedTrigger.getCalendarName());
        JobDetail job = jobDetailMap.get(firedTrigger.getJobKey());

        TriggerFiredBundle triggerFiredBundle = buildTriggerFiredBundle(firedTrigger, prevFireTime, calendar, job);
        firedResults.add(new TriggerFiredResult(triggerFiredBundle));
    }
    return firedResults;
}
项目:ogpHarvester    文件:AutowiringSpringBeanJobFactory.java   
@Override
protected Object createJobInstance(final TriggerFiredBundle bundle)
        throws Exception {
    if (beanFactory == null) {
        throw new IllegalStateException(
                "beanFactory must be initialized before calling "
                        + "createJobInstance");
    }

    Object job = super.createJobInstance(bundle);
    if (job instanceof IngestJob) {
        IngestJob ingestJob = (IngestJob) job;
        ingestJob.setIngestService(ingestService);
    }

    beanFactory.autowireBean(job);
    job = beanFactory.applyBeanPostProcessorsAfterInitialization(job,
            "ingestJob");
    return job;
}
项目:quartz-glass    文件:GlassJobFactory.java   
private void setTargetObject(Job job, TriggerFiredBundle bundle, boolean forceCreateObject) throws Exception {
    PojoJobMeta pojoJobMeta = getPojoJobMeta(bundle.getJobDetail());
    if (pojoJobMeta == null) return;
    if (pojoJobMeta.getTargetObject() != null && !forceCreateObject) return;

    Object targetObject;
    Class targetClass = pojoJobMeta.getTargetClass();
    try {
        targetObject = beanFactory.getBean(targetClass);
    } catch (NoSuchBeanDefinitionException e) {
        targetObject = targetClass.newInstance();
        beanFactory.autowireBean(targetObject);
    }

    populateJobDataMapTargetObject(bundle, targetObject);
    pojoJobMeta.setTargetObject(targetObject);

    MethodInvokingJobDetailFactoryBean methodInvoker = createMethodInvoker(pojoJobMeta);
    methodInvoker.setTargetObject(targetObject);

    MethodInvokingJob methodInvokingJob = (MethodInvokingJob) job;
    methodInvokingJob.setMethodInvoker(methodInvoker);
}
项目:OpenNMS    文件:ReportJobFactory.java   
/** {@inheritDoc} */
public Job newJob(TriggerFiredBundle bundle) throws SchedulerException {

    JobDetail jobDetail = bundle.getJobDetail();
    Class<ReportJob> jobClass = getJobClass(jobDetail);

    ReportJob job = null;

    try {
        job = jobClass.newInstance();
        job.setReportd(getReportd());
        return job;
    } catch (Throwable e) {
        SchedulerException se = new SchedulerException("failed to create job class: "+ jobDetail.getJobClass().getName()+"; "+
                                                       e.getLocalizedMessage(), e);
        throw se;
    }
}
项目:OpenNMS    文件:ImportJobFactory.java   
/** {@inheritDoc} */
public Job newJob(TriggerFiredBundle bundle) throws SchedulerException {

    JobDetail jobDetail = bundle.getJobDetail();
    Class<ImportJob> jobClass = getJobClass(jobDetail);

    ImportJob job = null;

    try {
        job = jobClass.newInstance();
        job.setProvisioner(getProvisioner());
        return job;
    } catch (Throwable e) {
        SchedulerException se = new SchedulerException("failed to create job class: "+jobDetail.getJobClass().getName()+"; "+
                                                       e.getLocalizedMessage(), e);
        throw se;
    }
}
项目:deltaspike    文件:CdiAwareJobFactory.java   
@Override
public Job newJob(TriggerFiredBundle bundle, Scheduler scheduler) throws SchedulerException
{
    Job result = null;
    try
    {
        Class<? extends Job> jobClass = bundle.getJobDetail().getJobClass();
        result = BeanProvider.getContextualReference(jobClass);
        scheduler.getContext().put(jobClass.getName(), Boolean.TRUE);
    }
    catch (Exception e)
    {
        if (result == null)
        {
            result = defaultFactory.newJob(bundle, scheduler);
        }
    }
    return result;
}
项目:kettle_support_kettle8.0    文件:JobFactoryService.java   
/**
 * 功能描述:创建JOB实例,并注解相关内容等
 * 
 * @param bundle
 *            TriggerFiredBundle
 * @return Object JOB实例
 */
@Override
protected Object createJobInstance(TriggerFiredBundle bundle)
        throws Exception {
    Object instance = super.createJobInstance(bundle);
    context.getAutowireCapableBeanFactory().autowireBean(instance);
    return instance;
}
项目:springboot-shiro-cas-mybatis    文件:CasSpringBeanJobFactory.java   
@Override
protected Object createJobInstance(final TriggerFiredBundle bundle) throws Exception {
    final AutowireCapableBeanFactory beanFactory = applicationContext.getAutowireCapableBeanFactory();
    final Object job = super.createJobInstance(bundle);
    logger.debug("Created job {} for bundle {}", job, bundle);
    beanFactory.autowireBean(job);
    logger.debug("Autowired job per the application context");
    return job;
}
项目:alfresco-repository    文件:AlfrescoJobFactory.java   
@Override
protected Object createJobInstance(TriggerFiredBundle bundle)
      throws Exception {
   Object job = super.createJobInstance(bundle);
   if(job instanceof ApplicationContextAware)
   {
      ((ApplicationContextAware)job).setApplicationContext(context);
   }
   return job;
}
项目:dhus-core    文件:AutowiringJobFactory.java   
@Override
public Job newJob (TriggerFiredBundle bundle, Scheduler scheduler)
   throws SchedulerException
{
   Job job = super.newJob (bundle, scheduler);
   beanFactory.autowireBean (job);
   return job;
}
项目:cas-server-4.2.1    文件:CasSpringBeanJobFactory.java   
@Override
protected Object createJobInstance(final TriggerFiredBundle bundle) throws Exception {
    final AutowireCapableBeanFactory beanFactory = applicationContext.getAutowireCapableBeanFactory();
    final Object job = super.createJobInstance(bundle);
    logger.debug("Created job {} for bundle {}", job, bundle);
    beanFactory.autowireBean(job);
    logger.debug("Autowired job per the application context");
    return job;
}
项目:lams    文件:AdaptableJobFactory.java   
/**
 * Quartz 1.x version of newJob: contains actual implementation code.
 */
@Override
public Job newJob(TriggerFiredBundle bundle) throws SchedulerException {
    try {
        Object jobObject = createJobInstance(bundle);
        return adaptJob(jobObject);
    }
    catch (Exception ex) {
        throw new SchedulerException("Job instantiation failed", ex);
    }
}
项目:lams    文件:AdaptableJobFactory.java   
/**
 * Create an instance of the specified job class.
 * <p>Can be overridden to post-process the job instance.
 * @param bundle the TriggerFiredBundle from which the JobDetail
 * and other info relating to the trigger firing can be obtained
 * @return the job instance
 * @throws Exception if job instantiation failed
 */
protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
    // Reflectively adapting to differences between Quartz 1.x and Quartz 2.0...
    Method getJobDetail = bundle.getClass().getMethod("getJobDetail");
    Object jobDetail = ReflectionUtils.invokeMethod(getJobDetail, bundle);
    Method getJobClass = jobDetail.getClass().getMethod("getJobClass");
    Class<?> jobClass = (Class<?>) ReflectionUtils.invokeMethod(getJobClass, jobDetail);
    return jobClass.newInstance();
}
项目:lams    文件:JTAAnnotationAwareJobRunShellFactory.java   
/**
 * <p>
 * Called by the <class>{@link org.quartz.core.QuartzSchedulerThread}
 * </code> to obtain instances of <code>
 * {@link org.quartz.core.JobRunShell}</code>.
 * </p>
 */
public JobRunShell createJobRunShell(TriggerFiredBundle bundle)
        throws SchedulerException {
    ExecuteInJTATransaction jtaAnnotation = ClassUtils.getAnnotation(bundle.getJobDetail().getJobClass(), ExecuteInJTATransaction.class);
    if(jtaAnnotation == null)
        return new JobRunShell(scheduler, bundle);
    else {
        int timeout = jtaAnnotation.timeout();
        if (timeout >= 0) {
            return new JTAJobRunShell(scheduler, bundle, timeout);
        } else {
            return new JTAJobRunShell(scheduler, bundle);
        }
    }
}
项目:lams    文件:PropertySettingJobFactory.java   
@Override
public Job newJob(TriggerFiredBundle bundle, Scheduler scheduler) throws SchedulerException {

    Job job = super.newJob(bundle, scheduler);

    JobDataMap jobDataMap = new JobDataMap();
    jobDataMap.putAll(scheduler.getContext());
    jobDataMap.putAll(bundle.getJobDetail().getJobDataMap());
    jobDataMap.putAll(bundle.getTrigger().getJobDataMap());

    setBeanProps(job, jobDataMap);

    return job;
}
项目:bird-java    文件:AutowireJobFactory.java   
@Override
protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
    //调用父类的方法
    Object jobInstance = super.createJobInstance(bundle);
    //进行注入
    capableBeanFactory.autowireBean(jobInstance);
    return jobInstance;
}
项目:asura    文件:RAMJobStore.java   
/**
 * <p>
 * Inform the <code>JobStore</code> that the scheduler is now firing the
 * given <code>Trigger</code> (executing its associated <code>Job</code>),
 * that it had previously acquired (reserved).
 * </p>
 */
public TriggerFiredBundle triggerFired(SchedulingContext ctxt,
        Trigger trigger) {

    synchronized (lock) {
        TriggerWrapper tw = (TriggerWrapper) triggersByFQN.get(TriggerWrapper
                .getTriggerNameKey(trigger));
        // was the trigger deleted since being acquired?
        if (tw == null || tw.trigger == null) {
            return null;
        }
        // was the trigger completed, paused, blocked, etc. since being acquired?
        if (tw.state != TriggerWrapper.STATE_ACQUIRED) {
            return null;
        }

        Calendar cal = null;
        if (tw.trigger.getCalendarName() != null) {
            cal = retrieveCalendar(ctxt, tw.trigger.getCalendarName());
            if(cal == null)
                return null;
        }
        Date prevFireTime = trigger.getPreviousFireTime();
        // in case trigger was replaced between acquiring and firering
        timeTriggers.remove(tw);            
        // call triggered on our copy, and the scheduler's copy
        tw.trigger.triggered(cal);
        trigger.triggered(cal);
        //tw.state = TriggerWrapper.STATE_EXECUTING;
        tw.state = TriggerWrapper.STATE_WAITING;

        TriggerFiredBundle bndle = new TriggerFiredBundle(retrieveJob(ctxt,
                trigger.getJobName(), trigger.getJobGroup()), trigger, cal,
                false, new Date(), trigger.getPreviousFireTime(), prevFireTime,
                trigger.getNextFireTime());

        JobDetail job = bndle.getJobDetail();

        if (job.isStateful()) {
            ArrayList trigs = getTriggerWrappersForJob(job.getName(), job
                    .getGroup());
            Iterator itr = trigs.iterator();
            while (itr.hasNext()) {
                TriggerWrapper ttw = (TriggerWrapper) itr.next();
                if(ttw.state == TriggerWrapper.STATE_WAITING) {
                    ttw.state = TriggerWrapper.STATE_BLOCKED;
                }
                if(ttw.state == TriggerWrapper.STATE_PAUSED) {
                    ttw.state = TriggerWrapper.STATE_PAUSED_BLOCKED;
                }
                timeTriggers.remove(ttw);
            }
            blockedJobs.add(JobWrapper.getJobNameKey(job));
        } else if (tw.trigger.getNextFireTime() != null) {
            synchronized (lock) {
                timeTriggers.add(tw);
            }
        }

        return bndle;
    }
}
项目:webside    文件:AutowiringSpringBeanJobFactory.java   
@Override
protected Object createJobInstance(final TriggerFiredBundle bundle)
        throws Exception {
    final Object job = super.createJobInstance(bundle);
    beanFactory.autowireBean(job);
    return job;
}
项目:JuniperBotJ    文件:SpringBeanJobFactory.java   
@Override
protected Object createJobInstance(TriggerFiredBundle bundle)
        throws Exception {
    Object jobInstance = super.createJobInstance(bundle);
    context.getAutowireCapableBeanFactory().autowireBean(jobInstance);
    return jobInstance;
}
项目:taboola-cronyx    文件:DelegatingQuartzJobFactory.java   
@Override
public Job newJob(TriggerFiredBundle bundle, Scheduler scheduler) throws SchedulerException {

    JobDetail jobDetail = bundle.getJobDetail();
    MetricRegistry metricRegistry = autowireCapableBeanFactory.getBean(MetricRegistry.class);
    HistorianDAO historianDAO = autowireCapableBeanFactory.getBean(HistorianDAO.class);
    AfterDAO afterDAO = autowireCapableBeanFactory.getBean(AfterDAO.class);

    try {
        return new TriggerAwareLoggingJob(
                new HistorianJob(
                        new TimedJob(
                                new ErrorHandlingJob(
                                        (Job) autowireCapableBeanFactory.autowire(jobDetail.getJobClass(),
                                                AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR, false)
                                ),
                                metricRegistry
                        ),
                        Clock.systemUTC(),
                        scheduler.getSchedulerName(),
                        scheduler.getSchedulerInstanceId(),
                        historianDAO,
                        afterDAO
                )
        );
    } catch (Exception e) {
        throw new SchedulerException(
                "Problem instantiating class '"
                        + jobDetail.getJobClass().getName() + "'", e);
    }
}
项目:yadaframework    文件:YadaQuartzJobFactory.java   
/**
 * Create the job instance, populating it with property values taken
 * from the scheduler context, job data map and trigger data map.
 */
@Override
protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
    Object job = getFromApplicationContext(bundle);
    if (job==null) {
        return null;
    }
    initJob(bundle, job);
    return job;
}
项目:yadaframework    文件:YadaQuartzJobFactory.java   
protected Object getFromApplicationContext(TriggerFiredBundle bundle) {
    Class jobClass = bundle.getJobDetail().getJobClass();
    Object jobBean = applicationContext.getBean(jobClass);
    if (jobBean==null) {
        log.error("Can't find bean of type '{}' in ApplicationContext", jobClass);
    }
    return jobBean;
}
项目:Mastering-Mesos    文件:AuroraCronJobFactory.java   
@Override
public Job newJob(TriggerFiredBundle bundle, Scheduler scheduler) throws SchedulerException {
  checkState(AuroraCronJob.class.equals(bundle.getJobDetail().getJobClass()),
      "Quartz tried to run a type of job we don't know about: "
          + bundle.getJobDetail().getJobClass());

  return auroraCronJobProvider.get();
}
项目:hsweb-framework    文件:DynamicJobFactory.java   
@Override
public Job newJob(TriggerFiredBundle bundle, Scheduler scheduler) throws SchedulerException {
    Map<String, Object> data = bundle.getJobDetail().getJobDataMap();
    String jobId = (String) data.get(JOB_ID_KEY);
    if (null == jobId || bundle.getJobDetail().getJobClass() != DynamicJob.class) {
        return defaultFactory.newJob(bundle, scheduler);
    }
    return  context -> scheduleJobExecutor.doExecuteJob(jobId, data);
}