gpt4 book ai didi

java - Guice + Quartz + iBatis

转载 作者:行者123 更新时间:2023-11-30 05:13:17 25 4
gpt4 key购买 nike

我正在尝试将 Guice (Java)、Quartz 调度程序和 iBatis ( iBaGuice ) 连接在一起以执行以下操作:

  1. 使用 main() 启动命令行实用程序扫描仪
  2. 定期扫描目录(作为参数提供)以查找包含格式化输出(XML 或 YAML)的文件
  3. 当检测到文件时,解析并输出结果到数据库

问题:

  1. 我用过this example连接 Guice 和 Quartz。然而,我遗漏了一些我在评论中询问的重要细节,但这篇文章有些过时了,所以我也在这里引用它:
  1. It's not obvious how to set-up the scheduler. Where and how would I wire the Trigger (I can use Trigger#makeMinutelyTrigger)?
  2. I really have just one type of job I will be executing, I understand that details in the JobFactory#newJob are coming from the TriggerFiredBundle parameter but where/how do I wire that? And where/how do I create or wire concrete Job?

附注通过创建和连接 ScheduleProvider,我得到了进一步的了解。现在我对如何在下面的代码片段中实际安排作业感到困惑。看来我的 JobFactory#newJob 方法从未被调用

public class CollectorServiceImpl implements CollectorService {
Scheduler scheduler;

/**
* @throws SchedulerException
*/
@Inject
public CollectorServiceImpl(final SchedulerFactory factory, final GuiceJobFactory jobFactory)
throws SchedulerException {
scheduler = factory.getScheduler();
scheduler.setJobFactory(jobFactory);
}

/**
* @throws SchedulerException
* @see teradata.quantum.reporting.collector.service.CollectorService#start()
*/
@Override
public void start() throws SchedulerException {
Trigger trigger = TriggerUtils.makeMinutelyTrigger("MIN_TRIGGER");
scheduler.scheduleJob(trigger); // this fails trigger validation since no job name is provided
scheduler.start();
}

}

最佳答案

您问题的核心是,您实际上并没有安排工作类(class):

getScheduler().scheduleJob(new JobDetail("myFooJob", null, FooJob.class),
TriggerUtils.makeMinutelyTrigger("MIN_TRIGGER"));

http://www.codesmell.org/blog/2009/01/quartz-fits/ 上的完整答案和演示代码

关于java - Guice + Quartz + iBatis,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2587437/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com