private String getMode() { return appSettings.mode(); }
public HotReloadRouter(RestxMainRouter delegate, Supplier<ImmutableSet<Class>> coldClasses) { this.delegate = delegate; this.coldClasses = Suppliers.memoize(coldClasses); this.rootPackage = appSettings.appPackage().get(); }
@Override public void run(RestxShell shell) throws Exception { AppSettings appSettings = shell.getFactory() .getComponent(AppSettings.class); compileMode.compile( shell, Paths.get(appSettings.targetClasses()), Paths.get(appSettings.targetDependency()), Paths.get(appSettings.mainSources()), Paths.get(appSettings.mainResources()), null); } }
protected String getCommand(AppSettings appSettings, Optional<String> pack, String pathSeparator) { return "java" + " -cp \"" + appSettings.targetClasses() + pathSeparator + appSettings.targetDependency() + "/*\"" + " -Drestx.app.package=" + pack.get() + " -Drestx.mode=prod"; } }
private boolean useHotReload() { if (appSettings.hotReload().or(Boolean.FALSE)) { // hotreload is explicitly set if (!appSettings.appPackage().isPresent()) { logger.info("can't enable hot reload: restx.app.package is not set.\n" + "Run your app with -Drestx.app.package=<app.base.package> to enable hot reload."); return false; } else { return true; } } else { return appSettings.hotReload().or(Boolean.TRUE) && !getMode().equals(RestxContext.Modes.PROD) && !getMode().equals(RestxContext.Modes.TEST) && appSettings.appPackage().isPresent(); } }
private boolean useHotCompile() { if (appSettings.hotCompile().or(Boolean.FALSE) || appSettings.autoCompile().or(Boolean.FALSE)) { // hotcompile or autocompile is explicitly set if (!appSettings.appPackage().isPresent()) { logger.info("can't enable hot compile: restx.app.package is not set.\n" + "Run your app with -Drestx.app.package=<app.base.package> to enable hot compile."); return false; } else if (!hasSystemJavaCompiler()) { logger.info("can't enable hot compile: tools.jar is not in classpath.\n" + "Run your app with a JDK rather than a JRE to enable hot compile."); return false; } else { return true; } } else { return appSettings.hotCompile().or(Boolean.TRUE) && !getMode().equals(RestxContext.Modes.PROD) && !getMode().equals(RestxContext.Modes.TEST) && appSettings.appPackage().isPresent() && hasSystemJavaCompiler(); } }
public Path getTargetClasses() { return FileSystems.getDefault().getPath(settings.targetClasses()); }
public Optional<RestxRouter> resourcesRouter(AppSettings appSettings) { if (new File(appSettings.mainResources()).exists()) { return Optional.of(FSRouter.mount(appSettings.mainResources()).allowDirectoryListing().on("/@/sources/resources/")); } else { return Optional.absent(); } } }
public Optional<RestxRouter> sourcesRouter(AppSettings appSettings) { if (new File(appSettings.mainSources()).exists()) { return Optional.of(FSRouter.mount(appSettings.mainSources()).allowDirectoryListing().on("/@/sources/main/")); } else { return Optional.absent(); } }
private boolean useAutoCompile() { return appSettings.autoCompile().or(Boolean.TRUE) && useHotCompile(); }
private boolean useHotCompile() { if (appSettings.hotCompile().or(Boolean.FALSE) || appSettings.autoCompile().or(Boolean.FALSE)) { // hotcompile or autocompile is explicitly set if (!appSettings.appPackage().isPresent()) { logger.info("can't enable hot compile: restx.app.package is not set.\n" + "Run your app with -Drestx.app.package=<app.base.package> to enable hot compile."); return false; } else if (!hasSystemJavaCompiler()) { logger.info("can't enable hot compile: tools.jar is not in classpath.\n" + "Run your app with a JDK rather than a JRE to enable hot compile."); return false; } else { return true; } } else { return appSettings.hotCompile().or(Boolean.TRUE) && !getMode().equals(RestxContext.Modes.PROD) && !getMode().equals(RestxContext.Modes.TEST) && appSettings.appPackage().isPresent() && hasSystemJavaCompiler(); } }
private boolean useHotReload() { if (appSettings.hotReload().or(Boolean.FALSE)) { // hotreload is explicitly set if (!appSettings.appPackage().isPresent()) { logger.info("can't enable hot reload: restx.app.package is not set.\n" + "Run your app with -Drestx.app.package=<app.base.package> to enable hot reload."); return false; } else { return true; } } else { return appSettings.hotReload().or(Boolean.TRUE) && !getMode().equals(RestxContext.Modes.PROD) && !getMode().equals(RestxContext.Modes.TEST) && appSettings.appPackage().isPresent(); } }
public Path getTargetClasses() { return FileSystems.getDefault().getPath(settings.targetClasses()); }
public Optional<RestxRouter> resourcesRouter(AppSettings appSettings) { if (new File(appSettings.mainResources()).exists()) { return Optional.of(FSRouter.mount(appSettings.mainResources()).allowDirectoryListing().on("/@/sources/resources/")); } else { return Optional.absent(); } } }
public Optional<RestxRouter> sourcesRouter(AppSettings appSettings) { if (new File(appSettings.mainSources()).exists()) { return Optional.of(FSRouter.mount(appSettings.mainSources()).allowDirectoryListing().on("/@/sources/main/")); } else { return Optional.absent(); } }
private boolean useAutoCompile() { return appSettings.autoCompile().or(Boolean.TRUE) && useHotCompile(); }
private String getMode() { return appSettings.mode(); }
public void run(RestxShell shell) throws IOException, InterruptedException { Path targetClasses = Paths.get(appSettings.targetClasses()); Path dependenciesDir = Paths.get(appSettings.targetDependency()); Path mainSources = Paths.get(appSettings.mainSources()); Path mainResources = Paths.get(appSettings.mainResources()); if (!compile.compile(shell, targetClasses, dependenciesDir, mainSources, mainResources, appClassName)) return; shell.println("starting " + appClassName + "..." + (daemon ? " - type `stop` to stop it and go back to restx shell" : "")); vmOptions.add("-Drestx.app.package=" + appSettings.appPackage()); Process run = Apps.with(appSettings) .run(shell.currentLocation().toFile(), targetClasses, dependenciesDir, vmOptions, appClassName, Collections.<String>emptyList(), quiet); if (daemon) { while (!shell.ask("", "").equals("stop")) { shell.printIn("restx> unrecognized command - type `stop` to stop the app", RestxShell.AnsiCodes.ANSI_YELLOW); shell.println(""); } run.destroy(); } run.waitFor(); }
public HotReloadRouter(RestxMainRouter delegate, Supplier<ImmutableSet<Class>> coldClasses) { this.delegate = delegate; this.coldClasses = Suppliers.memoize(coldClasses); this.rootPackage = appSettings.appPackage().get(); }
public void unpack(Path destinationDirectory, AppSettings appSettings) { Path targetClassesDir = destinationDirectory.resolve(appSettings.targetClasses()); try ( JarFile jar = new JarFile(jarFile.toFile()) ) { if(jar.getJarEntry(CHROOT+"md.restx.json") == null) {