我可以将CDI注入石英调度程序作业吗?

编程入门 行业动态 更新时间:2024-10-11 01:11:37
本文介绍了我可以将CDI注入石英调度程序作业吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用Glassfish和CDI进行注射,(主要是)成功。我似乎无法让Quartz工作与注释bean一起工​​作,注释中注有 @Inject 永远不会被注入。

I'm using Glassfish and CDI for injection, (mostly) successfully. I can't seem to get Quartz jobs to work with injection- beans annotated with @Inject never get injected.

是否Quartz使用某种不同的类加载器来防止注入发生?

Is Quartz using some kind of different classloader that's preventing injection from happening?

我在我的web.xml中配置Quartz:

I'm configuring Quartz like so in my web.xml:

<context-param> <param-name>quartz:config-file</param-name> <param-value>quartz.properties</param-value> </context-param> <context-param> <param-name>quartz:shutdown-on-unload</param-name> <param-value>true</param-value> </context-param> <context-param> <param-name>quartz:wait-on-shutdown</param-name> <param-value>false</param-value> </context-param> <context-param> <param-name>quartz:start-scheduler-on-load</param-name> <param-value>true</param-value> </context-param> <listener> <listener-class> org.quartz.ee.servlet.QuartzInitializerListener </listener-class> </listener>

我的quartz.properties看起来像:

My quartz.properties looks like:

org.quartz.scheduler.instanceName = MyScheduler org.quartz.scheduler.instanceId = 1 org.quartz.scheduler.rmi.export = false org.quartz.scheduler.rmi.proxy = false org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPool org.quartz.threadPool.threadCount = 3 org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore org.quartz.plugin.jobInitializer.class = org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin org.quartz.plugin.jobInitializer.fileNames = quartz-config.xml org.quartz.plugin.jobInitializer.scanInterval = 10 org.quartz.plugin.jobInitializer.wrapInUserTransaction = false org.quartz.plugin.jobInitializer.failOnFileNotFound = true

推荐答案

你需要自己实现org.quartz.spi.JobFactory,它知道如何使用你的应用程序n的CDI实例化作业类并注入它们。

You will need to make your own implementation of org.quartz.spi.JobFactory that knows how to use your application's CDI to instantiate the jobs classes and inject them.

更多推荐

我可以将CDI注入石英调度程序作业吗?

本文发布于:2023-11-25 20:52:08,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:作业   程序   CDI   石英

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!