All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.intelie.pipes.time.TaskAction Maven / Gradle / Ivy

There is a newer version: 0.25.5
Show newest version
package net.intelie.pipes.time;

import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;

public class TaskAction {
    private final long begin;
    private final long end;
    private final Task task;

    public TaskAction(long begin, long end, Task task) {
        this.begin = begin;
        this.end = end;
        this.task = task;
    }

    public void execute() {
        try {
            task.run(begin, end);
        } catch (Throwable e) {
            LogRecord log = new LogRecord(Level.WARNING, "Uncaught exception at {0}");
            log.setParameters(new Object[]{this});
            log.setThrown(e);
            Logger.getLogger(TaskAction.class.getName()).log(log);
        }
    }

    @Override
    public String toString() {
        return "TaskAction{" +
                "begin=" + begin +
                ", end=" + end +
                ", task=" + task +
                '}';
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy