本文整理了Java中org.quartz.Job.execute()
方法的一些代码示例,展示了Job.execute()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Job.execute()
方法的具体详情如下:
包路径:org.quartz.Job
类名称:Job
方法名:execute
[英]Called by the Scheduler
when a Trigger
fires that is associated with the Job
.
The implementation may wish to set a JobExecutionContext#setResult(Object) object on the JobExecutionContext before this method exits. The result itself is meaningless to Quartz, but may be informative to JobListeners
or TriggerListeners
that are watching the job's execution.
[中]当与Job
关联的Trigger
激发时,由Scheduler
调用。
在该方法退出之前,实现可能希望在JobExecutionContext上设置JobExecutionContext#setResult(对象)对象。结果本身对Quartz没有意义,但可能对正在监视作业执行的JobListeners
或TriggerListeners
有帮助。
代码示例来源:origin: ltsopensource/light-task-scheduler
@Override
public void execute(QuartzJobContext quartzJobContext, Job job) throws Throwable {
JobDataMap jobDataMap = JobDataMapSupport.newJobDataMap(quartzJobContext.getJobDataMap());
// 用lts的覆盖
Map<String, String> map = job.getExtParams();
if (CollectionUtils.isNotEmpty(map)) {
for (Map.Entry<String, String> entry : map.entrySet()) {
jobDataMap.put(entry.getKey(), entry.getValue());
}
}
JobExecutionContext jobExecutionContext = new JobExecutionContextImpl(jobDataMap);
quartzJob.execute(jobExecutionContext);
}
}
代码示例来源:origin: ltsopensource/light-task-scheduler
@Override
public void execute(QuartzJobContext quartzJobContext, Job job) throws Throwable {
JobDataMap jobDataMap = JobDataMapSupport.newJobDataMap(quartzJobContext.getJobDataMap());
// 用lts的覆盖
Map<String, String> map = job.getExtParams();
if (CollectionUtils.isNotEmpty(map)) {
for (Map.Entry<String, String> entry : map.entrySet()) {
jobDataMap.put(entry.getKey(), entry.getValue());
}
}
JobExecutionContext jobExecutionContext = new JobExecutionContextImpl(jobDataMap);
quartzJob.execute(jobExecutionContext);
}
}
代码示例来源:origin: quartz-scheduler/quartz
job.execute(jec);
endTime = System.currentTimeMillis();
} catch (JobExecutionException jee) {
代码示例来源:origin: quartz-scheduler/quartz
job.execute(jec);
endTime = System.currentTimeMillis();
} catch (JobExecutionException jee) {
代码示例来源:origin: fang-yan-peng/cronner
public void executeJob() throws JobExecutionException {
if(job != null){
job.execute(null);
}
}
代码示例来源:origin: fang-yan-peng/cronner
@Override
public void run() {
try {
job.execute(null);
} catch (JobExecutionException e) {
log.error("Trigger job with dependency fail: ",e);
}
}
});
代码示例来源:origin: com.manydesigns/portofino-quartz
@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);
}
}
};
代码示例来源:origin: sakaiproject/sakai
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
String beanId = jobExecutionContext.getJobDetail().getJobDataMap().getString(SPRING_BEAN_NAME);
Job job = (Job) ComponentManager.get(beanId);
if (job instanceof StatefulJob) {
log.warn("Non-stateful wrapper used with stateful job: "+ beanId+
" You probably wanted to use SpringStatefulJobBeanWrapper for this job.");
}
job.execute(jobExecutionContext);
}
代码示例来源:origin: sakaiproject/sakai
public void execute(JobExecutionContext jobExecutionContext) throws
JobExecutionException {
String beanId =
jobExecutionContext.getJobDetail().getJobDataMap().getString(SPRING_BEAN_NAME);
Job job = (Job) ComponentManager.get(beanId);
job.execute(jobExecutionContext);
}
}
代码示例来源:origin: com.atlassian.scheduler/atlassian-scheduler-quartz1
@Override
public void execute(final JobExecutionContext context) throws JobExecutionException {
service.preJob();
final Thread thd = Thread.currentThread();
final ClassLoader originalClassLoader = thd.getContextClassLoader();
try {
thd.setContextClassLoader(delegate.getClass().getClassLoader());
delegate.execute(context);
} finally {
thd.setContextClassLoader(originalClassLoader);
service.postJob();
}
}
}
代码示例来源:origin: org.sakaiproject.scheduler/scheduler-component-shared
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
String beanId = jobExecutionContext.getJobDetail().getJobDataMap().getString(SPRING_BEAN_NAME);
Job job = (Job) ComponentManager.get(beanId);
if (job instanceof StatefulJob) {
log.warn("Non-stateful wrapper used with stateful job: "+ beanId+
" You probably wanted to use SpringStatefulJobBeanWrapper for this job.");
}
job.execute(jobExecutionContext);
}
代码示例来源:origin: org.sakaiproject.scheduler/scheduler-component-shared
public void execute(JobExecutionContext jobExecutionContext) throws
JobExecutionException {
String beanId =
jobExecutionContext.getJobDetail().getJobDataMap().getString(SPRING_BEAN_NAME);
Job job = (Job) ComponentManager.get(beanId);
job.execute(jobExecutionContext);
}
}
代码示例来源:origin: ManyDesigns/Portofino
@Override
public Job newJob(TriggerFiredBundle bundle, Scheduler scheduler) throws SchedulerException {
final Job job = super.newJob(bundle, scheduler);
applicationContext.getAutowireCapableBeanFactory().autowireBean(job);
return jobExecutionContext -> {
job.execute(jobExecutionContext);
try {
//In a different class to make the database module optional at runtime
SessionCleaner.closeSessions(applicationContext);
} catch (NoClassDefFoundError e) {
logger.debug("Database module not available, not closing sessions", e);
}
};
}
代码示例来源:origin: org.apache.geronimo.ext.openejb/openejb-core
public void execute(JobExecutionContext execution) throws JobExecutionException {
JobDataMap jobDataMap = execution.getJobDetail().getJobDataMap();
Data data = Data.class.cast(jobDataMap.get(Data.class.getName()));
Job job = data.job;
MessageEndpoint endpoint = (MessageEndpoint) job;
try {
Method method = Job.class.getMethod("execute", JobExecutionContext.class);
endpoint.beforeDelivery(method);
job.execute(execution);
} catch (NoSuchMethodException e) {
throw new IllegalStateException(e);
} catch (ResourceException e) {
throw new JobExecutionException(e);
} finally {
try {
endpoint.afterDelivery();
} catch (ResourceException e) {
throw new JobExecutionException(e);
}
}
}
}
代码示例来源:origin: com.github.ltsopensource/lts-spring
@Override
public void execute(QuartzJobContext quartzJobContext, Job job) throws Throwable {
JobDataMap jobDataMap = JobDataMapSupport.newJobDataMap(quartzJobContext.getJobDataMap());
// 用lts的覆盖
Map<String, String> map = job.getExtParams();
if (CollectionUtils.isNotEmpty(map)) {
for (Map.Entry<String, String> entry : map.entrySet()) {
jobDataMap.put(entry.getKey(), entry.getValue());
}
}
JobExecutionContext jobExecutionContext = new JobExecutionContextImpl(jobDataMap);
quartzJob.execute(jobExecutionContext);
}
}
代码示例来源:origin: org.jboss.jbossas/jboss-as-connector
job.execute(jobExecutionContext);
代码示例来源:origin: org.onehippo.cms7/hippo-repository-engine
@Override
public void executeJob(final String jobIdentifier) throws RepositoryException {
try {
final RepositoryJobDetail jobDetail = (RepositoryJobDetail) scheduler.getJobDetail(new JobKey(jobIdentifier));
final Job job = jobDetail.getJobClass().newInstance();
job.execute(new JobExecutionContextImpl(scheduler, jobDetail));
} catch (SchedulerException | InstantiationException | IllegalAccessException e) {
throw new RepositoryException(e);
}
}
代码示例来源:origin: org.mule.transports/mule-transport-quartz
((Job)tempJob).execute(jobExecutionContext);
代码示例来源:origin: pentaho/pentaho-platform
@Test
public void testJobIsRunWhenThereIsAnExceptionRetrievingTheBlockoutManager() throws JobExecutionException {
BlockingQuartzJob blockingJob = createTestBlockingJob( true );
mockery.checking( new Expectations() {
{
oneOf( context ).getJobDetail();
will( returnValue( new JobDetail( "somejob", BlockingQuartzJob.class ) ) );
oneOf( context ).getJobDetail();
will( returnValue( new JobDetail( "somejob", BlockingQuartzJob.class ) ) );
one( underlyingJob ).execute( with( same( context ) ) );
one( context ).getJobDetail();
will( returnValue( new JobDetail( "somejob", BlockingQuartzJob.class ) ) );
one( logger )
.warn(
"Got Exception retrieving the Blockout Manager for job 'somejob'."
+ " Executing the underlying job anyway", schedulerException );
}
} );
blockingJob.execute( context );
}
代码示例来源:origin: pentaho/pentaho-platform
@Test
public void testJobIsRunWhenNoBlockout() throws JobExecutionException {
BlockingQuartzJob blockingJob = createTestBlockingJob( false );
try {
mockery.checking( new Expectations() {
{
oneOf( context ).getJobDetail();
will( returnValue( new JobDetail( "somejob", BlockingQuartzJob.class ) ) );
oneOf( context ).getJobDetail();
will( returnValue( new JobDetail( "somejob", BlockingQuartzJob.class ) ) );
one( blockoutManager ).shouldFireNow();
will( returnValue( true ) );
one( underlyingJob ).execute( with( same( context ) ) );
}
} );
} catch ( SchedulerException e ) {
throw new RuntimeException( e );
}
blockingJob.execute( context );
}
内容来源于网络,如有侵权,请联系作者删除!