• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TaskUtils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java InlineDateField类代码示例发布时间:2022-05-23
下一篇:
Java GetAliasesRequest类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap