Quartz Scheduler和OSGI [英] Quartz scheduler and OSGI

查看:132
本文介绍了Quartz Scheduler和OSGI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个OSGI调度程序包,其中装有Quartz Scheduler Jar. 该捆绑包仅向其他捆绑包公开一个应用程序接口,并且在注册新作业时,将其包装到一个临时作业(实现StatefulJob)中,并使用调度程序进行调度.

I have an OSGI scheduler bundle that has the Quartz Scheduler Jar in it. This bundle exposes just an application interface to other bundles and, when a new job is registered, it is wrapped into a temporaryJob (that implements StatefulJob) and scheduled using the scheduler.

通过这种方式,我不必公开Quartz Scheduler jar(它与osgi不太兼容). 这种方法的问题在于,由于StatefulJob避免并行执行作业,并且我只有一个实际作业(临时作业),因此我所有的真实作业一次都运行一次.

In this way I don't have to expose Quartz Scheduler jar (that it is not so much osgi compliant). The problem with this approach is that, since StatefulJob avoids to execute job in parallel and I have only one actual job (the temporaryJob), all my real jobs run one at a time.

不幸的是,标记器界面似乎是唯一可以说明该作业是有​​状态作业的方法. 我唯一能找到的解决方案是使守护程序暴露StatefulJobInterface(除去伪造的工作),但是这样做,我遇到了很多类路径问题. 有没有更简单的解决方案?

Unfortunately it seems that the marker interface is the only way to say that the job is a stateful one. The only solution I could find is to make the daemon exposing the StatefulJobInterface (removing the fake job), but doing so, I am having a lot of classpath problems. Is there a simpler solution to this?

推荐答案

使用真正的Quartz OSGi捆绑包,例如此处提供的捆绑包:

Use a real Quartz OSGi bundle, such as the one available here:

http://ebr.springsource. com/repository/app/bundle/detail?name = com.springsource.org.quartz

那里提供的最新Quartz版本是1.6.2.如果您需要更新的版本,使用 bnd bundlor .

The latest Quartz version available there is 1.6.2. If you need a newer version, building your own bundle is pretty easy with bnd or bundlor.

然后,您可以在OSGi环境中的任何位置公开StatefulJob作为服务,并让您的调度程序包在Quartz中注册和注销这些作业.更好的是,让调度程序捆绑包监听触发器和作业信息周围的所有包装服务,例如Spring

Then you can expose StatefulJob as a service anywhere in your OSGi environment, and have your scheduler bundle register and deregister those jobs with Quartz. Even better, have the scheduler bundle listen for any services that are wrappers around your trigger and job information, such as the Spring CronTriggerBean or SimpleTriggerBean. This way,

1)您的内部API/OSGi服务不是特定于Quartz的-仅调度包对Quartz包具有依赖性,并且

1) your internal API / OSGi services are not Quartz specific -- only the scheduling bundle has a dependency on the Quartz bundle, and

2)您的应用程序捆绑包可以确定作业的时间表,而不是尝试找出该时间表的时间表包.

2) your application bundles can determine the job's schedule instead of the scheduling bundle trying to figure that out.

更新:可从ServiceMix项目中获得更新的Quartz OSGi软件包:

Update: Newer Quartz OSGi bundles are available from the ServiceMix project: http://repo1.maven.org/maven2/org/apache/servicemix/bundles/org.apache.servicemix.bundles.quartz/

这篇关于Quartz Scheduler和OSGI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆