public HotReloadRouter(RestxMainRouter delegate, Supplier<ImmutableSet<Class>> coldClasses) { this.delegate = delegate; this.coldClasses = Suppliers.memoize(coldClasses); this.rootPackage = appSettings.appPackage().get(); }
public HotReloadRouter(RestxMainRouter delegate, Supplier<ImmutableSet<Class>> coldClasses) { this.delegate = delegate; this.coldClasses = Suppliers.memoize(coldClasses); this.rootPackage = appSettings.appPackage().get(); }
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 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 CompilationManagerRouter(RestxMainRouter delegate, EventBus eventBus, Supplier<ImmutableSet<Class>> coldClasses, CompilationSettings compilationSettings) { this.delegate = delegate; this.coldClasses = Suppliers.memoize(coldClasses); this.rootPackage = appSettings.appPackage().get(); compilationManager = Apps.with(appSettings).newAppCompilationManager(eventBus, compilationSettings); eventBus.register(new Object() { @Subscribe public void onCompilationFinished( CompilationFinishedEvent event) { synchronized (CompilationManagerRouter.this) { classLoader = null; } } }); compilationManager.incrementalCompile(); if (useAutoCompile()) { compilationManager.startAutoCompile(); } }
public CompilationManagerRouter(RestxMainRouter delegate, EventBus eventBus, Supplier<ImmutableSet<Class>> coldClasses, CompilationSettings compilationSettings) { this.delegate = delegate; this.coldClasses = Suppliers.memoize(coldClasses); this.rootPackage = appSettings.appPackage().get(); compilationManager = Apps.with(appSettings).newAppCompilationManager(eventBus, compilationSettings); eventBus.register(new Object() { @Subscribe public void onCompilationFinished( CompilationFinishedEvent event) { synchronized (CompilationManagerRouter.this) { classLoader = null; } } }); compilationManager.incrementalCompile(); if (useAutoCompile()) { compilationManager.startAutoCompile(); } }
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 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(); }
compilationManager.incrementalCompile(); HotReloadingClassLoader hotReloadingClassLoader = compilationManager.newHotReloadingClassLoader( appSettings.appPackage().get(), ImmutableSet.<Class>of()); mainFactoryClassLoader = hotReloadingClassLoader;
compilationManager.incrementalCompile(); HotReloadingClassLoader hotReloadingClassLoader = compilationManager.newHotReloadingClassLoader( appSettings.appPackage().get(), ImmutableSet.<Class>of()); mainFactoryClassLoader = hotReloadingClassLoader;