fr.mael.microrss.service.impl.ParseTrigger.java Source code

Java tutorial

Introduction

Here is the source code for fr.mael.microrss.service.impl.ParseTrigger.java

Source

/*
   Copyright  2013 Mael Le Guvel
   This work is free. You can redistribute it and/or modify it under the
   terms of the Do What The Fuck You Want To Public License, Version 2,
   as published by Sam Hocevar. See the COPYING file for more details.
*/
package fr.mael.microrss.service.impl;

import java.util.Date;

import org.springframework.scheduling.Trigger;
import org.springframework.scheduling.TriggerContext;
import org.springframework.stereotype.Component;

@Component
public class ParseTrigger implements Trigger {

    public static final int EXECUTION_INTERVAL = 1 * 60 * 1000;

    @Override
    public Date nextExecutionTime(TriggerContext triggerContext) {
        Date lastDate = triggerContext.lastCompletionTime();
        if (lastDate == null) {
            lastDate = new Date();
        }
        Date newDate = new Date();
        newDate.setTime(lastDate.getTime() + EXECUTION_INTERVAL);
        return newDate;
    }

}