// Path: core/src/main/java/org/n52/supervisor/api/Check.java
// @XmlRootElement
// public abstract class Check {
// 
//     private String identifier;
// 
//     private String notificationEmail;
// 
//     protected String type = "GenericCheck";
// 
//     /*
//      * injects only work on objects created by Guice.
//      * this is most likely not the case for Checkers.
//      */
// //    @Inject
// //    @Named(SupervisorProperties.DEFAULT_CHECK_INTERVAL)
//     private long intervalSeconds;
//     
//     public Check() {
//         // required for jaxb
//     }
// 
//     public Check(String identifier) {
//         super();
//         this.identifier = identifier;
//     }
//     
//     public Check(String notificationEmail, long intervalSeconds) {
//         this();
//         this.notificationEmail = notificationEmail;
//         this.intervalSeconds = intervalSeconds;
//     }
// 
//     public Check(String identifier, String notificationEmail, long intervalSeconds) {
//         this(identifier);
//         this.notificationEmail = notificationEmail;
//         this.intervalSeconds = intervalSeconds;
//     }
// 
//     public String getIdentifier() {
//         return identifier;
//     }
// 
//     public long getIntervalSeconds() {
//         return intervalSeconds;
//     }
// 
//     public String getNotificationEmail() {
//         return notificationEmail;
//     }
// 
//     public String getType() {
//         return type;
//     }
// 
//     public void setIdentifier(String identifier) {
//         this.identifier = identifier;
//     }
// 
//     public void setIntervalSeconds(long intervalMillis) {
//         this.intervalSeconds = intervalMillis;
//     }
// 
//     public void setNotificationEmail(String notificationEmail) {
//         this.notificationEmail = notificationEmail;
//     }
// 
//     public void setType(String type) {
//         this.type = type;
//     }
// 
// }
// 
// 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/checks/RunnerFactory.java
// public interface RunnerFactory {
// 
// 	CheckRunner resolveRunner(Check check);
// 
// }


import java.util.Set;
import org.n52.supervisor.api.Check;
import org.n52.supervisor.api.CheckRunner;
import org.n52.supervisor.checks.RunnerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.inject.Inject;
import com.google.inject.Singleton;
/**
 * ﻿Copyright (C) 2013 - 2014 52°North Initiative for Geospatial Open Source Software GmbH
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.n52.supervisor;




/**
 * 
 * @author Daniel
 * 
 */
@Singleton
public class CheckerResolver {

    private static Logger log = LoggerFactory.getLogger(CheckerResolver.class);

	@Inject
	private Set<RunnerFactory> factories;
    
    public CheckRunner getRunner(final Check check) {
        log.debug("Resolving check: {}", check);
        // String checkType = check.getType();

// Path: core/src/main/java/org/n52/supervisor/api/Check.java
// @XmlRootElement
// public abstract class Check {
// 
//     private String identifier;
// 
//     private String notificationEmail;
// 
//     protected String type = "GenericCheck";
// 
//     /*
//      * injects only work on objects created by Guice.
//      * this is most likely not the case for Checkers.
//      */
// //    @Inject
// //    @Named(SupervisorProperties.DEFAULT_CHECK_INTERVAL)
//     private long intervalSeconds;
//     
//     public Check() {
//         // required for jaxb
//     }
// 
//     public Check(String identifier) {
//         super();
//         this.identifier = identifier;
//     }
//     
//     public Check(String notificationEmail, long intervalSeconds) {
//         this();
//         this.notificationEmail = notificationEmail;
//         this.intervalSeconds = intervalSeconds;
//     }
// 
//     public Check(String identifier, String notificationEmail, long intervalSeconds) {
//         this(identifier);
//         this.notificationEmail = notificationEmail;
//         this.intervalSeconds = intervalSeconds;
//     }
// 
//     public String getIdentifier() {
//         return identifier;
//     }
// 
//     public long getIntervalSeconds() {
//         return intervalSeconds;
//     }
// 
//     public String getNotificationEmail() {
//         return notificationEmail;
//     }
// 
//     public String getType() {
//         return type;
//     }
// 
//     public void setIdentifier(String identifier) {
//         this.identifier = identifier;
//     }
// 
//     public void setIntervalSeconds(long intervalMillis) {
//         this.intervalSeconds = intervalMillis;
//     }
// 
//     public void setNotificationEmail(String notificationEmail) {
//         this.notificationEmail = notificationEmail;
//     }
// 
//     public void setType(String type) {
//         this.type = type;
//     }
// 
// }
// 
// 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/checks/RunnerFactory.java
// public interface RunnerFactory {
// 
// 	CheckRunner resolveRunner(Check check);
// 
// }


// Path: core/src/main/java/org/n52/supervisor/CheckerResolver.java
import java.util.Set;
import org.n52.supervisor.api.Check;
import org.n52.supervisor.api.CheckRunner;
import org.n52.supervisor.checks.RunnerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.inject.Inject;
import com.google.inject.Singleton;

/**
 * ﻿Copyright (C) 2013 - 2014 52°North Initiative for Geospatial Open Source Software GmbH
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.n52.supervisor;




/**
 * 
 * @author Daniel
 * 
 */
@Singleton
public class CheckerResolver {

    private static Logger log = LoggerFactory.getLogger(CheckerResolver.class);

	@Inject
	private Set<RunnerFactory> factories;
    
    public CheckRunner getRunner(final Check check) {
        log.debug("Resolving check: {}", check);
        // String checkType = check.getType();

        CheckRunner r = null;