在IBM Domino应用程序中使用Quartz Scheduler [英] Use Quartz Scheduler in IBM Domino Application

查看:155
本文介绍了在IBM Domino应用程序中使用Quartz Scheduler的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Quartz的新手,但要了解3个简单的知识,才能使其正常工作. 这些是作业,触发器和调度程序.

I'm very new to Quartz, but know 3 simple things which you have to have in order to make it work. These are jobs, triggers and scheduler.

现在,在我们的Domino应用程序中,我们必须使用它来刷新令牌.

Now, in our domino application we have to use it for refreshing a token.

我为此创建了3个基本类.

I've created 3 basic classes for it.

工作:

public class RefreshEGRZTokenJob implements Job 
{
    public void execute(JobExecutionContext arg0) throws JobExecutionException 
    {
        System.out.println("stub for refreshing a token");  
    }
}

触发器和类似main的东西:

public class RefreshEGRZTokenExecutor
{
    private static String REFRESH_TOKEN_JOB = "refreshTokenJob";

    public static void executeAndScheduleRefreshToken(int timeInSeconds) throws SchedulerException 
    {
        JobDetail job = JobBuilder.newJob(RefreshEGRZTokenJob.class)
        .withIdentity(REFRESH_TOKEN_JOB).build();

        Trigger trigger =  TriggerBuilder
        .newTrigger()
        .withIdentity(REFRESH_TOKEN_JOB)
        .withSchedule(
            SimpleScheduleBuilder.simpleSchedule()
                .withIntervalInSeconds(timeInSeconds).repeatForever())
        .build();

        QuartzScheduler.getInstance().scheduleJob(job, trigger);
    }

    public static void pauseScheduler() throws SchedulerException 
    {
        QuartzScheduler.getInstance().standby();
    }
}

还有调度程序:

public final class QuartzScheduler 
{
    private static Scheduler quartzSchedulerInstance;

    public static Scheduler getInstance() throws SchedulerException 
    {
        if (quartzSchedulerInstance == null) 
        {
            Scheduler scheduler = new StdSchedulerFactory().getScheduler();
            scheduler.start();
            quartzSchedulerInstance = scheduler;
        }
        return quartzSchedulerInstance;
    }
}

我的呼叫来自一个按钮(在生产中,它将在用户授权后立即执行)

The call I make is from a button (in production it'll execute shortly after the user authorized)

 <xp:eventHandler event="onclick" submit="true"
    refreshMode="complete">
    <xp:this.action><![CDATA[#{javascript:      
    ru.lanit.egrz.scheduler.RefreshEGRZTokenExecutor.executeAndScheduleRefreshToken(30);


    }]]>
    </xp:this.action>

 </xp:eventHandler>

好,石英调度程序已初始化,并且已设置作业,但不执行该作业(我知道这一点是因为如果我两次按相同的按钮,这将使我不难发现该作业已存在).

Well, quartz scheduler is initilized and the job is set but doesn't execute the job (I know this because if I press the same button twice, it'll give me an exeption that the job already exists).

我想Domino的JVM不会让调度程序无限期地运行.

I guess Domino's JVM doesn't let the scheduler run indefinitely.

我不使用标准IBM代理的原因很简单-在Code部分中不允许使用Java代码.您必须导入并复制到目前为止的所有内容,或者将其编译为jar并导入.但是,如果您决定更改源代码中的任何内容,则必须重新编译整个jar(使用新的源代码)并重新导入.

The reason why I don't use standard IBM's agent is simple - it doesn't allow to use Java code in Code section. You have to either import and duplicate everything you have so far or to compile it into jar and import. But if you decide to change anything in your sources you'll have to recompile the entire jar (with new source code) and re-import that.

有人集成了Domino JVM和Quartz吗?

Has anybody integrated Domino JVM and Quartz?

如果是,请告诉我最佳做法以及如何使其发挥作用.

If so, please tell me the best practices and how to make it work.

谢谢.

推荐答案

我已经创建了一个插件,您可以在这里找到它: https://github.com/hasselbach/domino-quartz

I have created a plugin, you can find it here: https://github.com/hasselbach/domino-quartz

缺少功能项目和updatesite项目.

The feature project and the updatesite project are missing.

您必须在服务器和DDE中安装插件,然后在XPages应用程序中将其激活.

You have to install the plugin on the server and in the DDE and activate it in your XPages application.

这篇关于在IBM Domino应用程序中使用Quartz Scheduler的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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