无法在服务器部署上启动 Quartz

发布于 2024-10-16 08:54:40 字数 283 浏览 4 评论 0原文

我为此苦苦挣扎了一个星期。 使用Jboss5.1.x、EJB3.0、quartz1.8 人们向我推荐文档,但似乎 no1 确实有线索或不理解我。

有没有办法在EJB bean中启动java代码来调度quartz? 我已经了解如何初始化和循环石英调度程序..但是您如何实际调用在应用程序部署时初始化调度程序的方法?

如果你需要JBOSS调度程序首先调用调度Quartz的init方法,那么Quartz对我来说就没用了!我会继续使用 Jboss 调度程序。

有人有解决办法吗?

谢谢, 射线。

I am struggling this for a week.
using Jboss5.1.x, EJB3.0, quartz1.8
people refer me to to documents, but it seems like no1 has really clue or doesn't understand me.

Is there a way of starting the java code in EJB bean to schedule quartz?
I already understood how to init and loop up the quartz scheduler.. but how do you actually call the method which INIT the scheduler on application deployment?

if you need the JBOSS scheduler to first call the init method which schedule Quartz, then Quartz is useless for me! i would just continue with Jboss scheduler.

anyone has any solution for that?

thanks,
ray.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

将军与妓 2024-10-23 08:54:40

我不确定我是否理解你的问题,但是你不能将 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();
    }
}

I'm not sure I understand your question but can't you store the Quartz scheduler factory in a static variable and initialize it in a static initializer or a static method? Something like:

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();
    }
}

是的,但我想要实现的是让我的石英开始部署。但我找到了我正在使用的解决方案

@Service(objectName = "..")
@Management(...)

,并且一旦我的项目部署,该类就会被触发。

Yes, but What I wanted to achive is to have my quartz start on deploy. but I found solution for this I am using

@Service(objectName = "..")
@Management(...)

and that class will be triggerd as soon as my project will deploy.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文