You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2018/07/27 10:03:49 UTC
[3/4] brooklyn-server git commit: remove all mention of brooklyn.war,
delete JavascriptGuiLauncher
remove all mention of brooklyn.war, delete JavascriptGuiLauncher
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/3602dcb8
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/3602dcb8
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/3602dcb8
Branch: refs/heads/master
Commit: 3602dcb8e1a3c9ac64be99738529dbf694a13cc2
Parents: d1f21f0
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Thu Jul 26 15:57:47 2018 +0100
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Thu Jul 26 16:00:32 2018 +0100
----------------------------------------------------------------------
launcher/pom.xml | 57 ----------
.../brooklyn/launcher/BrooklynWebServer.java | 43 +++++---
.../launcher/config/CustomResourceLocator.java | 4 +-
.../brooklyn/launcher/WebAppRunnerTest.java | 19 ++--
.../jsgui/BrooklynJavascriptGuiLauncher.java | 104 -------------------
.../BrooklynJavascriptGuiLauncherTest.java | 95 -----------------
rest/rest-api/pom.xml | 7 --
rest/rest-resources/pom.xml | 7 --
.../rest/resources/ActivityRestTest.java | 4 +-
.../brooklyn/rest/BrooklynRestApiLauncher.java | 76 ++++----------
.../brooklyn/rest/CorsFilterLauncherTest.java | 3 +-
11 files changed, 64 insertions(+), 355 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3602dcb8/launcher/pom.xml
----------------------------------------------------------------------
diff --git a/launcher/pom.xml b/launcher/pom.xml
index c691fc2..a18827e 100644
--- a/launcher/pom.xml
+++ b/launcher/pom.xml
@@ -82,14 +82,6 @@
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-jsgui</artifactId>
- <type>war</type>
- <!-- Needed during build time only -->
- <scope>provided</scope>
- <version>${project.version}</version>
- </dependency>
- <dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.framework</artifactId>
</dependency>
@@ -226,55 +218,6 @@
<build>
<plugins>
-
- <plugin>
- <artifactId>maven-dependency-plugin</artifactId>
- <!-- copy the WAR so it is available on the classpath for programmatic deployment -->
- <executions>
- <execution>
- <id>copy</id>
- <phase>process-classes</phase>
- <goals>
- <goal>copy</goal>
- </goals>
- <configuration>
- <artifactItems>
- <artifactItem>
- <!-- this can fail in eclipse trying to copy _from_ target/classes.
- see http://jira.codehaus.org/browse/MDEP-259 -->
- <groupId>${project.groupId}</groupId>
- <artifactId>brooklyn-jsgui</artifactId>
- <version>${project.version}</version>
- <type>war</type>
- <overWrite>true</overWrite>
- <outputDirectory>target/classes</outputDirectory>
- <destFileName>brooklyn.war</destFileName>
- </artifactItem>
- </artifactItems>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <executions>
- <execution>
- <id>exclude-jsgui</id>
- <phase>package</phase>
- <goals>
- <goal>jar</goal>
- </goals>
- <configuration>
- <classifier>no-jsgui</classifier>
- <excludes>
- <exclude>brooklyn.war</exclude>
- </excludes>
- </configuration>
- </execution>
- </executions>
- </plugin>
<plugin>
<groupId>org.apache.rat</groupId>
<artifactId>apache-rat-plugin</artifactId>
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3602dcb8/launcher/src/main/java/org/apache/brooklyn/launcher/BrooklynWebServer.java
----------------------------------------------------------------------
diff --git a/launcher/src/main/java/org/apache/brooklyn/launcher/BrooklynWebServer.java b/launcher/src/main/java/org/apache/brooklyn/launcher/BrooklynWebServer.java
index 604b559..4b01ee8 100644
--- a/launcher/src/main/java/org/apache/brooklyn/launcher/BrooklynWebServer.java
+++ b/launcher/src/main/java/org/apache/brooklyn/launcher/BrooklynWebServer.java
@@ -19,6 +19,7 @@
package org.apache.brooklyn.launcher;
import java.io.File;
+import java.io.IOException;
import java.io.InputStream;
import java.net.BindException;
import java.net.InetAddress;
@@ -42,14 +43,12 @@ import org.apache.brooklyn.api.location.PortRange;
import org.apache.brooklyn.api.mgmt.ManagementContext;
import org.apache.brooklyn.config.ConfigKey;
import org.apache.brooklyn.core.BrooklynFeatureEnablement;
-import org.apache.brooklyn.core.BrooklynVersion;
import org.apache.brooklyn.core.internal.BrooklynInitialization;
import org.apache.brooklyn.core.location.PortRanges;
import org.apache.brooklyn.core.mgmt.ShutdownHandler;
import org.apache.brooklyn.core.mgmt.internal.ManagementContextInternal;
import org.apache.brooklyn.core.server.BrooklynServerPaths;
import org.apache.brooklyn.core.server.BrooklynServiceAttributes;
-import org.apache.brooklyn.launcher.config.CustomResourceLocator;
import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
import org.apache.brooklyn.rest.BrooklynWebConfig;
import org.apache.brooklyn.rest.NopSecurityHandler;
@@ -72,6 +71,7 @@ import org.apache.brooklyn.util.core.BrooklynNetworkUtils;
import org.apache.brooklyn.util.core.ResourceUtils;
import org.apache.brooklyn.util.core.crypto.FluentKeySigner;
import org.apache.brooklyn.util.core.crypto.SecureKeys;
+import org.apache.brooklyn.util.core.file.ArchiveBuilder;
import org.apache.brooklyn.util.core.flags.FlagUtils;
import org.apache.brooklyn.util.core.flags.SetFromFlag;
import org.apache.brooklyn.util.core.flags.TypeCoercions;
@@ -102,24 +102,18 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Charsets;
import com.google.common.base.Splitter;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps;
+import com.google.common.io.Files;
/**
- * Starts the web-app running, connected to the given management context
+ * Starts the brooklyn REST server running, connected to the given management context
*/
public class BrooklynWebServer {
private static final Logger log = LoggerFactory.getLogger(BrooklynWebServer.class);
-
- public static final String BROOKLYN_WAR_URL = "classpath://brooklyn.war";
- static {
- // support loading the WAR in dev mode from an alternate location
- CustomResourceLocator.registerAlternateLocator(new CustomResourceLocator.SearchingClassPathInDevMode(
- BROOKLYN_WAR_URL, "/brooklyn-server/launcher/target",
- "/brooklyn-server/rest/rest-server/target/brooklyn-rest-server-"+BrooklynVersion.get()+".jar"));
- }
static {
LoggingSetup.installJavaUtilLoggingBridge();
@@ -146,7 +140,7 @@ public class BrooklynWebServer {
protected InetAddress actualAddress = null;
@SetFromFlag
- protected String war = BROOKLYN_WAR_URL;
+ protected String war = null;
/** IP of NIC where this server should bind, or null to autodetect
* (e.g. 0.0.0.0 if security is configured, or loopback if no security) */
@@ -240,7 +234,7 @@ public class BrooklynWebServer {
}
public BrooklynWebServer(ManagementContext managementContext, int port) {
- this(managementContext, port, "brooklyn.war");
+ this(managementContext, port, null);
}
public BrooklynWebServer(ManagementContext managementContext, int port, String warUrl) {
@@ -435,6 +429,9 @@ public class BrooklynWebServer {
actualAddress = bindAddress;
}
+ if (war==null) {
+ war = createTempWarWithIndexHtml("This server is running the Brooklyn REST API only. No UI.");
+ }
if (log.isDebugEnabled())
log.debug("Starting Brooklyn rest server at "+getRootUrl()+", running " + war + (wars != null ? " and " + wars.values() : ""));
@@ -716,4 +713,24 @@ public class BrooklynWebServer {
return rootContext;
}
+ // duplicated in BrooklynRestApiLauncher (in test project so not visible here)
+ /** create a directory with a simple index.html so we have some content being served up */
+ private static String createTempWebDirWithIndexHtml(String indexHtmlContent) {
+ File dir = Files.createTempDir();
+ dir.deleteOnExit();
+ try {
+ Files.write(indexHtmlContent, new File(dir, "index.html"), Charsets.UTF_8);
+ } catch (IOException e) {
+ Exceptions.propagate(e);
+ }
+ return dir.getAbsolutePath();
+ }
+ /** create WAR/ZIP as per {@link #createTempWebDirWithIndexHtml(String)} */
+ private static String createTempWarWithIndexHtml(String indexHtmlContent) {
+ File archive = ArchiveBuilder.zip().addDirContentsAt(
+ new File(createTempWebDirWithIndexHtml(indexHtmlContent)), ".").create();
+ archive.deleteOnExit();
+ return archive.getAbsolutePath();
+ }
+
}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3602dcb8/launcher/src/main/java/org/apache/brooklyn/launcher/config/CustomResourceLocator.java
----------------------------------------------------------------------
diff --git a/launcher/src/main/java/org/apache/brooklyn/launcher/config/CustomResourceLocator.java b/launcher/src/main/java/org/apache/brooklyn/launcher/config/CustomResourceLocator.java
index 21c5bcc..8e2e2b4 100644
--- a/launcher/src/main/java/org/apache/brooklyn/launcher/config/CustomResourceLocator.java
+++ b/launcher/src/main/java/org/apache/brooklyn/launcher/config/CustomResourceLocator.java
@@ -65,7 +65,9 @@ public class CustomResourceLocator {
/** finds the file indicated at the URL, using some rewrites if necessary to work around some known issues.
* <p>
- * in particular, eclipse often does not copy WAR files as instructed by maven, so brooklyn.war might not be found */
+ * in particular, eclipse often does not copy WAR files as instructed by maven, so brooklyn.war might not be found;
+ * less important now that WARs are run separately, via OSGi (in prod) or node (in dev),
+ * but kept in case custom WARs are ever added to legacy webserver code */
public InputStream getResourceFromUrl(String url) {
// TODO we could allow the source to be overridden from config,
// by allowing configuration e.g.
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3602dcb8/launcher/src/test/java/org/apache/brooklyn/launcher/WebAppRunnerTest.java
----------------------------------------------------------------------
diff --git a/launcher/src/test/java/org/apache/brooklyn/launcher/WebAppRunnerTest.java b/launcher/src/test/java/org/apache/brooklyn/launcher/WebAppRunnerTest.java
index 766fce5..c335b69 100644
--- a/launcher/src/test/java/org/apache/brooklyn/launcher/WebAppRunnerTest.java
+++ b/launcher/src/test/java/org/apache/brooklyn/launcher/WebAppRunnerTest.java
@@ -39,7 +39,8 @@ import com.google.common.collect.Lists;
/**
- * These tests require the brooklyn.war to work. (Should be placed by maven build.)
+ * Tests that web app starts with given WAR(s) - legacy startup, originally written for the single non-angular brooklyn.war,
+ * but tested here that it works with other WARs in case that is used anywhere.
*/
public class WebAppRunnerTest {
@@ -81,14 +82,14 @@ public class WebAppRunnerTest {
try {
server.start();
- assertBrooklynEventuallyAt("http://localhost:"+server.getActualPort()+"/");
+ assertRootPageAvailableAt("http://localhost:"+server.getActualPort()+"/");
} finally {
server.stop();
}
}
- public static void assertBrooklynEventuallyAt(String url) {
- HttpAsserts.assertContentEventuallyContainsText(url, "Brooklyn Web Console");
+ public static void assertRootPageAvailableAt(String url) {
+ HttpAsserts.assertContentEventuallyContainsText(url, "Brooklyn REST API only");
}
@Test
@@ -96,13 +97,13 @@ public class WebAppRunnerTest {
TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war");
BrooklynWebServer server = createWebServer(
- MutableMap.of("port", "8091+", "war", "brooklyn.war", "wars", MutableMap.of("hello", "hello-world.war")) );
+ MutableMap.of("port", "8091+", "war", null, "wars", MutableMap.of("hello", "hello-world.war")) );
assertNotNull(server);
try {
server.start();
- assertBrooklynEventuallyAt("http://localhost:"+server.getActualPort()+"/");
+ assertRootPageAvailableAt("http://localhost:"+server.getActualPort()+"/");
HttpAsserts.assertContentEventuallyContainsText("http://localhost:"+server.getActualPort()+"/hello",
"This is the home page for a sample application");
@@ -115,14 +116,14 @@ public class WebAppRunnerTest {
public void testStartSecondaryWarAfter() throws Exception {
TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war");
- BrooklynWebServer server = createWebServer(MutableMap.of("port", "8091+", "war", "brooklyn.war"));
+ BrooklynWebServer server = createWebServer(MutableMap.of("port", "8091+", "war", null));
assertNotNull(server);
try {
server.start();
server.deploy("/hello", "hello-world.war");
- assertBrooklynEventuallyAt("http://localhost:"+server.getActualPort()+"/");
+ assertRootPageAvailableAt("http://localhost:"+server.getActualPort()+"/");
HttpAsserts.assertContentEventuallyContainsText("http://localhost:"+server.getActualPort()+"/hello",
"This is the home page for a sample application");
@@ -145,7 +146,7 @@ public class WebAppRunnerTest {
try {
details.getWebServer().deploy("/hello2", "hello-world.war");
- assertBrooklynEventuallyAt(details.getWebServerUrl());
+ assertRootPageAvailableAt(details.getWebServerUrl());
HttpAsserts.assertContentEventuallyContainsText(details.getWebServerUrl()+"hello", "This is the home page for a sample application");
HttpAsserts.assertContentEventuallyContainsText(details.getWebServerUrl()+"hello2", "This is the home page for a sample application");
HttpAsserts.assertHttpStatusCodeEventuallyEquals(details.getWebServerUrl()+"hello0", 404);
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3602dcb8/launcher/src/test/java/org/apache/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncher.java
----------------------------------------------------------------------
diff --git a/launcher/src/test/java/org/apache/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncher.java b/launcher/src/test/java/org/apache/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncher.java
deleted file mode 100644
index 0677561..0000000
--- a/launcher/src/test/java/org/apache/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncher.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.brooklyn.rest.jsgui;
-
-import java.net.InetSocketAddress;
-
-import org.apache.brooklyn.rest.BrooklynRestApiLauncher;
-import org.apache.brooklyn.rest.NopSecurityHandler;
-import org.apache.brooklyn.rest.security.provider.AnyoneSecurityProvider;
-import org.apache.brooklyn.util.core.ResourceUtils;
-import org.apache.brooklyn.util.net.Networking;
-import org.apache.brooklyn.util.os.Os;
-import org.eclipse.jetty.server.NetworkConnector;
-import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.webapp.WebAppContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/** launches Javascript GUI programmatically. and used for tests.
- * see {@link BrooklynRestApiLauncher} for more information.
- *
- * WINDOWS tips:
- * On Windows Jetty will lock all static files preventing any changes on them.
- * To work around the problem and tell Jetty not to lock files:
- * <ul>
- * <li>find jetty-webapp-<ver>.jar from your classpath
- * <li>extract the file webdefault.xml from folder org/eclipse/jetty/webapp (On Eclipse
- * just expanding the jar from the dependencies, right click/copy on the file.)
- * <li>in this project create a java package org.eclipse.jetty.webapp and put the webdefault.html file in it
- * <li>edit the file and change the property useFileMappedBuffer to false
- * </ul>
- **/
-public class BrooklynJavascriptGuiLauncher {
-
- private static final Logger log = LoggerFactory.getLogger(BrooklynJavascriptGuiLauncher.class);
-
- public static void main(String[] args) throws Exception {
- // 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 jsgui 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.
- startJavascriptAndRest();
-
- log.info("Press Ctrl-C to quit.");
- }
-
- final static int FAVOURITE_PORT = 8080;
-
- /** due to the relative path search in {@link BrooklynRestApiLauncher} we can just call that method */
- public static Server startJavascriptAndRest() throws Exception {
- return BrooklynRestApiLauncher.launcherServlet()
- .securityProvider(AnyoneSecurityProvider.class)
- .start();
- }
-
- /** 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 static <T> T throwingReturning(String error, T result) {
- throw new IllegalStateException(error);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3602dcb8/launcher/src/test/java/org/apache/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncherTest.java
----------------------------------------------------------------------
diff --git a/launcher/src/test/java/org/apache/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncherTest.java b/launcher/src/test/java/org/apache/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncherTest.java
deleted file mode 100644
index 77adb2e..0000000
--- a/launcher/src/test/java/org/apache/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncherTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.brooklyn.rest.jsgui;
-
-import org.apache.brooklyn.api.mgmt.ManagementContext;
-import org.apache.brooklyn.core.entity.Entities;
-import org.apache.brooklyn.core.server.BrooklynServiceAttributes;
-import org.apache.brooklyn.rest.BrooklynRestApiLauncherTestFixture;
-import org.apache.brooklyn.util.core.osgi.Compat;
-import org.apache.brooklyn.util.http.HttpAsserts;
-import org.eclipse.jetty.server.NetworkConnector;
-import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.server.handler.ContextHandler;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.Test;
-
-/** Convenience and demo for launching programmatically. */
-public class BrooklynJavascriptGuiLauncherTest {
-
- Server server = null;
-
- @AfterMethod(alwaysRun=true)
- public void stopServer() throws Exception {
- if (server!=null) {
- ManagementContext mgmt = getManagementContextFromJettyServerAttributes(server);
- server.stop();
- if (mgmt!=null) Entities.destroyAll(mgmt);
- server = null;
- }
- }
-
- @Test
- public void testJavascriptWithoutRest() throws Exception {
- server = BrooklynJavascriptGuiLauncher.startJavascriptWithoutRest();
- checkUrlContains("/index.html", "Brooklyn");
- }
-
- @Test
- public void testJavascriptWithRest() throws Exception {
- server = BrooklynJavascriptGuiLauncher.startJavascriptAndRest();
- BrooklynRestApiLauncherTestFixture.forceUseOfDefaultCatalogWithJavaClassPath(server);
- BrooklynRestApiLauncherTestFixture.enableAnyoneLogin(server);
- checkEventuallyHealthy();
- checkUrlContains("/index.html", "Brooklyn");
- checkUrlContains("/v1/catalog/entities", "BrooklynNode");
- }
-
- protected void checkUrlContains(final String path, final String text) {
- //Server may return 403 until it loads completely, wait a bit
- //until it stabilizes.
- HttpAsserts.assertContentEventuallyContainsText(rootUrl()+path, text);
- }
-
- protected void checkEventuallyHealthy() {
- HttpAsserts.assertHttpStatusCodeEventuallyEquals(rootUrl(), 200);
- }
-
- protected String rootUrl() {
- return "http://localhost:"+((NetworkConnector)server.getConnectors()[0]).getLocalPort();
- }
-
- private ManagementContext getManagementContextFromJettyServerAttributes(Server server) {
- return getManagementContext((ContextHandler) server.getHandler());
- }
-
- /**
- * Compatibility methods between karaf launcher and monolithic launcher.
- *
- * @todo Remove after transition to karaf launcher.
- */
- public static ManagementContext getManagementContext(ContextHandler jettyServerHandler) {
- ManagementContext managementContext = Compat.getInstance().getManagementContext();
- if (managementContext == null && jettyServerHandler != null) {
- managementContext = (ManagementContext) jettyServerHandler.getAttribute(BrooklynServiceAttributes.BROOKLYN_MANAGEMENT_CONTEXT);
- }
- return managementContext;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3602dcb8/rest/rest-api/pom.xml
----------------------------------------------------------------------
diff --git a/rest/rest-api/pom.xml b/rest/rest-api/pom.xml
index bc5c641..32b6e89 100644
--- a/rest/rest-api/pom.xml
+++ b/rest/rest-api/pom.xml
@@ -99,13 +99,6 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-jsgui</artifactId>
- <version>${project.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3602dcb8/rest/rest-resources/pom.xml
----------------------------------------------------------------------
diff --git a/rest/rest-resources/pom.xml b/rest/rest-resources/pom.xml
index 175a061..17effa1 100644
--- a/rest/rest-resources/pom.xml
+++ b/rest/rest-resources/pom.xml
@@ -157,13 +157,6 @@
</dependency>
<dependency>
<groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-jsgui</artifactId>
- <version>${project.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
<artifactId>brooklyn-locations-jclouds</artifactId>
<version>${project.version}</version>
<scope>test</scope>
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3602dcb8/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/ActivityRestTest.java
----------------------------------------------------------------------
diff --git a/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/ActivityRestTest.java b/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/ActivityRestTest.java
index 8b0ebe7..f05c002 100644
--- a/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/ActivityRestTest.java
+++ b/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/ActivityRestTest.java
@@ -334,14 +334,14 @@ Task[eatand]@J90TKfIX: Waiting on Task[eat-sleep-rave-repeat]@QPa5o4kF
// child completed; now check we complete soon, and assert we have siblings
if (ci.hasNext()) continue;
if (!t.blockUntilEnded(timer.getDurationRemaining())) {
- Entities.dumpInfo(tRoot);
+ Dumper.dumpInfo(tRoot);
// log.info("Incomplete after "+t+": "+t.getStatusDetail(false));
throw Exceptions.propagate( new TimeoutException("parent didn't complete after child depth "+finishedDescendantDepth) );
}
}
if (finishedDescendantDepth == depthSoFar+2) {
if (Iterables.size(children)<2) {
- Entities.dumpInfo(tRoot);
+ Dumper.dumpInfo(tRoot);
throw new IllegalStateException("finished child's parent has no sibling");
}
}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3602dcb8/rest/rest-server/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncher.java
----------------------------------------------------------------------
diff --git a/rest/rest-server/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncher.java b/rest/rest-server/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncher.java
index 617fb77..eaa20f4 100644
--- a/rest/rest-server/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncher.java
+++ b/rest/rest-server/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncher.java
@@ -53,11 +53,10 @@ import org.apache.brooklyn.rest.security.provider.SecurityProvider;
import org.apache.brooklyn.rest.util.ManagementContextProvider;
import org.apache.brooklyn.rest.util.ServerStoppingShutdownHandler;
import org.apache.brooklyn.rest.util.ShutdownHandlerProvider;
-import org.apache.brooklyn.util.core.ResourceUtils;
+import org.apache.brooklyn.util.core.file.ArchiveBuilder;
import org.apache.brooklyn.util.exceptions.Exceptions;
import org.apache.brooklyn.util.guava.Maybe;
import org.apache.brooklyn.util.net.Networking;
-import org.apache.brooklyn.util.os.Os;
import org.apache.brooklyn.util.text.WildcardGlobs;
import org.eclipse.jetty.jaas.JAASLoginService;
import org.eclipse.jetty.server.NetworkConnector;
@@ -74,18 +73,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.io.Files;
-/** Convenience and demo for launching programmatically. Also used for automated tests.
- * <p>
- * BrooklynLauncher has a more full-featured CLI way to start,
- * but if you want more control you can:
- * <li> take the WAR this project builds (REST API) -- NB probably want the unshaded one (containing all deps)
- * <li> take the WAR from the brooklyn-jsgui project (brooklyn-ui repo) _and_ this WAR and combine them
- * (this one should run as a filter on the others, _not_ as a ResourceCollection where they fight over who's got root)
- * <li> programmatically install things, following the examples herein;
- * in particular {@link RestApiSetup} is quite handy!
- * <p>
- * You can also just run this class. In most installs it just works, assuming your IDE or maven-fu gives you the classpath.
- * Add more apps and entities on the classpath and they'll show up in the catalog.
+/** Convenience and demo for launching programmatically in a legacy non-OSGi mode. Also used for automated tests.
**/
public class BrooklynRestApiLauncher {
@@ -107,7 +95,6 @@ public class BrooklynRestApiLauncher {
private StartMode mode = StartMode.SERVLET;
private ManagementContext mgmt;
private ContextHandler customContext;
- private boolean deployJsgui = true;
private boolean disableHighAvailability = true;
private ServerStoppingShutdownHandler shutdownListener;
@@ -151,16 +138,6 @@ public class BrooklynRestApiLauncher {
return this;
}
- public BrooklynRestApiLauncher withJsgui() {
- this.deployJsgui = true;
- return this;
- }
-
- public BrooklynRestApiLauncher withoutJsgui() {
- this.deployJsgui = false;
- return this;
- }
-
public BrooklynRestApiLauncher disableHighAvailability(boolean value) {
this.disableHighAvailability = value;
return this;
@@ -257,20 +234,8 @@ public class BrooklynRestApiLauncher {
}
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)"));
+ context.setWar(
+ createTempWarWithIndexHtml("Brooklyn REST API only <p> (gui not available in legacy non-OSGi mode)"));
}
/** NB: not fully supported; use one of the other {@link StartMode}s */
@@ -369,25 +334,6 @@ public class BrooklynRestApiLauncher {
return launcherWebXml().start();
}
- /** look for the JS GUI webapp in common source places, returning path to it if found, or null.
- * assumes `brooklyn-ui` is checked out as a sibling to `brooklyn-server`, and both are 2, 3, 1, or 0
- * levels above the CWD. */
- @Beta
- public static Maybe<String> findJsguiWebappInSource() {
- // normally up 2 levels to where brooklyn-* folders are, then into ui
- // (but in rest projects it might be 3 up, and in some IDEs we might run from parent dirs.)
- // TODO could also look in maven repo ?
- return findFirstMatchingFile(
- "../../brooklyn-ui/src/main/webapp",
- "../../../brooklyn-ui/src/main/webapp",
- "../brooklyn-ui/src/main/webapp",
- "./brooklyn-ui/src/main/webapp",
- "../../brooklyn-ui/target/*.war",
- "../../..brooklyn-ui/target/*.war",
- "../brooklyn-ui/target/*.war",
- "./brooklyn-ui/target/*.war");
- }
-
/** look for the REST WAR file in common places, returning path to it if found, or null */
private static String findRestApiWar() {
// don't look at src/main/webapp here -- because classes won't be there!
@@ -432,6 +378,7 @@ public class BrooklynRestApiLauncher {
return Maybe.of(result.getAbsolutePath());
}
+ // duplicated in BrooklynWebServer (downstream, but no obvious util class to put it in and not worth creating)
/** create a directory with a simple index.html so we have some content being served up */
private static String createTempWebDirWithIndexHtml(String indexHtmlContent) {
File dir = Files.createTempDir();
@@ -443,5 +390,18 @@ public class BrooklynRestApiLauncher {
}
return dir.getAbsolutePath();
}
+ /** create WAR/ZIP as per {@link #createTempWebDirWithIndexHtml(String)} */
+ private static String createTempWarWithIndexHtml(String indexHtmlContent) {
+ File archive = ArchiveBuilder.zip().addDirContentsAt(
+ new File(createTempWebDirWithIndexHtml(indexHtmlContent)), ".").create();
+ archive.deleteOnExit();
+ return archive.getAbsolutePath();
+ }
+
+ public BrooklynRestApiLauncher withoutJsgui() {
+ // no-op method now, this is now only supported without the JS GUI as that is angular and OSGi
+ // method kept for compatibility
+ return this;
+ }
}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3602dcb8/rest/rest-server/src/test/java/org/apache/brooklyn/rest/CorsFilterLauncherTest.java
----------------------------------------------------------------------
diff --git a/rest/rest-server/src/test/java/org/apache/brooklyn/rest/CorsFilterLauncherTest.java b/rest/rest-server/src/test/java/org/apache/brooklyn/rest/CorsFilterLauncherTest.java
index 8197014..20a9865 100644
--- a/rest/rest-server/src/test/java/org/apache/brooklyn/rest/CorsFilterLauncherTest.java
+++ b/rest/rest-server/src/test/java/org/apache/brooklyn/rest/CorsFilterLauncherTest.java
@@ -201,8 +201,7 @@ public class CorsFilterLauncherTest extends BrooklynRestApiLauncherTestFixture {
} else {
BrooklynFeatureEnablement.disable(BrooklynFeatureEnablement.FEATURE_CORS_CXF_PROPERTY);
}
- BrooklynRestApiLauncher apiLauncher = baseLauncher()
- .withoutJsgui();
+ BrooklynRestApiLauncher apiLauncher = baseLauncher();
ManagementContext mgmt = LocalManagementContextForTests.builder(true)
.useAdditionalProperties(MutableMap.<String, Object>of(
BrooklynFeatureEnablement.FEATURE_CORS_CXF_PROPERTY, enable,