/** not much fun without a REST server. * but TODO we should make it so a different REST endpoint could be configured. * or better, use node js launchers in that project (likely to come with a new ui.) * <p> * relative path to webapp assumes brooklyn-server has been checked out at the same level as brooklyn-ui; * see {@link BrooklynRestApiLauncher#findJsguiWebappInSource()} */ public static Server startJavascriptWithoutRest() throws Exception { WebAppContext context = new WebAppContext( BrooklynRestApiLauncher.findJsguiWebappInSource().isPresent() ? BrooklynRestApiLauncher.findJsguiWebappInSource().get() : ResourceUtils.create(BrooklynJavascriptGuiLauncher.class).doesUrlExist("classpath://brooklyn.war") ? Os.writeToTempFile(ResourceUtils.create(BrooklynJavascriptGuiLauncher.class).getResourceFromUrl("classpath://brooklyn.war"), "brooklyn", "war").getAbsolutePath() : throwingReturning("could not find jsgui war or source", "missing-brooklyn.war"), "/"); context.setSecurityHandler(new NopSecurityHandler()); Server server = new Server(new InetSocketAddress(Networking.LOOPBACK, Networking.nextAvailablePort(FAVOURITE_PORT))); BrooklynRestApiLauncher.initJaasLoginService(server); server.setHandler(context); server.start(); log.info("JS GUI server started (no REST) at http://localhost:"+((NetworkConnector)server.getConnectors()[0]).getLocalPort()+"/"); return server; }
private void installWar(WebAppContext context) { // here we run with the JS GUI, for convenience, if we can find it, else set up an empty dir // TODO pretty sure there is an option to monitor this dir and load changes to static content // NOTE: When running Brooklyn from an IDE (i.e. by launching BrooklynJavascriptGuiLauncher.main()) // you will need to ensure that the working directory is set to the brooklyn-ui repo folder. For IntelliJ, // set the 'Working directory' of the Run/Debug Configuration to $MODULE_DIR$/brooklyn-server/launcher. // For Eclipse, use the default option of ${workspace_loc:brooklyn-launcher}. // If the working directory is not set correctly, Brooklyn will be unable to find the jsgui .war // file and the 'gui not available' message will be shown. context.setWar(this.deployJsgui && findJsguiWebappInSource().isPresent() ? findJsguiWebappInSource().get() : ResourceUtils.create(this).doesUrlExist("classpath://brooklyn.war") ? Os.writeToTempFile(ResourceUtils.create(this).getResourceFromUrl("classpath://brooklyn.war"), "brooklyn", "war").getAbsolutePath() : createTempWebDirWithIndexHtml("Brooklyn REST API <p> (gui not available)")); }