// Path: src/main/java/hr/vsite/hive/services/Service.java
// public interface Service {
// 
// 	public enum State {
// 		Uninitialized,
// 		Running,
// 		Stopped,
// 		Destroyed
// 	}
// 	
// 	/**
// 	 * Unique identifier for this service
// 	 */
// 	String getKey();
// 	
// 	/**
// 	 * Should this service start or not?
// 	 */
// 	boolean isEnabled();
// 
// 	/**
// 	 * Current state of this service
// 	 */
// 	Service.State getState();
// 
// 	/**
// 	 * Initialize service. This method blocks until the service has completely initialized.
// 	 * Call only once!
// 	 */
// 	void init() throws Exception;
// 	
// 	/**
// 	 * Starts service. This method blocks until the service has completely started.
// 	 */
// 	void start() throws Exception;
// 
// 	/**
// 	 * Stops service. This method blocks until the service has completely shut down.
// 	 */
// 	void stop();
// 
// 	/**
// 	 * Destroys service. This method blocks until the service has completely released all its resources.
// 	 * Call only once!
// 	 * After this call service can not be used again.
// 	 */
// 	void destroy() throws Exception;
// 	
// }
// 
// Path: src/main/java/hr/vsite/hive/services/javafx/JavaFxService.java
// @Singleton
// public class JavaFxService extends AbstractService {
// 
// 	public static final String Key = "javafx";
// 
// 	public JavaFxService() {
// 		super(Key);
// 	}
// 
// 	@Override
// 	public void doInit() throws Exception {
// 
// 		Platform.setImplicitExit(false);
// 
// 		appThread = new Thread(new Runnable() {
// 			@Override
// 			public void run() {
// 				Application.launch(FxApplication.class);
// 			}
// 		});
// 
// 		log.info("JavaFX service initialized");
// 		
// 	}
// 
// 	@Override
// 	public void doStart() throws Exception {
// 		appThread.start();
// 		log.info("JavaFX service started");
// 	}
// 
// 	@Override
// 	public void doStop() {
// 		Platform.exit();
// 		log.info("JavaFX service stopped");
// 	}
// 
// 	@Override
// 	public void doDestroy() {
// 		log.info("JavaFX service destroyed");
// 	}
// 
// 	private static final Logger log = LoggerFactory.getLogger(JavaFxService.class);
// 
// 	private Thread appThread = null;
// 	
// }
// 
// Path: src/main/java/hr/vsite/hive/services/jetty/JettyService.java
// @Singleton
// public class JettyService extends AbstractService {
// 
// 	public static final String Key = "jetty";
// 
// 	public JettyService() {
// 		super(Key);
// 	}
// 
// 	@Override
// 	public void doInit() throws Exception {
// 
// 		try (InputStream istream = ClassLoader.getSystemResourceAsStream("jetty.xml")) {
// 			XmlConfiguration jettyConf = new XmlConfiguration(istream);
// 			server = Server.class.cast(jettyConf.configure());
// 		}
// 
// 		log.info("Jetty service initialized");
// 		
// 	}
// 
// 	@Override
// 	public void doStart() throws Exception {
// 		server.start();
// 		log.info("Jetty service started");
// 	}
// 
// 	@Override
// 	public void doStop() {
// 		try {
// 			server.stop();
// 			log.info("Jetty service stopped");
// 		} catch (Exception e) {
// 			log.error("Error stopping jetty", e);
// 		}
// 	}
// 
// 	@Override
// 	public void doDestroy() {
// 		server.destroy();
// 		log.info("Jetty service destroyed");
// 	}
// 
// 	private static final Logger log = LoggerFactory.getLogger(JettyService.class);
// 
// 	private Server server = null;
// 	
// }


import java.util.HashSet;
import java.util.Set;
import org.quartz.CronScheduleBuilder;
import org.quartz.CronTrigger;
import org.quartz.Job;
import org.quartz.JobBuilder;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.TriggerBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import hr.vsite.hive.services.Service;
import hr.vsite.hive.services.javafx.JavaFxService;
import hr.vsite.hive.services.jetty.JettyService;

		try {
			scheduler.standby();
		} catch (SchedulerException e) {
			log.error("Unable to stop scheduler", e);
		}
		
		eventBus.post(new HiveStopEvent(this));
		
	}
	
	public void destroy() {

		log.info("Hive {} is initializing shutdown...", HiveProperties.get().getVersion());
		
		destroyServices();

		try {
			scheduler.shutdown();
		} catch (SchedulerException e) {
			log.error("Unable to stop scheduler", e);
		}
		
		eventBus.post(new HiveDestroyEvent(this));
		eventBus.shutdown();
		
		log.info("Hive {} successfully shut down - bye!", HiveProperties.get().getVersion());
		
	}

// Path: src/main/java/hr/vsite/hive/services/Service.java
// public interface Service {
// 
// 	public enum State {
// 		Uninitialized,
// 		Running,
// 		Stopped,
// 		Destroyed
// 	}
// 	
// 	/**
// 	 * Unique identifier for this service
// 	 */
// 	String getKey();
// 	
// 	/**
// 	 * Should this service start or not?
// 	 */
// 	boolean isEnabled();
// 
// 	/**
// 	 * Current state of this service
// 	 */
// 	Service.State getState();
// 
// 	/**
// 	 * Initialize service. This method blocks until the service has completely initialized.
// 	 * Call only once!
// 	 */
// 	void init() throws Exception;
// 	
// 	/**
// 	 * Starts service. This method blocks until the service has completely started.
// 	 */
// 	void start() throws Exception;
// 
// 	/**
// 	 * Stops service. This method blocks until the service has completely shut down.
// 	 */
// 	void stop();
// 
// 	/**
// 	 * Destroys service. This method blocks until the service has completely released all its resources.
// 	 * Call only once!
// 	 * After this call service can not be used again.
// 	 */
// 	void destroy() throws Exception;
// 	
// }
// 
// Path: src/main/java/hr/vsite/hive/services/javafx/JavaFxService.java
// @Singleton
// public class JavaFxService extends AbstractService {
// 
// 	public static final String Key = "javafx";
// 
// 	public JavaFxService() {
// 		super(Key);
// 	}
// 
// 	@Override
// 	public void doInit() throws Exception {
// 
// 		Platform.setImplicitExit(false);
// 
// 		appThread = new Thread(new Runnable() {
// 			@Override
// 			public void run() {
// 				Application.launch(FxApplication.class);
// 			}
// 		});
// 
// 		log.info("JavaFX service initialized");
// 		
// 	}
// 
// 	@Override
// 	public void doStart() throws Exception {
// 		appThread.start();
// 		log.info("JavaFX service started");
// 	}
// 
// 	@Override
// 	public void doStop() {
// 		Platform.exit();
// 		log.info("JavaFX service stopped");
// 	}
// 
// 	@Override
// 	public void doDestroy() {
// 		log.info("JavaFX service destroyed");
// 	}
// 
// 	private static final Logger log = LoggerFactory.getLogger(JavaFxService.class);
// 
// 	private Thread appThread = null;
// 	
// }
// 
// Path: src/main/java/hr/vsite/hive/services/jetty/JettyService.java
// @Singleton
// public class JettyService extends AbstractService {
// 
// 	public static final String Key = "jetty";
// 
// 	public JettyService() {
// 		super(Key);
// 	}
// 
// 	@Override
// 	public void doInit() throws Exception {
// 
// 		try (InputStream istream = ClassLoader.getSystemResourceAsStream("jetty.xml")) {
// 			XmlConfiguration jettyConf = new XmlConfiguration(istream);
// 			server = Server.class.cast(jettyConf.configure());
// 		}
// 
// 		log.info("Jetty service initialized");
// 		
// 	}
// 
// 	@Override
// 	public void doStart() throws Exception {
// 		server.start();
// 		log.info("Jetty service started");
// 	}
// 
// 	@Override
// 	public void doStop() {
// 		try {
// 			server.stop();
// 			log.info("Jetty service stopped");
// 		} catch (Exception e) {
// 			log.error("Error stopping jetty", e);
// 		}
// 	}
// 
// 	@Override
// 	public void doDestroy() {
// 		server.destroy();
// 		log.info("Jetty service destroyed");
// 	}
// 
// 	private static final Logger log = LoggerFactory.getLogger(JettyService.class);
// 
// 	private Server server = null;
// 	
// }


// Path: src/main/java/hr/vsite/hive/Hive.java
import java.util.HashSet;
import java.util.Set;
import org.quartz.CronScheduleBuilder;
import org.quartz.CronTrigger;
import org.quartz.Job;
import org.quartz.JobBuilder;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.TriggerBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import hr.vsite.hive.services.Service;
import hr.vsite.hive.services.javafx.JavaFxService;
import hr.vsite.hive.services.jetty.JettyService;


		try {
			scheduler.standby();
		} catch (SchedulerException e) {
			log.error("Unable to stop scheduler", e);
		}
		
		eventBus.post(new HiveStopEvent(this));
		
	}
	
	public void destroy() {

		log.info("Hive {} is initializing shutdown...", HiveProperties.get().getVersion());
		
		destroyServices();

		try {
			scheduler.shutdown();
		} catch (SchedulerException e) {
			log.error("Unable to stop scheduler", e);
		}
		
		eventBus.post(new HiveDestroyEvent(this));
		eventBus.shutdown();
		
		log.info("Hive {} successfully shut down - bye!", HiveProperties.get().getVersion());
		
	}

	private void initServices() {