protected WebServerBase(String appBase, int port, String bindInterface, String serverTypeName, String serverGroupId, String serverModule) { if(appBase != null) { checkFileExists(appBase); } this.port = port; this.bindInterface = bindInterface; this.appBase = appBase; this.serverId = serverTypeName + "#" + SERVER_ID.incrementAndGet(); this.serverTypeName = serverTypeName; this.serverGroupId = serverGroupId; this.serverModule = serverModule; }
@Override boolean compile(RestxShell shell, Path targetClasses, Path dependenciesDir, Path mainSources, Path mainResources, String className) throws IOException, InterruptedException { shell.print("copying resources..."); copyDir( shell.currentLocation().resolve(mainResources), shell.currentLocation().resolve(targetClasses) ); shell.printIn(" [DONE]", RestxShell.AnsiCodes.ANSI_GREEN); shell.println(""); return true; } },
public void startAutoCompile() { synchronized (this) { if (watcherExecutor == null) { watcherExecutor = Executors.newCachedThreadPool(); Collection<Path> watched = new ArrayList<>(); for (Path sourceRoot : sourceRoots) { if (sourceRoot.toFile().exists()) { watched.add(sourceRoot); closeableWatchers.add(MoreFiles.watch(sourceRoot, eventBus, watcherExecutor, new WatcherSettings() { @Override public int coalescePeriod() { return settings.autoCompileCoalescePeriod(); } @Override public boolean recurse() { return true; } })); } else { logger.info("source root {} does not exist - IGNORED", sourceRoot); } } logger.info("watching for changes in {}; current location is {}", watched, new File(".").getAbsoluteFile()); } } }
@Override public Exception call() throws Exception { try { compileQueue.clear(); MoreFiles.delete(destination); destination.toFile().mkdirs(); final Collection<Path> sources = new ArrayList<>(); for (final Path sourceRoot : sourceRoots) { if (sourceRoot.toFile().exists()) { Files.walkFileTree(sourceRoot, new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { if (isSource(file)) { sources.add(file); } else if (file.toFile().isFile()) { doCopyResource(SourcePath.valueOf(sourceRoot, sourceRoot.relativize(file))); } return FileVisitResult.CONTINUE; } }); } } compile(sources); return null; } catch (Exception e) { return e; } } }).get(compilationTimeout, TimeUnit.SECONDS);
shell.download(tplZipURL, zipFile); extractZip(zipFile, tplDir); if (tplDir.list().length == 1 && tplDir.listFiles()[0].isDirectory()) {
@Override boolean compile(RestxShell shell, Path targetClasses, Path dependenciesDir, Path mainSources, Path mainResources, String className) throws IOException, InterruptedException { shell.print("compiling App..."); shell.currentLocation().resolve(targetClasses).toFile().mkdirs(); int compiled = new ProcessBuilder( "javac", "-cp", dependenciesDir + "/*", "-sourcepath", mainSources.toString(), "-d", targetClasses.toString(), mainSources.resolve(className.replace('.', '/') + ".java").toString()) .redirectErrorStream(true) .redirectOutput(ProcessBuilder.Redirect.INHERIT) .directory(shell.currentLocation().toFile().getAbsoluteFile()) .start() .waitFor(); if (compiled != 0) { shell.printIn(" [ERROR]", RestxShell.AnsiCodes.ANSI_RED); shell.println(""); return false; } shell.printIn(" [DONE]", RestxShell.AnsiCodes.ANSI_GREEN); shell.println(""); shell.print("copying resources..."); copyDir( shell.currentLocation().resolve(mainResources), shell.currentLocation().resolve(targetClasses) ); shell.printIn(" [DONE]", RestxShell.AnsiCodes.ANSI_GREEN); shell.println(""); return true; } },
public void startAutoCompile() { synchronized (this) { if (watcherExecutor == null) { watcherExecutor = Executors.newCachedThreadPool(); Collection<Path> watched = new ArrayList<>(); for (Path sourceRoot : sourceRoots) { if (sourceRoot.toFile().exists()) { watched.add(sourceRoot); closeableWatchers.add(MoreFiles.watch(sourceRoot, eventBus, watcherExecutor, new WatcherSettings() { @Override public int coalescePeriod() { return settings.autoCompileCoalescePeriod(); } @Override public boolean recurse() { return true; } })); } else { logger.info("source root {} does not exist - IGNORED", sourceRoot); } } logger.info("watching for changes in {}; current location is {}", watched, new File(".").getAbsoluteFile()); } } }
@Override public Exception call() throws Exception { try { compileQueue.clear(); MoreFiles.delete(destination); destination.toFile().mkdirs(); final Collection<Path> sources = new ArrayList<>(); for (final Path sourceRoot : sourceRoots) { if (sourceRoot.toFile().exists()) { Files.walkFileTree(sourceRoot, new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { if (isSource(file)) { sources.add(file); } else if (file.toFile().isFile()) { doCopyResource(SourcePath.valueOf(sourceRoot, sourceRoot.relativize(file))); } return FileVisitResult.CONTINUE; } }); } } compile(sources); return null; } catch (Exception e) { return e; } } }).get(compilationTimeout, TimeUnit.SECONDS);
public Jetty7WebServer(String webInfLocation, String appBase, int port, String bindInterface) { super(checkNotNull(appBase), port, bindInterface, "Jetty7", "org.eclipse.jetty", "jetty-server"); if (webInfLocation != null) { checkFileExists(webInfLocation); } this.webInfLocation = webInfLocation; }
copyDir( shell.currentLocation().resolve(mainResources), shell.currentLocation().resolve(targetClasses)
protected WebServerBase(String appBase, int port, String bindInterface, String serverTypeName, String serverGroupId, String serverModule) { if(appBase != null) { checkFileExists(appBase); } this.port = port; this.bindInterface = bindInterface; this.appBase = appBase; this.serverId = serverTypeName + "#" + SERVER_ID.incrementAndGet(); this.serverTypeName = serverTypeName; this.serverGroupId = serverGroupId; this.serverModule = serverModule; }
public Jetty7WebServer(String webInfLocation, String appBase, int port, String bindInterface) { super(checkNotNull(appBase), port, bindInterface, "Jetty7", "org.eclipse.jetty", "jetty-server"); if (webInfLocation != null) { checkFileExists(webInfLocation); } this.webInfLocation = webInfLocation; }
public Jetty8WebServer(String webInfLocation, String appBase, int port, String bindInterface) { super(checkNotNull(appBase), port, bindInterface, "Jetty8", "org.eclipse.jetty", "jetty-server"); if (webInfLocation != null) { checkFileExists(webInfLocation); } this.webInfLocation = webInfLocation; }
public Jetty8WebServer(String webInfLocation, String appBase, int port, String bindInterface) { super(checkNotNull(appBase), port, bindInterface, "Jetty8", "org.eclipse.jetty", "jetty-server"); if (webInfLocation != null) { checkFileExists(webInfLocation); } this.webInfLocation = webInfLocation; }