From 6b49962c50e5ebbe810ddbb562dc2b55a3c4de06 Mon Sep 17 00:00:00 2001 From: Robert Gemmell Date: Sun, 6 Oct 2013 11:04:56 +0000 Subject: 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 --- qpid/java/broker-plugins/management-http/build.xml | 31 +++--- qpid/java/broker-plugins/management-http/pom.xml | 53 +++++----- .../qpid/server/management/plugin/DojoHelper.java | 116 +++++++++++++++++++++ .../server/management/plugin/HttpManagement.java | 4 + .../management/plugin/servlet/FileServlet.java | 27 ++++- .../src/main/resources-maven/dojoconfig.properties | 5 + qpid/java/build.deps | 5 +- qpid/java/common.xml | 6 +- qpid/java/common/build-generate-sources.xml | 1 - qpid/java/ivy.retrieve.xml | 4 +- qpid/java/pom.xml | 3 + 11 files changed, 203 insertions(+), 52 deletions(-) create mode 100644 qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/DojoHelper.java create mode 100644 qpid/java/broker-plugins/management-http/src/main/resources-maven/dojoconfig.properties (limited to 'qpid/java') 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 @@ - - - - + + - + - - - - - - - - - + + + Manifest-Version: 1.0 +Class-Path: dojo-${dojo-version}.zip + - - + + + dojo-version=${dojo-version} +dojo-path=/dojo-${dojo-version}/dojo +dijit-path=/dojo-${dojo-version}/dijit +dojox-path=/dojo-${dojo-version}/dojox + 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 @@ + + org.dojotoolkit + dojo + ${dojo-version} + zip + + org.apache.qpid @@ -170,36 +177,28 @@ resources/ + + src/main/resources-maven + true + - - org.apache.maven.plugins - maven-dependency-plugin - - - - unpack-dojo - generate-resources - - unpack - - - - - org.dojotoolkit - dojo-war - 1.8.3 - war - false - ${project.build.directory}/classes/resources/dojo - META-INF/**,WEB-INF/**,**/*.uncompressed.js - - - - - - + + org.apache.maven.plugins + maven-jar-plugin + + + + + + dojo-${dojo-version}.zip + + + + 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 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 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 + diff --git a/qpid/java/build.deps b/qpid/java/build.deps index 73691b6aec..c70a778c62 100644 --- a/qpid/java/build.deps +++ b/qpid/java/build.deps @@ -57,7 +57,8 @@ jetty-servlet=lib/required/jetty-servlet-7.6.10.v20130312.jar jetty-websocket=lib/required/jetty-websocket-7.6.10.v20130312.jar servlet-api=${geronimo-servlet} -dojo=lib/required/dojo-war-1.8.3.war +dojo-version=1.8.3 +dojo=lib/required/dojo-${dojo-version}.zip jackson-core=lib/required/jackson-core-asl-1.9.0.jar jackson-mapper=lib/required/jackson-mapper-asl-1.9.0.jar @@ -79,7 +80,7 @@ broker-core.libs=${commons-cli} ${commons-logging} ${log4j} ${slf4j-log4j} \ #Borrow the broker-core libs, hack for release binary generation broker.libs=${broker-core.libs} -broker-plugins-management-http.libs=${jetty} ${jetty-continuation} ${jetty-security} ${jetty-http} ${jetty-io} ${jetty-servlet} ${jetty-util} ${servlet-api} ${jackson-core} ${jackson-mapper} +broker-plugins-management-http.libs=${jetty} ${jetty-continuation} ${jetty-security} ${jetty-http} ${jetty-io} ${jetty-servlet} ${jetty-util} ${servlet-api} ${jackson-core} ${jackson-mapper} ${dojo} broker-plugins.libs=${log4j} ${commons-configuration.libs} test.libs=${slf4j-log4j} ${log4j} ${junit} ${slf4j-api} ${mockito-all} diff --git a/qpid/java/common.xml b/qpid/java/common.xml index 46c41a7a1f..005dd261b4 100644 --- a/qpid/java/common.xml +++ b/qpid/java/common.xml @@ -286,8 +286,8 @@ - - + @@ -314,7 +314,7 @@ fail so long as Ivy is in at least one of the locations. --> - + diff --git a/qpid/java/common/build-generate-sources.xml b/qpid/java/common/build-generate-sources.xml index 2040d8e14a..339887f3dd 100644 --- a/qpid/java/common/build-generate-sources.xml +++ b/qpid/java/common/build-generate-sources.xml @@ -50,7 +50,6 @@ - diff --git a/qpid/java/ivy.retrieve.xml b/qpid/java/ivy.retrieve.xml index faecfb2dbf..305f3d3085 100644 --- a/qpid/java/ivy.retrieve.xml +++ b/qpid/java/ivy.retrieve.xml @@ -68,10 +68,12 @@ - + + + + 1.8.3 + + 3.8.1 1.9.0 -- cgit v1.2.1