@SuppressWarnings("unchecked") <P extends Plugin> P getPlugin(Class<P> pluginClass) { for (Plugin plugin : plugins) { if (plugin.getClass().equals(pluginClass)) { return (P) plugin; } } throw new NoSuchElementException("plugin " + pluginClass + " is not loaded"); }
DockerOrchestrator( DockerClient docker, Repo repo, FileOrchestrator fileOrchestrator, Set<BuildFlag> buildFlags, Logger logger, TailFactory tailFactory, DockerfileValidator dockerfileValidator, DefinitionFilter definitionFilter, boolean permissionErrorTolerant) { if (docker == null) { throw new IllegalArgumentException("docker is null"); } if (repo == null) { throw new IllegalArgumentException("repo is null"); } if (buildFlags == null) { throw new IllegalArgumentException("buildFlags is null"); } if (fileOrchestrator == null) { throw new IllegalArgumentException("fileOrchestrator is null"); } if (dockerfileValidator == null) { throw new IllegalArgumentException("dockerfileValidator is null"); } if (definitionFilter == null) { throw new IllegalArgumentException("definitionFilter is null"); } this.docker = docker; this.tailFactory = tailFactory; this.repo = repo; this.fileOrchestrator = fileOrchestrator; this.buildFlags = buildFlags; this.logger = logger; this.dockerfileValidator = dockerfileValidator; this.definitionFilter = definitionFilter; this.permissionErrorTolerant = permissionErrorTolerant; for (Plugin plugin : ServiceLoader.load(Plugin.class)) { plugins.add(plugin); logger.info("Loaded " + plugin.getClass() + " plugin"); } }