// Path: core/src/main/java/org/n52/supervisor/api/CheckRunner.java
// public interface CheckRunner {
// 
// 	final IdentifierGenerator ID_GENERATOR = new ShortAlphanumericIdentifierGenerator();
// 
//     public void addResult(CheckResult r);
// 
//     public boolean check();
// 
//     public Check getCheck();
// 
//     public Collection<CheckResult> getResults();
//     
//     public Collection<CheckResult> getAndClearResults();
// 
//     public void notifyFailure();
// 
//     public void notifySuccess();
// 
//     public void setCheck(Check check) throws UnsupportedCheckException;
// 
//     /**
//      * @param rd
//      *        is required so that the runner can announce its results
//      */
//     public void setResultDatabase(ResultDatabase rd);
// 
// }
// 
// Path: core/src/main/java/org/n52/supervisor/api/CheckTask.java
// public interface CheckTask {
// 
//     public Collection<CheckResult> checkIt(CheckRunner c);
// 
// }
// 
// Path: core/src/main/java/org/n52/supervisor/api/CheckTaskFactory.java
// public interface CheckTaskFactory {
// 
//     CheckTask create(CheckRunner checker);
// 
// }


import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.Properties;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import org.n52.supervisor.api.CheckRunner;
import org.n52.supervisor.api.CheckTask;
import org.n52.supervisor.api.CheckTaskFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

        boolean sendEmails = Boolean.parseBoolean(props.getProperty(SEND_EMAILS));

        if (sendEmails) {
        	/*
        	 * disabled for the moment, does not work as expected
        	 */
            // add task for email notifications, with out without admin email
//            String adminEmail = this.props.getProperty(EMAIL_ADMIN_EMAIL);
//
//            long emailSendInterval = Long.valueOf(this.props.getProperty(EMAIL_SEND_PERIOD_MINDS));
//            if ( !adminEmail.contains("@ADMIN_EMAIL@")) {
//                log.info("Found admin email address for send email task.");
//                SendEmailTask set = new SendEmailTask(adminEmail, this.rd);
//                submit(EMAIL_SENDER_TASK_ID, set, emailSendInterval, emailSendInterval);
//            }
        }
        else
            log.debug("Not sending emails, not starting email tasks.");

        log.info(" ***** Timer initiated successfully! ***** ");
    }

    private Properties loadProperties(InputStream is) throws IOException {
        Properties properties = new Properties();
        properties.load(is);

        return properties;
    }

// Path: core/src/main/java/org/n52/supervisor/api/CheckRunner.java
// public interface CheckRunner {
// 
// 	final IdentifierGenerator ID_GENERATOR = new ShortAlphanumericIdentifierGenerator();
// 
//     public void addResult(CheckResult r);
// 
//     public boolean check();
// 
//     public Check getCheck();
// 
//     public Collection<CheckResult> getResults();
//     
//     public Collection<CheckResult> getAndClearResults();
// 
//     public void notifyFailure();
// 
//     public void notifySuccess();
// 
//     public void setCheck(Check check) throws UnsupportedCheckException;
// 
//     /**
//      * @param rd
//      *        is required so that the runner can announce its results
//      */
//     public void setResultDatabase(ResultDatabase rd);
// 
// }
// 
// Path: core/src/main/java/org/n52/supervisor/api/CheckTask.java
// public interface CheckTask {
// 
//     public Collection<CheckResult> checkIt(CheckRunner c);
// 
// }
// 
// Path: core/src/main/java/org/n52/supervisor/api/CheckTaskFactory.java
// public interface CheckTaskFactory {
// 
//     CheckTask create(CheckRunner checker);
// 
// }


// Path: core/src/main/java/org/n52/supervisor/tasks/ThreadPoolTaskExecutor.java
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.Properties;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import org.n52.supervisor.api.CheckRunner;
import org.n52.supervisor.api.CheckTask;
import org.n52.supervisor.api.CheckTaskFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


        boolean sendEmails = Boolean.parseBoolean(props.getProperty(SEND_EMAILS));

        if (sendEmails) {
        	/*
        	 * disabled for the moment, does not work as expected
        	 */
            // add task for email notifications, with out without admin email
//            String adminEmail = this.props.getProperty(EMAIL_ADMIN_EMAIL);
//
//            long emailSendInterval = Long.valueOf(this.props.getProperty(EMAIL_SEND_PERIOD_MINDS));
//            if ( !adminEmail.contains("@ADMIN_EMAIL@")) {
//                log.info("Found admin email address for send email task.");
//                SendEmailTask set = new SendEmailTask(adminEmail, this.rd);
//                submit(EMAIL_SENDER_TASK_ID, set, emailSendInterval, emailSendInterval);
//            }
        }
        else
            log.debug("Not sending emails, not starting email tasks.");

        log.info(" ***** Timer initiated successfully! ***** ");
    }

    private Properties loadProperties(InputStream is) throws IOException {
        Properties properties = new Properties();
        properties.load(is);

        return properties;
    }

    public void submit(String identifier, CheckRunner cr, long delay) throws TaskExecutorException {