/** 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; }
((WebAppContext)context).setSecurityHandler(new NopSecurityHandler());