activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject activemq-artemis git commit: Clean up path handling in in the WebServerComponent a bit.
Date Wed, 06 Jan 2016 19:20:21 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/master 3e6dcd05e -> 2e8ce9889


Clean up path handling in in the WebServerComponent a bit.

- The if the web element's path attribute is configured with an absolute path like `path="/tmp/artemis/web"`
then use it as an absolute path instead of trying to make it a sub dir of artemis home.


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/2e8ce988
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/2e8ce988
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/2e8ce988

Branch: refs/heads/master
Commit: 2e8ce98891f38c62b3c2a4e8762349a50ed6bc32
Parents: 3e6dcd0
Author: Hiram Chirino <hiram@hiramchirino.com>
Authored: Wed Jan 6 14:20:14 2016 -0500
Committer: Hiram Chirino <hiram@hiramchirino.com>
Committed: Wed Jan 6 14:20:14 2016 -0500

----------------------------------------------------------------------
 .../artemis/component/WebServerComponent.java   | 22 +++++++++++++-------
 1 file changed, 14 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2e8ce988/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java
----------------------------------------------------------------------
diff --git a/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java
b/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java
index 05bf7fd..396c2d4 100644
--- a/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java
+++ b/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java
@@ -16,8 +16,6 @@
  */
 package org.apache.activemq.artemis.component;
 
-import java.net.URI;
-
 import org.apache.activemq.artemis.ActiveMQWebLogger;
 import org.apache.activemq.artemis.components.ExternalComponent;
 import org.apache.activemq.artemis.dto.AppDTO;
@@ -31,6 +29,11 @@ import org.eclipse.jetty.server.handler.HandlerList;
 import org.eclipse.jetty.server.handler.ResourceHandler;
 import org.eclipse.jetty.webapp.WebAppContext;
 
+import java.io.IOException;
+import java.net.URI;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
 public class WebServerComponent implements ExternalComponent {
 
    private Server server;
@@ -42,7 +45,6 @@ public class WebServerComponent implements ExternalComponent {
    @Override
    public void configure(ComponentDTO config, String artemisInstance, String artemisHome)
throws Exception {
       webServerConfig = (WebServerDTO) config;
-      String path = webServerConfig.path.startsWith("/") ? webServerConfig.path : "/" + webServerConfig.path;
       uri = new URI(webServerConfig.bind);
       server = new Server();
       ServerConnector connector = new ServerConnector(server);
@@ -53,9 +55,12 @@ public class WebServerComponent implements ExternalComponent {
 
       handlers = new HandlerList();
 
+      Path warDir = Paths.get(artemisHome != null ? artemisHome : ".")
+              .resolve( webServerConfig.path ).toAbsolutePath();
+
       if (webServerConfig.apps != null) {
          for (AppDTO app : webServerConfig.apps) {
-            deployWar(app.url, app.war, artemisHome, path);
+            deployWar(app.url, app.war, warDir);
             if (app.war.startsWith("jolokia")) {
                jolokiaUrl = webServerConfig.bind + "/" + app.url;
             }
@@ -64,11 +69,11 @@ public class WebServerComponent implements ExternalComponent {
 
       WebAppContext handler = new WebAppContext();
       handler.setContextPath("/");
-      handler.setResourceBase(artemisHome + path);
+      handler.setResourceBase(warDir.toString());
       handler.setLogUrlOnStart(true);
 
       ResourceHandler resourceHandler = new ResourceHandler();
-      resourceHandler.setResourceBase(artemisHome + path);
+      resourceHandler.setResourceBase(warDir.toString());
       resourceHandler.setDirectoriesListed(true);
       resourceHandler.setWelcomeFiles(new String[]{"index.html"});
 
@@ -99,7 +104,7 @@ public class WebServerComponent implements ExternalComponent {
       return server != null && server.isStarted();
    }
 
-   private void deployWar(String url, String warURL, String activeMQHome, String path) {
+   private void deployWar(String url, String warFile, Path warDirectory) throws IOException
{
       WebAppContext webapp = new WebAppContext();
       if (url.startsWith("/")) {
          webapp.setContextPath(url);
@@ -107,7 +112,8 @@ public class WebServerComponent implements ExternalComponent {
       else {
          webapp.setContextPath("/" + url);
       }
-      webapp.setWar(activeMQHome + path + "/" + warURL);
+
+      webapp.setWar(warDirectory.resolve(warFile).toString());
       handlers.addHandler(webapp);
    }
 }


Mime
View raw message