我为此苦苦挣扎了一个星期。 使用Jboss5.1.x、EJB3.0、quartz1.8 人们向我推荐文档,但似乎 no1 确实有线索或不理解我。
有没有办法在EJB bean中启动java代码来调度quartz? 我已经了解如何初始化和循环 quartz 调度程序..但是您如何实际调用在应用程序部署时初始化调度程序的方法?
如果你需要JBOSS调度程序首先调用调度Quartz的init方法,那么Quartz对我来说就没用了!我会继续使用 Jboss 调度程序。
谁有解决办法吗?
谢谢, 射线。
最佳答案
我不确定我是否理解你的问题,但是你不能将 Quartz 调度程序工厂存储在静态变量中并在静态初始化程序或静态方法中初始化它吗?像这样的东西:
public static Scheduler sched;
public static void init(ServletContext servletContext) throws SchedulerException {
if (sched == null || !sched.isStarted()) {
String quartzPropertiesLocation = UtilityClass.getYourQuartzConfig();
try {
log.info(new File(quartzPropertiesLocation).getCanonicalPath());
} catch (IOException e) {
e.printStackTrace();
}
SchedulerFactory schedFact = new org.quartz.impl.StdSchedulerFactory(quartzPropertiesLocation);
sched = schedFact.getScheduler();
sched.getContext().put(ServletContext.class.getName(), servletContext);
sched.start();
}
}
关于java - 无法在服务器部署上启动 Quartz,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4931448/