From 56e52f49aca2a837f244c44284ad22ad6d750e39 Mon Sep 17 00:00:00 2001 From: Claus Ibsen Date: Tue, 19 May 2015 11:21:42 +0200 Subject: [PATCH] #275: Just for fun using v2 hawtio console. --- console/pom.xml | 4 ++-- jube/src/main/java/io/fabric8/jube/main/Main.java | 7 +++++-- jube/src/main/java/io/fabric8/jube/main/RootServlet.java | 8 +------- .../test/java/io/fabric8/jube/main/ContextPathTest.java | 3 +-- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/console/pom.xml b/console/pom.xml index 3dba3b4..024a1df 100644 --- a/console/pom.xml +++ b/console/pom.xml @@ -35,8 +35,8 @@ io.hawt - hawtio-web - ${hawtio.version} + hawtio-war + 2.0-SNAPSHOT war diff --git a/jube/src/main/java/io/fabric8/jube/main/Main.java b/jube/src/main/java/io/fabric8/jube/main/Main.java index 1a72ee8..1242e5e 100644 --- a/jube/src/main/java/io/fabric8/jube/main/Main.java +++ b/jube/src/main/java/io/fabric8/jube/main/Main.java @@ -124,7 +124,7 @@ public static void main(final String[] args) throws Exception { //context.addServlet(servletHolder, "/kubernetes/api/*"); context.addServlet(WatchWebSocketServlet.class, "/api/*"); //context.addServlet(WatchWebSocketServlet.class, "/kubernetes/api/*"); - context.addServlet(new ServletHolder(new RootServlet()), "/"); + //context.addServlet(new ServletHolder(new RootServlet()), "/"); handlers.addHandler(context); @@ -297,6 +297,9 @@ private static void createWebapp(HandlerCollection handlers, Set foundUR System.out.println("adding web context path: /" + contextPath + " war: " + filePath); } WebAppContext webapp = new WebAppContext(); + if ("hawtio".equals(contextPath)) { + contextPath = ""; + } webapp.setContextPath("/" + contextPath); webapp.setWar("file://" + filePath); handlers.addHandler(webapp); @@ -320,7 +323,7 @@ public static String createContextPath(String uri) { if (contextPath.startsWith("hawtio-swag")) { contextPath = "hawtio-swagger"; } else if (contextPath.startsWith("hawtio-") || contextPath.startsWith("console-")) { - contextPath = "hawtio"; + contextPath = "/"; } return contextPath; } diff --git a/jube/src/main/java/io/fabric8/jube/main/RootServlet.java b/jube/src/main/java/io/fabric8/jube/main/RootServlet.java index 8dbbf33..e339e65 100644 --- a/jube/src/main/java/io/fabric8/jube/main/RootServlet.java +++ b/jube/src/main/java/io/fabric8/jube/main/RootServlet.java @@ -21,16 +21,10 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.eclipse.jetty.util.URIUtil; - public class RootServlet extends HttpServlet { @Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - // only redirect if its / to hawtio - if (req.getRequestURI().equals("/")) { - String url = URIUtil.addPaths(req.getRequestURI(), "hawtio"); - resp.sendRedirect(url); - } + // do not redirect as hawtio v2 console do not support using /hawtio as context-path yet } } diff --git a/jube/src/test/java/io/fabric8/jube/main/ContextPathTest.java b/jube/src/test/java/io/fabric8/jube/main/ContextPathTest.java index f651d6c..553b5b0 100644 --- a/jube/src/test/java/io/fabric8/jube/main/ContextPathTest.java +++ b/jube/src/test/java/io/fabric8/jube/main/ContextPathTest.java @@ -25,10 +25,9 @@ public class ContextPathTest { @Test public void testContextPath() throws Exception { - assertContextPath("file:/projects/jube/app/target/jube/maven/hawtio-web-1.4.27.war!/WEB-INF/web.xml", "hawtio"); + assertContextPath("file:/projects/jube/app/target/jube/maven/hawtio-web-1.4.27.war!/WEB-INF/web.xml", "/"); } - @Test public void testFilePath() throws Exception { assertFilePath("file:/projects/jube/app/target/jube/maven/hawtio-web-1.4.27.war!/WEB-INF/web.xml", "/projects/jube/app/target/jube/maven/hawtio-web-1.4.27.war");