当前位置: 首页>>代码示例>>Java>>正文


Java SimpleTriggerContext类代码示例

本文整理汇总了Java中org.springframework.scheduling.support.SimpleTriggerContext的典型用法代码示例。如果您正苦于以下问题:Java SimpleTriggerContext类的具体用法?Java SimpleTriggerContext怎么用?Java SimpleTriggerContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SimpleTriggerContext类属于org.springframework.scheduling.support包,在下文中一共展示了SimpleTriggerContext类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAllJobs

import org.springframework.scheduling.support.SimpleTriggerContext; //导入依赖的package包/类
@GET
@Path("/all")
@Produces("application/json")
public OscarJobResponse getAllJobs() {
	List<OscarJob> results = oscarJobManager.getAllJobs(getLoggedInInfo());
	
	OscarJobResponse response = new OscarJobResponse();
	for(OscarJob result:results) {
		OscarJobTo1 to = new OscarJobTo1();
		BeanUtils.copyProperties(result, to,new String[]{"oscarJobType"});
		to.setOscarJobType(new OscarJobTypeTo1());
		BeanUtils.copyProperties(result.getOscarJobType(), to.getOscarJobType());
		
		if(result.getCronExpression() != null) {
			CronTrigger trigger = new CronTrigger(result.getCronExpression());
			//ScheduledFuture<Object> future = OscarJobExecutingManager.getFutures().get(result.getId());
			
			if(result.isEnabled()) {
				to.setNextPlannedExecutionDate(trigger.nextExecutionTime(new SimpleTriggerContext()));
			}
			
		}
		response.getJobs().add(to);
	}
	return response;
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:27,代码来源:OscarJobService.java

示例2: shouldBuildTriggers

import org.springframework.scheduling.support.SimpleTriggerContext; //导入依赖的package包/类
@Test
public void shouldBuildTriggers() {
	
	String[] expressions = new String[]{ 
			"fixed-rate:100",
			"fixed-delay:100",
			"fixed-rate:10,fixed-delay:10",
			"0 0 * 14 3 ?",
			"timerange:10:00:00->12:00:00->(fixed-rate:100)"
	};
	
	TriggerBuilder triggerBuilder = new TriggerBuilder();
	for (String expression : expressions) {
		Trigger trigger = triggerBuilder.build(expression);
		TriggerContext triggerContext = new SimpleTriggerContext();
		trigger.nextExecutionTime(triggerContext);
	}
	
}
 
开发者ID:danidemi,项目名称:jlubricant,代码行数:20,代码来源:TriggerBuilderTest.java

示例3: schedule

import org.springframework.scheduling.support.SimpleTriggerContext; //导入依赖的package包/类
public ScheduledFuture<?> schedule(Runnable task, final Trigger trigger) {
	ManagedScheduledExecutorService executor = (ManagedScheduledExecutorService) scheduledExecutor;
	return executor.schedule(task, new javax.enterprise.concurrent.Trigger() {
		@Override
		public Date getNextRunTime(LastExecution le, Date taskScheduledTime) {
			return trigger.nextExecutionTime(le != null ?
					new SimpleTriggerContext(le.getScheduledStart(), le.getRunStart(), le.getRunEnd()) :
					new SimpleTriggerContext());
		}
		@Override
		public boolean skipRun(LastExecution lastExecution, Date scheduledRunTime) {
			return false;
		}
	});
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:ConcurrentTaskScheduler.java

示例4: setNextExecutionTime

import org.springframework.scheduling.support.SimpleTriggerContext; //导入依赖的package包/类
/**
 * Only set next execution time if the job is not continuous.
 */
public void setNextExecutionTime( Date nextExecutionTime )
{
    if ( cronExpression == null || cronExpression.equals( "" ) || cronExpression.equals( "* * * * * ?" ) )
    {
        return;
    }

    if ( nextExecutionTime != null )
        this.nextExecutionTime = nextExecutionTime;
    else
    {
        this.nextExecutionTime = new CronTrigger( cronExpression ).nextExecutionTime( new SimpleTriggerContext() );
    }
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:18,代码来源:JobConfiguration.java

示例5: assertPollerConfiguration

import org.springframework.scheduling.support.SimpleTriggerContext; //导入依赖的package包/类
private void assertPollerConfiguration(PollerMetadata poller,
		long expectedMaxMessages, long expectedFixedDelay) {
	assertThat(poller.getMaxMessagesPerPoll()).isEqualTo(expectedMaxMessages);
	Trigger trigger = poller.getTrigger();
	assertThat(trigger).isInstanceOf(PeriodicTrigger.class);
	TriggerContext triggerContext = new SimpleTriggerContext(LAST_SCHEDULED_DATE,
			LAST_EXECUTED_DATE, LAST_COMPLETED_DATE);
	Date nextExecution = trigger.nextExecutionTime(triggerContext);
	assertThat(nextExecution.getTime())
			.isEqualTo(LAST_COMPLETED_DATE.getTime() + expectedFixedDelay);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-sleuth,代码行数:12,代码来源:SleuthStreamAutoConfigurationTest.java

示例6: cronTaskWithZone

import org.springframework.scheduling.support.SimpleTriggerContext; //导入依赖的package包/类
@Test
public void cronTaskWithZone() throws InterruptedException {
	Assume.group(TestGroup.LONG_RUNNING);

	BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
	BeanDefinition targetDefinition = new RootBeanDefinition(CronWithTimezoneTestBean.class);
	context.registerBeanDefinition("postProcessor", processorDefinition);
	context.registerBeanDefinition("target", targetDefinition);
	context.refresh();

	Object postProcessor = context.getBean("postProcessor");
	Object target = context.getBean("target");
	ScheduledTaskRegistrar registrar = (ScheduledTaskRegistrar)
			new DirectFieldAccessor(postProcessor).getPropertyValue("registrar");
	@SuppressWarnings("unchecked")
	List<CronTask> cronTasks = (List<CronTask>)
			new DirectFieldAccessor(registrar).getPropertyValue("cronTasks");
	assertEquals(1, cronTasks.size());
	CronTask task = cronTasks.get(0);
	ScheduledMethodRunnable runnable = (ScheduledMethodRunnable) task.getRunnable();
	Object targetObject = runnable.getTarget();
	Method targetMethod = runnable.getMethod();
	assertEquals(target, targetObject);
	assertEquals("cron", targetMethod.getName());
	assertEquals("0 0 0-4,6-23 * * ?", task.getExpression());
	Trigger trigger = task.getTrigger();
	assertNotNull(trigger);
	assertTrue(trigger instanceof CronTrigger);
	CronTrigger cronTrigger = (CronTrigger) trigger;
	Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT+10"));
	cal.clear();
	cal.set(2013, 3, 15, 4, 0); // 15-04-2013 4:00 GMT+10
	Date lastScheduledExecutionTime = cal.getTime();
	Date lastActualExecutionTime = cal.getTime();
	cal.add(Calendar.MINUTE, 30); // 4:30
	Date lastCompletionTime = cal.getTime();
	TriggerContext triggerContext = new SimpleTriggerContext(
			lastScheduledExecutionTime, lastActualExecutionTime, lastCompletionTime);
	cal.add(Calendar.MINUTE, 30);
	cal.add(Calendar.HOUR_OF_DAY, 1); // 6:00
	Date nextExecutionTime = cronTrigger.nextExecutionTime(triggerContext);
	assertEquals(cal.getTime(), nextExecutionTime); // assert that 6:00 is next execution time
	Thread.sleep(10000);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:45,代码来源:ScheduledAnnotationBeanPostProcessorTests.java

示例7: shouldRunOnce

import org.springframework.scheduling.support.SimpleTriggerContext; //导入依赖的package包/类
@Test
public void shouldRunOnce() {

	Date testStart = new Date();

	SimpleTriggerContext triggerContext = new SimpleTriggerContext();
	OnceTrigger onceTrigger = new OnceTrigger();

	Date next1 = onceTrigger.nextExecutionTime(triggerContext);

	assertFalse(next1.before(testStart));

	triggerContext.update(next1, next1, next1);

	Date next2 = onceTrigger.nextExecutionTime(triggerContext);

	assertNull(next2);


}
 
开发者ID:danidemi,项目名称:jlubricant,代码行数:21,代码来源:OnceTriggerTest.java

示例8: shouldRunOnceAfter

import org.springframework.scheduling.support.SimpleTriggerContext; //导入依赖的package包/类
@Test
public void shouldRunOnceAfter() {

	Date testStart = new Date();

	SimpleTriggerContext triggerContext = new SimpleTriggerContext();
	OnceTrigger onceTrigger = new OnceTrigger();
	onceTrigger.setAfter(2000);

	Date next1 = onceTrigger.nextExecutionTime(triggerContext);

	assert (next1.getTime() - testStart.getTime() <= 2000);

	triggerContext.update(next1, next1, next1);

	Date next2 = onceTrigger.nextExecutionTime(triggerContext);

	assertNull(next2);

}
 
开发者ID:danidemi,项目名称:jlubricant,代码行数:21,代码来源:OnceTriggerTest.java


注:本文中的org.springframework.scheduling.support.SimpleTriggerContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。