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


Java TaskUtils类代码示例

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


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

示例1: PdpController

import org.springframework.scheduling.support.TaskUtils; //导入依赖的package包/类
@Autowired
public PdpController(@Value("${period.policies.refresh.minutes}") int period,
                     @Value("${policies.cachePolicies}") boolean cachePolicies,
                     @Value("${loa.levels}") String  loaLevelsCommaSeparated,
                     PdpPolicyViolationRepository pdpPolicyViolationRepository,
                     PdpPolicyRepository pdpPolicyRepository,
                     PDPEngineHolder pdpEngineHolder,
                     ServiceRegistry serviceRegistry,
                     MailBox mailBox,
                     PolicyMissingServiceProviderValidator policyMissingServiceProviderValidator) {
    this.cachePolicies = cachePolicies;
    this.loaLevels = Stream.of(loaLevelsCommaSeparated.split(",")).map(String::trim).collect(toList());
    this.pdpEngineHolder = pdpEngineHolder;
    this.playgroundPdpEngine = pdpEngineHolder.newPdpEngine(false, true);
    this.pdpEngine = pdpEngineHolder.newPdpEngine(cachePolicies, false);
    this.pdpPolicyViolationRepository = pdpPolicyViolationRepository;
    this.policyIdpAccessEnforcer = new PolicyIdpAccessEnforcer(serviceRegistry);
    this.pdpPolicyRepository = pdpPolicyRepository;
    this.serviceRegistry = serviceRegistry;
    this.mailBox = mailBox;
    this.policyMissingServiceProviderValidator = policyMissingServiceProviderValidator;

    Executors.newSingleThreadScheduledExecutor().scheduleAtFixedRate(
        TaskUtils.decorateTaskWithErrorHandler(this::refreshPolicies, t -> LOG.error("Exception in refreshPolicies task", t), true),
        period, period, TimeUnit.MINUTES);
}
 
开发者ID:OpenConext,项目名称:OpenConext-pdp,代码行数:27,代码来源:PdpController.java

示例2: schedule

import org.springframework.scheduling.support.TaskUtils; //导入依赖的package包/类
@Override
public ScheduledFuture<?> schedule(Runnable task, Trigger trigger) {
	try {
		if (this.enterpriseConcurrentScheduler) {
			return new EnterpriseConcurrentTriggerScheduler().schedule(decorateTask(task, true), trigger);
		}
		else {
			ErrorHandler errorHandler = (this.errorHandler != null ? this.errorHandler : TaskUtils.getDefaultErrorHandler(true));
			return new ReschedulingRunnable(task, trigger, this.scheduledExecutor, errorHandler).schedule();
		}
	}
	catch (RejectedExecutionException ex) {
		throw new TaskRejectedException("Executor [" + this.scheduledExecutor + "] did not accept task: " + task, ex);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:ConcurrentTaskScheduler.java

示例3: decorateTask

import org.springframework.scheduling.support.TaskUtils; //导入依赖的package包/类
private Runnable decorateTask(Runnable task, boolean isRepeatingTask) {
	Runnable result = TaskUtils.decorateTaskWithErrorHandler(task, this.errorHandler, isRepeatingTask);
	if (this.enterpriseConcurrentScheduler) {
		result = ManagedTaskBuilder.buildManagedTask(result, task.toString());
	}
	return result;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:ConcurrentTaskScheduler.java

示例4: schedule

import org.springframework.scheduling.support.TaskUtils; //导入依赖的package包/类
@Override
public ScheduledFuture<?> schedule(Runnable task, Trigger trigger) {
	ScheduledExecutorService executor = getScheduledExecutor();
	try {
		ErrorHandler errorHandler =
				(this.errorHandler != null ? this.errorHandler : TaskUtils.getDefaultErrorHandler(true));
		return new ReschedulingRunnable(task, trigger, executor, errorHandler).schedule();
	}
	catch (RejectedExecutionException ex) {
		throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:ThreadPoolTaskScheduler.java

示例5: simpleApplicationEventMulticasterWithErrorHandler

import org.springframework.scheduling.support.TaskUtils; //导入依赖的package包/类
@Test
public void simpleApplicationEventMulticasterWithErrorHandler() {
	@SuppressWarnings("unchecked")
	ApplicationListener<ApplicationEvent> listener = mock(ApplicationListener.class);
	ApplicationEvent evt = new ContextClosedEvent(new StaticApplicationContext());

	SimpleApplicationEventMulticaster smc = new SimpleApplicationEventMulticaster();
	smc.setErrorHandler(TaskUtils.LOG_AND_SUPPRESS_ERROR_HANDLER);
	smc.addApplicationListener(listener);

	willThrow(new RuntimeException()).given(listener).onApplicationEvent(evt);
	smc.multicastEvent(evt);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:14,代码来源:ApplicationContextEventTests.java

示例6: schedule

import org.springframework.scheduling.support.TaskUtils; //导入依赖的package包/类
public ScheduledFuture schedule(Runnable task, Trigger trigger) {
	try {
		ErrorHandler errorHandler =
				(this.errorHandler != null ? this.errorHandler : TaskUtils.getDefaultErrorHandler(true));
		return new ReschedulingRunnable(task, trigger, this.scheduledExecutor, errorHandler).schedule();
	}
	catch (RejectedExecutionException ex) {
		throw new TaskRejectedException("Executor [" + this.scheduledExecutor + "] did not accept task: " + task, ex);
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:11,代码来源:ConcurrentTaskScheduler.java

示例7: schedule

import org.springframework.scheduling.support.TaskUtils; //导入依赖的package包/类
public ScheduledFuture schedule(Runnable task, Trigger trigger) {
	ScheduledExecutorService executor = getScheduledExecutor();
	try {
		ErrorHandler errorHandler =
				(this.errorHandler != null ? this.errorHandler : TaskUtils.getDefaultErrorHandler(true));
		return new ReschedulingRunnable(task, trigger, executor, errorHandler).schedule();
	}
	catch (RejectedExecutionException ex) {
		throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:12,代码来源:ThreadPoolTaskScheduler.java

示例8: start

import org.springframework.scheduling.support.TaskUtils; //导入依赖的package包/类
@PostConstruct
public void start() throws Exception {
	Validate.isTrue(period > 0);

	//任何异常不会中断schedule执行, 由Spring TaskUtils的LOG_AND_SUPPRESS_ERROR_HANDLER進行处理
	Runnable task = TaskUtils.decorateTaskWithErrorHandler(this, null, true);

	//创建单线程的SechdulerExecutor,并用guava的ThreadFactoryBuilder设定生成线程的名称
	scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryBuilder().setNameFormat(
			"JdkTimerJob-%1$d").build());

	//scheduleAtFixedRatefixRate() 固定任务两次启动之间的时间间隔.
	//scheduleAtFixedDelay()      固定任务结束后到下一次启动间的时间间隔.
	scheduledExecutorService.scheduleAtFixedRate(task, initialDelay, period, TimeUnit.SECONDS);
}
 
开发者ID:Michaelleolee,项目名称:appengine,代码行数:16,代码来源:JdkTimerJob.java

示例9: errorHandlingTask

import org.springframework.scheduling.support.TaskUtils; //导入依赖的package包/类
private Runnable errorHandlingTask(Runnable task, boolean isRepeatingTask) {
	return TaskUtils.decorateTaskWithErrorHandler(task, this.errorHandler, isRepeatingTask);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:ThreadPoolTaskScheduler.java

示例10: errorHandlingTask

import org.springframework.scheduling.support.TaskUtils; //导入依赖的package包/类
private Runnable errorHandlingTask(Runnable delegate, boolean isRepeatingTask) {
	return TaskUtils.decorateTaskWithErrorHandler(delegate, this.errorHandler, isRepeatingTask);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:TimerManagerTaskScheduler.java

示例11: getRunnableToSchedule

import org.springframework.scheduling.support.TaskUtils; //导入依赖的package包/类
/**
 * Determine the actual Runnable to schedule for the given task.
 * <p>Wraps the task's Runnable in a
 * {@link org.springframework.scheduling.support.DelegatingErrorHandlingRunnable}
 * that will catch and log the Exception. If necessary, it will suppress the
 * Exception according to the
 * {@link #setContinueScheduledExecutionAfterException "continueScheduledExecutionAfterException"}
 * flag.
 * @param task the ScheduledExecutorTask to schedule
 * @return the actual Runnable to schedule (may be a decorator)
 */
protected Runnable getRunnableToSchedule(ScheduledExecutorTask task) {
	return (this.continueScheduledExecutionAfterException ?
			new DelegatingErrorHandlingRunnable(task.getRunnable(), TaskUtils.LOG_AND_SUPPRESS_ERROR_HANDLER) :
			new DelegatingErrorHandlingRunnable(task.getRunnable(), TaskUtils.LOG_AND_PROPAGATE_ERROR_HANDLER));
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:ScheduledExecutorFactoryBean.java


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