List of usage examples for java.util ServiceLoader forEach
default void forEach(Consumer<? super T> action)
From source file:org.kie.workbench.common.migration.cli.MigrationApp.java
public MigrationApp(String args[]) { actualConfig = parseToolConfigOrExit(args); ServiceLoader<MigrationTool> migrationLoader = ServiceLoader.load(MigrationTool.class); migrationLoader.forEach(migrationTool -> migrationTools.add(migrationTool)); Collections.sort(migrationTools, Comparator.comparing(MigrationTool::getPriority)); }
From source file:org.wso2.ballerinalang.compiler.BinaryFileWriter.java
public void writeExecutableBinary(BLangPackage packageNode, String fileName) { String execFileName = cleanupExecFileName(fileName, BLANG_COMPILED_PROG_EXT); // Generate code for the given executable ProgramFile programFile = this.codeGenerator.generateBALX(packageNode); ByteArrayOutputStream byteArrayOS = new ByteArrayOutputStream(); try {//ww w . ja v a 2s . co m ProgramFileWriter.writeProgram(programFile, byteArrayOS); } catch (IOException e) { throw new BLangCompilerException("error writing program file '" + execFileName + "'", e); } final Path execFilePath = this.sourceDirectory .saveCompiledProgram(new ByteArrayInputStream(byteArrayOS.toByteArray()), execFileName); ServiceLoader<CompilerPlugin> processorServiceLoader = ServiceLoader.load(CompilerPlugin.class); processorServiceLoader.forEach(plugin -> { plugin.codeGenerated(packageNode.packageID, execFilePath); }); }