Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
225 views
in Technique[技术] by (71.8m points)

java - 在IBM Domino应用程序中使用Quartz Scheduler(Use Quartz Scheduler in IBM Domino Application)

I'm very new to Quartz, but know 3 simple things which you have to have in order to make it work.

(我是Quartz的新手,但要了解3个简单的知识,才能使其正常工作。)

These are jobs, triggers and scheduler.

(这些是作业,触发器和调度程序。)

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

(现在,在我们的多米诺骨牌应用程序中,我们必须使用它来刷新令牌。)

I've created 3 basic classes for it.

(我为此创建了3个基本类。)

The job:

(工作:)

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

The trigger and something like main :

(触发器和类似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();
    }
}

And the scheduler:

(和调度程序:)

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).

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

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

(我猜Domino的JVM不会让调度程序无限期地运行。)

The reason why I don't use standard IBM's agent is simple - it doesn't allow to use Java code in Code section.

(我不使用标准IBM代理的原因很简单-它不允许在Code代码Code部分中使用Java代码。)

You have to either import and duplicate everything you have so far or to compile it into jar and import.

(您必须导入并复制到目前为止的所有内容,或者将其编译为jar并导入。)

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.

(但是,如果您决定更改源代码中的任何内容,则必须重新编译整个jar(使用新的源代码)并重新导入。)

Has anybody integrated Domino JVM and Quartz?

(是否有人集成了Domino JVM和Quartz?)

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

(如果是这样,请告诉我最佳做法以及如何使其发挥作用。)

Thanks in advance.

(提前致谢。)

  ask by Rus9Mus9 translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...