You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2013/10/06 13:04:57 UTC

svn commit: r1529610 - in /qpid/trunk/qpid/java: ./ broker-plugins/management-http/ broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/ broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/pl...

Author: robbie
Date: Sun Oct  6 11:04:56 2013
New Revision: 1529610

URL: http://svn.apache.org/r1529610
Log:
QPID-5207, QPID-5048: use the dojo release zip instead of extracting files from the war

Added:
    qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/DojoHelper.java
    qpid/trunk/qpid/java/broker-plugins/management-http/src/main/resources-maven/
    qpid/trunk/qpid/java/broker-plugins/management-http/src/main/resources-maven/dojoconfig.properties
Modified:
    qpid/trunk/qpid/java/broker-plugins/management-http/build.xml
    qpid/trunk/qpid/java/broker-plugins/management-http/pom.xml
    qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
    qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/FileServlet.java
    qpid/trunk/qpid/java/build.deps
    qpid/trunk/qpid/java/common.xml
    qpid/trunk/qpid/java/common/build-generate-sources.xml
    qpid/trunk/qpid/java/ivy.retrieve.xml
    qpid/trunk/qpid/java/pom.xml

Modified: qpid/trunk/qpid/java/broker-plugins/management-http/build.xml
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-http/build.xml?rev=1529610&r1=1529609&r2=1529610&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/management-http/build.xml (original)
+++ qpid/trunk/qpid/java/broker-plugins/management-http/build.xml Sun Oct  6 11:04:56 2013
@@ -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" />

Modified: qpid/trunk/qpid/java/broker-plugins/management-http/pom.xml
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-http/pom.xml?rev=1529610&r1=1529609&r2=1529610&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/management-http/pom.xml (original)
+++ qpid/trunk/qpid/java/broker-plugins/management-http/pom.xml Sun Oct  6 11:04:56 2013
@@ -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>
 

Added: qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/DojoHelper.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/DojoHelper.java?rev=1529610&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/DojoHelper.java (added)
+++ qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/DojoHelper.java Sun Oct  6 11:04:56 2013
@@ -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;
+    }
+}

Modified: qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java?rev=1529610&r1=1529609&r2=1529610&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java (original)
+++ qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java Sun Oct  6 11:04:56 2013
@@ -313,6 +313,10 @@ public class HttpManagement extends Abst
         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");

Modified: qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/FileServlet.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/FileServlet.java?rev=1529610&r1=1529609&r2=1529610&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/FileServlet.java (original)
+++ qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/FileServlet.java Sun Oct  6 11:04:56 2013
@@ -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.HttpServletRes
 
 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 HttpSer
         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 HttpSer
                 response.setContentType(contentType);
             }
         }
-        URL resourceURL = getClass().getResource("/resources" + filename);
+
+        URL resourceURL = getClass().getResource(_resourcePathPrefix + filename);
         if(resourceURL != null)
         {
             response.setStatus(HttpServletResponse.SC_OK);

Added: qpid/trunk/qpid/java/broker-plugins/management-http/src/main/resources-maven/dojoconfig.properties
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-http/src/main/resources-maven/dojoconfig.properties?rev=1529610&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/management-http/src/main/resources-maven/dojoconfig.properties (added)
+++ qpid/trunk/qpid/java/broker-plugins/management-http/src/main/resources-maven/dojoconfig.properties Sun Oct  6 11:04:56 2013
@@ -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
+

Modified: qpid/trunk/qpid/java/build.deps
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/build.deps?rev=1529610&r1=1529609&r2=1529610&view=diff
==============================================================================
--- qpid/trunk/qpid/java/build.deps (original)
+++ qpid/trunk/qpid/java/build.deps Sun Oct  6 11:04:56 2013
@@ -57,7 +57,8 @@ jetty-servlet=lib/required/jetty-servlet
 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} ${common
 #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}

Modified: qpid/trunk/qpid/java/common.xml
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/common.xml?rev=1529610&r1=1529609&r2=1529610&view=diff
==============================================================================
--- qpid/trunk/qpid/java/common.xml (original)
+++ qpid/trunk/qpid/java/common.xml Sun Oct  6 11:04:56 2013
@@ -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"/>

Modified: qpid/trunk/qpid/java/common/build-generate-sources.xml
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/common/build-generate-sources.xml?rev=1529610&r1=1529609&r2=1529610&view=diff
==============================================================================
--- qpid/trunk/qpid/java/common/build-generate-sources.xml (original)
+++ qpid/trunk/qpid/java/common/build-generate-sources.xml Sun Oct  6 11:04:56 2013
@@ -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">

Modified: qpid/trunk/qpid/java/ivy.retrieve.xml
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/ivy.retrieve.xml?rev=1529610&r1=1529609&r2=1529610&view=diff
==============================================================================
--- qpid/trunk/qpid/java/ivy.retrieve.xml (original)
+++ qpid/trunk/qpid/java/ivy.retrieve.xml Sun Oct  6 11:04:56 2013
@@ -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

Modified: qpid/trunk/qpid/java/pom.xml
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/pom.xml?rev=1529610&r1=1529609&r2=1529610&view=diff
==============================================================================
--- qpid/trunk/qpid/java/pom.xml (original)
+++ qpid/trunk/qpid/java/pom.xml Sun Oct  6 11:04:56 2013
@@ -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>
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org