// Path: src/main/java/de/flapdoodle/embed/process/config/ExecutableProcessConfig.java
// public interface ExecutableProcessConfig {
// 
// 	Version version();
// 
// 	SupportConfig supportConfig();
// 
// 	OptionalLong stopTimeoutInMillis();
// }
// 
// Path: src/main/java/de/flapdoodle/embed/process/config/RuntimeConfig.java
// @Value.Immutable
// public interface RuntimeConfig {
// 
// 	ProcessOutput processOutput();
// 
// 	@Default
// 	default CommandLinePostProcessor commandLinePostProcessor() {
// 		return new CommandLinePostProcessor.Noop();
// 	}
// 	
// 	IArtifactStore artifactStore();
// 
// 	@Default
// 	default boolean isDaemonProcess() {
// 		return false;
// 	}
// 	
// 	static ImmutableRuntimeConfig.Builder builder() {
// 		return ImmutableRuntimeConfig.builder();
// 	}
// 
// 	/**
// 	 * some api hacks to reenable spring boot support until they fix their api usage
// 	 */
// 	static interface Builder {
// 		ImmutableRuntimeConfig.Builder processOutput(ProcessOutput processOutput);
// 
// 		default ImmutableRuntimeConfig.Builder processOutput(de.flapdoodle.embed.process.config.io.ProcessOutput processOutput) {
// 			return processOutput((ProcessOutput) processOutput);
// 		}
// 	}
// }
// 
// Path: src/main/java/de/flapdoodle/embed/process/distribution/Distribution.java
// @Value.Immutable
// public abstract class Distribution {
// 
// 	@Parameter
// 	public abstract Version version();
// 
// 	@Parameter
// 	public abstract Platform platform();
// 
// 	@Override
// 	public String toString() {
// 		return "" + version() + ":" + platform();
// 	}
// 
// 	public static Distribution detectFor(Version version) {
// 		return of(version, Platform.detect());
// 	}
// 
// 	public static Distribution of(Version version, Platform platform) {
// 		return ImmutableDistribution.of(version, platform);
// 	}
// }
// 
// Path: src/main/java/de/flapdoodle/embed/process/extract/ExtractedFileSet.java
// @Value.Immutable
// @Style(strictBuilder=true)
// public abstract class ExtractedFileSet {
// 
// 	@Parameter
// 	public abstract File baseDir();
// 	
// 	public abstract File executable();
// 	
// 	public abstract Set<File> libraryFiles();
// 
// 	public abstract boolean baseDirIsGenerated();
// 
// 	public static ImmutableExtractedFileSet.Builder builder(File baseDir) {
// 		return ImmutableExtractedFileSet.builder(baseDir);
// 	}
// }


import de.flapdoodle.embed.process.config.ExecutableProcessConfig;
import de.flapdoodle.embed.process.config.RuntimeConfig;
import de.flapdoodle.embed.process.distribution.Distribution;
import de.flapdoodle.embed.process.extract.ExtractedFileSet;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
 * Copyright (C) 2011
 *   Michael Mosmann <michael@mosmann.de>
 *   Martin Jöhren <m.joehren@googlemail.com>
 *
 * with contributions from
 * 	konstantin-ba@github,
	Archimedes Trajano (trajano@github),
	Kevin D. Keck (kdkeck@github),
	Ben McCann (benmccann@github)
 *
 * 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 de.flapdoodle.embed.process.runtime;




public abstract class Executable<T extends ExecutableProcessConfig, P extends IStopable> implements IStopable {

	private final Logger logger = LoggerFactory.getLogger(getClass());

	private final T config;
	private final RuntimeConfig runtimeConfig;
	private final ExtractedFileSet executable;
	private boolean stopped;
	private boolean registeredJobKiller;
	
	private List<IStopable> stopables = new ArrayList<>();

	private final Distribution distribution;

	public Executable(Distribution distribution, T config, RuntimeConfig runtimeConfig, ExtractedFileSet executable) {
		this.distribution = distribution;
		this.config = config;
		this.runtimeConfig = runtimeConfig;
		this.executable = executable;
		// only add shutdown hook for daemon processes,
		// clis being invoked will usually die by themselves
// Path: src/main/java/de/flapdoodle/embed/process/config/ExecutableProcessConfig.java
// public interface ExecutableProcessConfig {
// 
// 	Version version();
// 
// 	SupportConfig supportConfig();
// 
// 	OptionalLong stopTimeoutInMillis();
// }
// 
// Path: src/main/java/de/flapdoodle/embed/process/config/RuntimeConfig.java
// @Value.Immutable
// public interface RuntimeConfig {
// 
// 	ProcessOutput processOutput();
// 
// 	@Default
// 	default CommandLinePostProcessor commandLinePostProcessor() {
// 		return new CommandLinePostProcessor.Noop();
// 	}
// 	
// 	IArtifactStore artifactStore();
// 
// 	@Default
// 	default boolean isDaemonProcess() {
// 		return false;
// 	}
// 	
// 	static ImmutableRuntimeConfig.Builder builder() {
// 		return ImmutableRuntimeConfig.builder();
// 	}
// 
// 	/**
// 	 * some api hacks to reenable spring boot support until they fix their api usage
// 	 */
// 	static interface Builder {
// 		ImmutableRuntimeConfig.Builder processOutput(ProcessOutput processOutput);
// 
// 		default ImmutableRuntimeConfig.Builder processOutput(de.flapdoodle.embed.process.config.io.ProcessOutput processOutput) {
// 			return processOutput((ProcessOutput) processOutput);
// 		}
// 	}
// }
// 
// Path: src/main/java/de/flapdoodle/embed/process/distribution/Distribution.java
// @Value.Immutable
// public abstract class Distribution {
// 
// 	@Parameter
// 	public abstract Version version();
// 
// 	@Parameter
// 	public abstract Platform platform();
// 
// 	@Override
// 	public String toString() {
// 		return "" + version() + ":" + platform();
// 	}
// 
// 	public static Distribution detectFor(Version version) {
// 		return of(version, Platform.detect());
// 	}
// 
// 	public static Distribution of(Version version, Platform platform) {
// 		return ImmutableDistribution.of(version, platform);
// 	}
// }
// 
// Path: src/main/java/de/flapdoodle/embed/process/extract/ExtractedFileSet.java
// @Value.Immutable
// @Style(strictBuilder=true)
// public abstract class ExtractedFileSet {
// 
// 	@Parameter
// 	public abstract File baseDir();
// 	
// 	public abstract File executable();
// 	
// 	public abstract Set<File> libraryFiles();
// 
// 	public abstract boolean baseDirIsGenerated();
// 
// 	public static ImmutableExtractedFileSet.Builder builder(File baseDir) {
// 		return ImmutableExtractedFileSet.builder(baseDir);
// 	}
// }


// Path: src/main/java/de/flapdoodle/embed/process/runtime/Executable.java
import de.flapdoodle.embed.process.config.ExecutableProcessConfig;
import de.flapdoodle.embed.process.config.RuntimeConfig;
import de.flapdoodle.embed.process.distribution.Distribution;
import de.flapdoodle.embed.process.extract.ExtractedFileSet;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Copyright (C) 2011
 *   Michael Mosmann <michael@mosmann.de>
 *   Martin Jöhren <m.joehren@googlemail.com>
 *
 * with contributions from
 * 	konstantin-ba@github,
	Archimedes Trajano (trajano@github),
	Kevin D. Keck (kdkeck@github),
	Ben McCann (benmccann@github)
 *
 * 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 de.flapdoodle.embed.process.runtime;




public abstract class Executable<T extends ExecutableProcessConfig, P extends IStopable> implements IStopable {

	private final Logger logger = LoggerFactory.getLogger(getClass());

	private final T config;
	private final RuntimeConfig runtimeConfig;
	private final ExtractedFileSet executable;
	private boolean stopped;
	private boolean registeredJobKiller;
	
	private List<IStopable> stopables = new ArrayList<>();

	private final Distribution distribution;

	public Executable(Distribution distribution, T config, RuntimeConfig runtimeConfig, ExtractedFileSet executable) {
		this.distribution = distribution;
		this.config = config;
		this.runtimeConfig = runtimeConfig;
		this.executable = executable;
		// only add shutdown hook for daemon processes,
		// clis being invoked will usually die by themselves
		if (runtimeConfig.isDaemonProcess()) {