summaryrefslogtreecommitdiff
path: root/qpid/java/broker-plugins
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
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')
-rw-r--r--qpid/java/broker-plugins/management-http/build.xml31
-rw-r--r--qpid/java/broker-plugins/management-http/pom.xml53
-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
6 files changed, 191 insertions, 45 deletions
diff --git a/qpid/java/broker-plugins/management-http/build.xml b/qpid/java/broker-plugins/management-http/build.xml
index 05af45a289..d921b91580 100644
--- a/qpid/java/broker-plugins/management-http/build.xml
+++ b/qpid/java/broker-plugins/management-http/build.xml
@@ -26,28 +26,27 @@
<property name="broker.plugin" value="true"/>
- <property name="broker-plugins-management-http.libs" value="" />
-
<import file="../../module.xml" />
- <!-- Flagfile used to determine if uwar needs to be done. ._ is part of Ant's defaultexcludes so wont appear bundles -->
- <property name="dojo.uptodate.flagfile" value="${module.classes}/resources/dojo/._dojouptodate.timestamp" />
+ <property name="module.manifest" value="${module.build}/MANIFEST.MF" />
+ <property name="dojo.config.file" value="${module.classes}/dojoconfig.properties" />
- <target name="precompile" depends="unwardojo" />
+ <target name="precompile" depends="generate-manifest, generate-dojo-config"/>
- <target name="unwardojo" depends="check-unwardojo.done" unless="unwardojo.done">
- <unwar src="${project.root}/${dojo}" dest="${module.classes}/resources/dojo">
- <patternset>
- <exclude name="META-INF/**" />
- <exclude name="WEB-INF/**" />
- <exclude name="**/*.uncompressed.js" />
- </patternset>
- </unwar>
- <touch file="${dojo.uptodate.flagfile}" />
+ <target name="generate-manifest">
+ <!-- Echos exactly as shown, so leave no spaces before/after lines -->
+ <echo file="${module.manifest}" append="false">Manifest-Version: 1.0
+Class-Path: dojo-${dojo-version}.zip
+</echo>
</target>
- <target name="check-unwardojo.done">
- <uptodate property="unwardojo.done" targetfile="${dojo.uptodate.flagfile}" srcfile="${project.root}/${dojo}" />
+ <target name="generate-dojo-config">
+ <!-- Echos exactly as shown, so leave no spaces before/after lines -->
+ <echo file="${dojo.config.file}" append="false">dojo-version=${dojo-version}
+dojo-path=/dojo-${dojo-version}/dojo
+dijit-path=/dojo-${dojo-version}/dijit
+dojox-path=/dojo-${dojo-version}/dojox
+</echo>
</target>
<target name="bundle" depends="bundle-tasks" />
diff --git a/qpid/java/broker-plugins/management-http/pom.xml b/qpid/java/broker-plugins/management-http/pom.xml
index f7942f85fa..dfc56ff3f1 100644
--- a/qpid/java/broker-plugins/management-http/pom.xml
+++ b/qpid/java/broker-plugins/management-http/pom.xml
@@ -150,6 +150,13 @@
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.dojotoolkit</groupId>
+ <artifactId>dojo</artifactId>
+ <version>${dojo-version}</version>
+ <type>zip</type>
+ </dependency>
+
<!-- test dependencies -->
<dependency>
<groupId>org.apache.qpid</groupId>
@@ -170,36 +177,28 @@
<include>resources/</include>
</includes>
</resource>
+ <resource>
+ <directory>src/main/resources-maven</directory>
+ <filtering>true</filtering>
+ </resource>
</resources>
<plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <!--version specified in parent pluginManagement -->
- <executions>
- <execution>
- <id>unpack-dojo</id>
- <phase>generate-resources</phase>
- <goals>
- <goal>unpack</goal>
- </goals>
- <configuration>
- <artifactItems>
- <artifactItem>
- <groupId>org.dojotoolkit</groupId>
- <artifactId>dojo-war</artifactId>
- <version>1.8.3</version>
- <type>war</type>
- <overWrite>false</overWrite>
- <outputDirectory>${project.build.directory}/classes/resources/dojo</outputDirectory>
- <excludes>META-INF/**,WEB-INF/**,**/*.uncompressed.js</excludes>
- </artifactItem>
- </artifactItems>
- </configuration>
- </execution>
- </executions>
- </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <!--version specified in parent pluginManagement -->
+ <configuration>
+ <archive>
+ <!-- add the dojo zip to the manifest Class-Path so that
+ it gets picked up when using classpath wildcard
+ expansion, which only collects .jar files -->
+ <manifestEntries>
+ <Class-Path>dojo-${dojo-version}.zip</Class-Path>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
</plugins>
</build>
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
+