summaryrefslogtreecommitdiff
path: root/qpid/java/broker-plugins/management-http/src/main
diff options
context:
space:
mode:
authorRobert Gemmell <robbie@apache.org>2013-10-06 11:04:56 +0000
committerRobert Gemmell <robbie@apache.org>2013-10-06 11:04:56 +0000
commit6b49962c50e5ebbe810ddbb562dc2b55a3c4de06 (patch)
treee4c7e1227ec4214094cded08b4a8effe9c9dc024 /qpid/java/broker-plugins/management-http/src/main
parent9e1128eed479d269cd9700675a46dd979f26d40a (diff)
downloadqpid-python-6b49962c50e5ebbe810ddbb562dc2b55a3c4de06.tar.gz
QPID-5207, QPID-5048: use the dojo release zip instead of extracting files from the war
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1529610 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker-plugins/management-http/src/main')
-rw-r--r--qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/DojoHelper.java116
-rw-r--r--qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java4
-rw-r--r--qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/FileServlet.java27
-rw-r--r--qpid/java/broker-plugins/management-http/src/main/resources-maven/dojoconfig.properties5
4 files changed, 150 insertions, 2 deletions
diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/DojoHelper.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/DojoHelper.java
new file mode 100644
index 0000000000..2349bb48a7
--- /dev/null
+++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/DojoHelper.java
@@ -0,0 +1,116 @@
+/*
+ * 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.qpid.server.management.plugin;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+import java.util.Properties;
+
+public class DojoHelper
+{
+ private static final Logger _logger = LoggerFactory.getLogger(DojoHelper.class);
+
+ public static final String VERSION_FILE = "dojoconfig.properties";
+ public static final String DOJO_VERSION_PROPERTY = "dojo-version";
+ public static final String DOJO_PATH_PROPERTY = "dojo-path";
+ public static final String DIJIT_PATH_PROPERTY = "dijit-path";
+ public static final String DOJOX_PATH_PROPERTY = "dojox-path";
+
+ private static String _version = "undefined";
+ private static String _dojoPath = "/dojo-undefined/dojo";
+ private static String _dijitPath = "/dojo-undefined/dijit";
+ private static String _dojoxPath = "/dojo-undefined/dojox";
+
+ // Loads the value from the properties file.
+ static
+ {
+ Properties props = new Properties();
+
+ try
+ {
+ InputStream propertyStream = DojoHelper.class.getClassLoader().getResourceAsStream(VERSION_FILE);
+ if (propertyStream == null)
+ {
+ _logger.warn("Unable to find resource " + VERSION_FILE + " from classloader");
+ }
+ else
+ {
+ props.load(propertyStream);
+
+ if (_logger.isDebugEnabled())
+ {
+ _logger.debug("Dumping Dojo Config:");
+ for (Map.Entry<Object, Object> entry : props.entrySet())
+ {
+ _logger.debug("Property: " + entry.getKey() + " Value: " + entry.getValue());
+ }
+
+ _logger.debug("End of property dump");
+ }
+
+ _version = readPropertyValue(props, DOJO_VERSION_PROPERTY, _version);
+ _dojoPath = readPropertyValue(props, DOJO_PATH_PROPERTY, _dojoPath);
+ _dijitPath = readPropertyValue(props, DIJIT_PATH_PROPERTY, _dijitPath);
+ _dojoxPath = readPropertyValue(props, DOJOX_PATH_PROPERTY, _dojoxPath);
+ }
+ }
+ catch (IOException e)
+ {
+ // Log a warning about this and leave the values initialized to unknown.
+ _logger.error("Exception loading " + VERSION_FILE + " resource:", e);
+ }
+ }
+
+ private static String readPropertyValue(Properties props, String propertyName, String defaultValue)
+ {
+ String value = props.getProperty(propertyName);
+ if (value == null)
+ {
+ return defaultValue;
+ }
+
+ return value;
+ }
+
+ public static String getDojoVersion()
+ {
+ return _version;
+ }
+
+ public static String getDojoPath()
+ {
+ return _dojoPath;
+ }
+
+ public static String getDijitPath()
+ {
+ return _dijitPath;
+ }
+
+ public static String getDojoxPath()
+ {
+ return _dojoxPath;
+ }
+}
diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
index 027ab8f8bc..f1cb7c37eb 100644
--- a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
+++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
@@ -313,6 +313,10 @@ public class HttpManagement extends AbstractPluginAdapter implements HttpManagem
root.addServlet(new ServletHolder(new DefinedFileServlet("index.html")), "/");
root.addServlet(new ServletHolder(new LogoutServlet()), "/logout");
+ root.addServlet(new ServletHolder(new FileServlet(DojoHelper.getDojoPath(), true)), "/dojo/dojo/*");
+ root.addServlet(new ServletHolder(new FileServlet(DojoHelper.getDijitPath(), true)), "/dojo/dijit/*");
+ root.addServlet(new ServletHolder(new FileServlet(DojoHelper.getDojoxPath(), true)), "/dojo/dojox/*");
+
root.addServlet(new ServletHolder(FileServlet.INSTANCE), "*.js");
root.addServlet(new ServletHolder(FileServlet.INSTANCE), "*.css");
root.addServlet(new ServletHolder(FileServlet.INSTANCE), "*.html");
diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/FileServlet.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/FileServlet.java
index 24e5e7c049..7e97b32c0c 100644
--- a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/FileServlet.java
+++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/FileServlet.java
@@ -26,6 +26,7 @@ import java.net.URL;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
@@ -34,6 +35,8 @@ import javax.servlet.http.HttpServletResponse;
public class FileServlet extends HttpServlet
{
+ private static final String RESOURCES_PREFIX = "/resources";
+
public static final FileServlet INSTANCE = new FileServlet();
private static final Map<String, String> CONTENT_TYPES;
@@ -52,14 +55,33 @@ public class FileServlet extends HttpServlet
CONTENT_TYPES = Collections.unmodifiableMap(contentTypes);
}
+ private final String _resourcePathPrefix;
+ private boolean _usePathInfo;
public FileServlet()
{
+ _resourcePathPrefix = RESOURCES_PREFIX;
+ _usePathInfo = false;
+ }
+
+ public FileServlet(String resourcePathPrefix, boolean usePathInfo)
+ {
+ _resourcePathPrefix = resourcePathPrefix;
+ _usePathInfo = usePathInfo;
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
- String filename = request.getServletPath();
+ String filename = null;
+ if(_usePathInfo)
+ {
+ filename = request.getPathInfo();
+ }
+ else
+ {
+ filename = request.getServletPath();
+ }
+
if(filename.contains("."))
{
String suffix = filename.substring(filename.lastIndexOf('.')+1);
@@ -69,7 +91,8 @@ public class FileServlet extends HttpServlet
response.setContentType(contentType);
}
}
- URL resourceURL = getClass().getResource("/resources" + filename);
+
+ URL resourceURL = getClass().getResource(_resourcePathPrefix + filename);
if(resourceURL != null)
{
response.setStatus(HttpServletResponse.SC_OK);
diff --git a/qpid/java/broker-plugins/management-http/src/main/resources-maven/dojoconfig.properties b/qpid/java/broker-plugins/management-http/src/main/resources-maven/dojoconfig.properties
new file mode 100644
index 0000000000..153b568482
--- /dev/null
+++ b/qpid/java/broker-plugins/management-http/src/main/resources-maven/dojoconfig.properties
@@ -0,0 +1,5 @@
+dojo-version=${dojo-version}
+dojo-path=/dojo-${dojo-version}/dojo
+dijit-path=/dojo-${dojo-version}/dijit
+dojox-path=/dojo-${dojo-version}/dojox
+