diff options
| author | Robert Gemmell <robbie@apache.org> | 2013-10-06 11:04:56 +0000 |
|---|---|---|
| committer | Robert Gemmell <robbie@apache.org> | 2013-10-06 11:04:56 +0000 |
| commit | 6b49962c50e5ebbe810ddbb562dc2b55a3c4de06 (patch) | |
| tree | e4c7e1227ec4214094cded08b4a8effe9c9dc024 | |
| parent | 9e1128eed479d269cd9700675a46dd979f26d40a (diff) | |
| download | qpid-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
11 files changed, 203 insertions, 52 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 + 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 @@ <!-- targets for downloading ivy and retrieving dependencies --> <target name="retrieve-dependencies" depends="load-ivy, configure-ivy, retrieve-optional-dependencies" unless="${ivy.dont.retrieve}"> <echo message="Resolving and retrieving dependencies..."/> - <ivy:resolve type="jar,bundle,war" file="${project.root}/ivy.retrieve.xml" conf="required"/> - <ivy:retrieve type="jar,bundle,war" conf="required" sync="true" + <ivy:resolve type="jar,bundle,zip" file="${project.root}/ivy.retrieve.xml" conf="required"/> + <ivy:retrieve type="jar,bundle,zip" conf="required" sync="true" pattern="${project.root}/lib/required/[artifact]-[revision].[ext]" /> </target> @@ -314,7 +314,7 @@ fail so long as Ivy is in at least one of the locations. --> <mkdir dir="${ivy.jar.dir}"/> <path id="ivy.lib.path"> - <fileset dir="${ivy.jar.dir}" includes="*.jar"/> + <fileset dir="${ivy.jar.dir}" includes="*${ivy.install.version}*.jar"/> </path> <taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/> 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 @@ <property name="gentools.src" value="${basedir}/gentools/src"/> <property name="generated.package" value="org/apache/qpid/framing" /> - <property name="version.file" location="${basedir}/target/classes/qpidversion.properties"/> <property file="${version.file}" prefix="old."/> <target name="check-version"> 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 @@ <dependency org="org.eclipse.jetty" name="jetty-security" rev="7.6.10.v20130312" transitive="false"/> <dependency org="org.eclipse.jetty" name="jetty-servlet" rev="7.6.10.v20130312" transitive="false"/> <dependency org="org.eclipse.jetty" name="jetty-util" rev="7.6.10.v20130312" transitive="false"/> - <dependency org="org.dojotoolkit" name="dojo-war" rev="1.8.3" transitive="false"/> <dependency org="xalan" name="xalan" rev="2.7.0" transitive="false"/> <dependency org="velocity" name="velocity" rev="1.4" transitive="false"/> <dependency org="velocity" name="velocity-dep" rev="1.4" transitive="false"/> + <dependency org="org.dojotoolkit" name="dojo" rev="1.8.3" transitive="false"> + <artifact name="dojo" type="zip"/> + </dependency> <!-- The following are optional dependencies, for modules providing optional functionlity or for use in optional build/test steps. Their optional status is usually indicative of licences diff --git a/qpid/java/pom.xml b/qpid/java/pom.xml index 843361fa33..027f8b5b62 100644 --- a/qpid/java/pom.xml +++ b/qpid/java/pom.xml @@ -62,6 +62,9 @@ <properties> <!-- dependency version numbers --> + <dojo-version>1.8.3</dojo-version> + + <!-- test dependency version numbers --> <junit-version>3.8.1</junit-version> <mockito-version>1.9.0</mockito-version> |
