click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r797998 - in /incubator/click/trunk/click: build/ documentation/docs/ documentation/docs/developer-guide/ documentation/xdocs/src/docbook/click/ extras/src/org/apache/click/extras/gae/ extras/src/org/apache/click/extras/service/ framework/s...
Date Sun, 26 Jul 2009 22:45:44 GMT
Author: sabob
Date: Sun Jul 26 22:45:43 2009
New Revision: 797998

URL: http://svn.apache.org/viewvc?rev=797998&view=rev
Log:
deploy resources from META-INF/resources instead of META-INF/web. CLK-570

Modified:
    incubator/click/trunk/click/build/build.xml
    incubator/click/trunk/click/documentation/docs/developer-guide/contributing.html
    incubator/click/trunk/click/documentation/docs/roadmap-changes.html
    incubator/click/trunk/click/documentation/docs/upgrade-path.html
    incubator/click/trunk/click/documentation/xdocs/src/docbook/click/chapter-configuration.xml
    incubator/click/trunk/click/extras/src/org/apache/click/extras/gae/GoogleAppEngineListener.java
    incubator/click/trunk/click/extras/src/org/apache/click/extras/service/FreemarkerTemplateService.java
    incubator/click/trunk/click/framework/src/org/apache/click/service/VelocityTemplateService.java
    incubator/click/trunk/click/framework/src/org/apache/click/service/XmlConfigService.java

Modified: incubator/click/trunk/click/build/build.xml
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/build/build.xml?rev=797998&r1=797997&r2=797998&view=diff
==============================================================================
--- incubator/click/trunk/click/build/build.xml (original)
+++ incubator/click/trunk/click/build/build.xml Sun Jul 26 22:45:43 2009
@@ -708,7 +708,7 @@
             todir="documentation/docs/click-api/org/apache/click/control"/>
       <copy file="documentation/images/inline-paginator.png"
             todir="documentation/docs/extras-api/org/apache/click/extras/control"/>
-      <copy file="extras/src/META-INF/web/click/colorpicker/images/color-picker.png"
+      <copy file="extras/src/META-INF/resources/click/colorpicker/images/color-picker.png"
             todir="documentation/docs/extras-api/org/apache/click/extras/control/colorpicker"/>
       <copy file="documentation/images/tree.png"
             todir="documentation/docs/extras-api/org/apache/click/extras/tree"/>

Modified: incubator/click/trunk/click/documentation/docs/developer-guide/contributing.html
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/documentation/docs/developer-guide/contributing.html?rev=797998&r1=797997&r2=797998&view=diff
==============================================================================
--- incubator/click/trunk/click/documentation/docs/developer-guide/contributing.html (original)
+++ incubator/click/trunk/click/documentation/docs/developer-guide/contributing.html Sun Jul
26 22:45:43 2009
@@ -75,11 +75,8 @@
         Click automatically deploys configured classpath resources to the <tt class="blue">/click</tt>
         directory at startup (existing files will not be overwritten).
         <p/>
-        To enable your controls to deploy resources on startup either place the resources
-        in the Click Extras JAR folder 'META-INF/web/' or use the Control
-        <a href="../click-api/org/apache/click/Control.html#on-deploy">onDeploy()</a>
method.
-        Click extra controls which use the <tt>onDeploy</tt> method should be
registered
-        in Click Extras JAR <tt>extras-controls.xml</tt> file. See the section
+        To enable your controls to deploy resources on startup place the resources
+        in the Click Extras JAR directory 'META-INF/resources/'. See the section
         <a href="../user-guide/html/ch04s03.html#deploying-custom-resources">Deploying
Custom Resources</a>
         for more information on resource deployment.
 

Modified: incubator/click/trunk/click/documentation/docs/roadmap-changes.html
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/documentation/docs/roadmap-changes.html?rev=797998&r1=797997&r2=797998&view=diff
==============================================================================
--- incubator/click/trunk/click/documentation/docs/roadmap-changes.html (original)
+++ incubator/click/trunk/click/documentation/docs/roadmap-changes.html Sun Jul 26 22:45:43
2009
@@ -201,6 +201,13 @@
           [<a target="_blank" href="https://issues.apache.org/jira/browse/CLK-571">571</a>].
       </li>
       <li class="change">
+          Added support to deploy resources inside JARs from the Servlet 3.0 compliant
+          location, <tt>META-INF/resources</tt>. If Click is running on a Servlet
3.0
+          server, it won't deploy its resources, but rely on the container to
+          serve the resources directly
+          [<a target="_blank" href="https://issues.apache.org/jira/browse/CLK-570">570</a>].
+      </li>
+      <li class="change">
           Added new Calendar popup to DateField. This Calendar popup uses
           <a target="_blank" class="external" href="http://code.google.com/p/calendardateselect/">Calendar
Date Select</a>
           which is based on the Prototype JavaScript library.

Modified: incubator/click/trunk/click/documentation/docs/upgrade-path.html
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/documentation/docs/upgrade-path.html?rev=797998&r1=797997&r2=797998&view=diff
==============================================================================
--- incubator/click/trunk/click/documentation/docs/upgrade-path.html (original)
+++ incubator/click/trunk/click/documentation/docs/upgrade-path.html Sun Jul 26 22:45:43 2009
@@ -92,6 +92,27 @@
           <a href="click-api/org/apache/click/Control.html#getHeadElements()">Control.getHeadElements()</a>
           and <a href="click-api/org/apache/click/Page.html#getHeadElements()">Page.getHeadElements()</a>.
       </li>
+      <li class="change">
+          Deprecated methods: <a href="click-api/org/apache/click/Page.html#getPageImports()">Page.getPageImports()</a>
+          and <a href="click-api/org/apache/click/Page.html#setPageImports(org.apache.click.util.PageImports)">Page.setPageImports()</a>.
+          These methods have been deprecated in favor of
+          <a href="click-api/org/apache/click/Page.html#getHeadElements()">Page.getHeadElements()</a>.
+      </li>
+      <li class="change">
+          Click automatically deploy resources from the classpath that are located
+          under the directory <tt>META-INF/web</tt>.
+          <p/>
+          The Servlet 3.0 specification introduced a similar concept where resources
+          can be packaged in a JAR and served directly without having to be
+          deployed.
+          <p/>
+          Click 2.1.0 aligns with Servlet 3.0 in that resources are now also deployed
+          from the location <tt>META-INF/resources</tt>.
+          <p/>
+          For backwards compatibility Click will still deploy resources from
+          <tt>META-INF/web</tt>, however it is highly recommended to use the
new
+          Servlet 3.0 location instead.
+      </li>
     </ul>
   </dd>
 

Modified: incubator/click/trunk/click/documentation/xdocs/src/docbook/click/chapter-configuration.xml
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/documentation/xdocs/src/docbook/click/chapter-configuration.xml?rev=797998&r1=797997&r2=797998&view=diff
==============================================================================
--- incubator/click/trunk/click/documentation/xdocs/src/docbook/click/chapter-configuration.xml
(original)
+++ incubator/click/trunk/click/documentation/xdocs/src/docbook/click/chapter-configuration.xml
Sun Jul 26 22:45:43 2009
@@ -1032,7 +1032,7 @@
       <title>Deploying Custom Resources</title>
 
       <para> Click supports two ways of deploying pre-configured resources
-      (templates, stylesheets, JavaScript etc.) from a Jar to a web applications.
+      (templates, stylesheets, JavaScript etc.) from a Jar to a web application.
       </para>
 
       <orderedlist>
@@ -1044,8 +1044,14 @@
           </para>
         </listitem>
         <listitem>
-          <para> By packaging the resources (stylesheets, JavaScript, Images etc.)
-          into a special folder called <emphasis>'META-INF/web'</emphasis>.
+          <para>By packaging the resources (stylesheets, JavaScript, Images etc.)
+          into a special folder called <emphasis>'META-INF/resources'</emphasis>.
+          Please note that if Click is executing inside a Servlet 3.0 compliant
+          server, it won't deploy its resources. Instead it will rely on the
+          Servlet 3.0 feature where if the server cannot find a resource
+          in the root directory of the webapp, it will look for the resource
+          under <emphasis>'META-INF/resources'</emphasis>, and if it is found,
+          serve it up.
           </para>
         </listitem>
       </orderedlist>
@@ -1055,14 +1061,14 @@
       </para>
 
       <para>When Click starts up, it scans each Jar in the classpath for
-      specially marked entries starting with 'META-INF/web/'. (Please note that
-      even though Click will scan the entire classpath it is strongly recommended
-      to host your Jar files inside your WAR lib folder e.g. WEB-INF/lib. Sharing
-      Jars on the classpath can lead to class loading issues.)
+      specially marked entries starting with 'META-INF/resources/'. (Please note
+      that even though Click will scan the entire classpath it is strongly
+      recommended to host your Jar files under your WAR lib folder e.g. WEB-INF/lib.
+      Sharing Jars on the classpath can lead to class loading issues.)
       </para>
 
-      <para>Click will then copy all files found under 'META-INF/web/' to the web
-      application folder.
+      <para>Click will then copy all files found under 'META-INF/resources/' to
+      the root directory of the webapp.
       </para>
 
       <para>
@@ -1071,10 +1077,10 @@
 
       <itemizedlist>
         <listitem>
-          <para>META-INF/web/mycorp/edit_customer.js</para>
+          <para>META-INF/resources/mycorp/edit_customer.js</para>
         </listitem>
         <listitem>
-          <para>META-INF/web/mycorp/edit_customer.css</para>
+          <para>META-INF/resources/mycorp/edit_customer.css</para>
         </listitem>
         <listitem>
           <para>mycorp/pages/EditCustomerPage.class</para>

Modified: incubator/click/trunk/click/extras/src/org/apache/click/extras/gae/GoogleAppEngineListener.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/extras/src/org/apache/click/extras/gae/GoogleAppEngineListener.java?rev=797998&r1=797997&r2=797998&view=diff
==============================================================================
--- incubator/click/trunk/click/extras/src/org/apache/click/extras/gae/GoogleAppEngineListener.java
(original)
+++ incubator/click/trunk/click/extras/src/org/apache/click/extras/gae/GoogleAppEngineListener.java
Sun Jul 26 22:45:43 2009
@@ -128,9 +128,10 @@
  *
  * <h3>Deployment issues</h3>
  *
- * On application startup, Click automatically deploys all its JavaScript and
- * CSS resources to the "<tt>/click</tt>" folder. Since GAE doesn't allow
- * writing to disk, Click cannot automatically deploy its resources.
+ * On application startup, Click automatically deploys all its JavaScript, CSS
+ * and image resources to the "<tt>/click</tt>" folder in the root directory
of
+ * the webapp. Since GAE doesn't allow writing to disk, Click cannot
+ * automatically deploy its resources.
  * <p/>
  * Instead you will have to manually add Click's resources in your GAE
  * application's "<tt>/war</tt>" folder. To do this create a <tt>click</tt>
@@ -138,8 +139,8 @@
  * <p/>
  * Next you need to copy the resources from the click-core.X.X.X.jar and
  * click-extras.X.X.X.jar. Use your favorite IDE or ZIP utility to open the
- * jars and navigate to "<tt>META-INF/web/</tt>" where you will find the
- * "<tt>/click</tt>" folder with all the resources packaged for that jar. Simple
+ * jars and navigate to "<tt>META-INF/resources/</tt>" where you will find the
+ * "<tt>/click</tt>" folder with all the resources packaged for that jar. Simply
  * copy the content of the "<tt>/click</tt>" folder to your GAE folder:
  * "<tt>/war/click</tt>".
  */

Modified: incubator/click/trunk/click/extras/src/org/apache/click/extras/service/FreemarkerTemplateService.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/extras/src/org/apache/click/extras/service/FreemarkerTemplateService.java?rev=797998&r1=797997&r2=797998&view=diff
==============================================================================
--- incubator/click/trunk/click/extras/src/org/apache/click/extras/service/FreemarkerTemplateService.java
(original)
+++ incubator/click/trunk/click/extras/src/org/apache/click/extras/service/FreemarkerTemplateService.java
Sun Jul 26 22:45:43 2009
@@ -246,10 +246,10 @@
         String templatePath = page.getTemplate();
 
         if (!deployedErrorTemplate && templatePath.equals(ERROR_PAGE_PATH)) {
-            templatePath = "META-INF/web" + ERROR_PAGE_PATH;
+            templatePath = "META-INF/resources" + ERROR_PAGE_PATH;
         }
         if (!deployedErrorTemplate && templatePath.equals(NOT_FOUND_PAGE_PATH)) {
-            templatePath = "META-INF/web" + NOT_FOUND_PAGE_PATH;
+            templatePath = "META-INF/resources" + NOT_FOUND_PAGE_PATH;
         }
 
         // Get the template object

Modified: incubator/click/trunk/click/framework/src/org/apache/click/service/VelocityTemplateService.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/src/org/apache/click/service/VelocityTemplateService.java?rev=797998&r1=797997&r2=797998&view=diff
==============================================================================
--- incubator/click/trunk/click/framework/src/org/apache/click/service/VelocityTemplateService.java
(original)
+++ incubator/click/trunk/click/framework/src/org/apache/click/service/VelocityTemplateService.java
Sun Jul 26 22:45:43 2009
@@ -318,10 +318,10 @@
         String templatePath = page.getTemplate();
 
         if (!deployedErrorTemplate && templatePath.equals(ERROR_PAGE_PATH)) {
-            templatePath = "META-INF/web" + ERROR_PAGE_PATH;
+            templatePath = "META-INF/resources" + ERROR_PAGE_PATH;
         }
         if (!deployedErrorTemplate && templatePath.equals(NOT_FOUND_PAGE_PATH)) {
-            templatePath = "META-INF/web" + NOT_FOUND_PAGE_PATH;
+            templatePath = "META-INF/resources" + NOT_FOUND_PAGE_PATH;
         }
 
         // May throw parsing error if template could not be obtained

Modified: incubator/click/trunk/click/framework/src/org/apache/click/service/XmlConfigService.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/src/org/apache/click/service/XmlConfigService.java?rev=797998&r1=797997&r2=797998&view=diff
==============================================================================
--- incubator/click/trunk/click/framework/src/org/apache/click/service/XmlConfigService.java
(original)
+++ incubator/click/trunk/click/framework/src/org/apache/click/service/XmlConfigService.java
Sun Jul 26 22:45:43 2009
@@ -1237,7 +1237,7 @@
             deployControls(rootElm);
             deployControlSets(rootElm);
 
-            deployAutoFiles();
+            deployResourcesOnClasspath();
         } else {
             String msg = "Could not auto deploy files to 'click' web folder."
                 + " You may need to manually include click resources in your"
@@ -1247,73 +1247,101 @@
     }
 
     /**
-     * Deploy from jars and directories all files that are specified in the
-     * folder 'META-INF/web'.
+     * Deploy from the classpath all resources found under the directory
+     * 'META-INF/resources/'. For backwards compatibility resources under the
+     * directory 'META-INF/web/' are also deployed.
      * <p/>
      * Only jars and folders available on the classpath are scanned.
      *
-     * @throws java.lang.Exception if the files cannot be deployed
+     * @throws java.lang.IOException if the resources cannot be deployed
      */
-    private void deployAutoFiles() throws Exception {
+    private void deployResourcesOnClasspath() throws IOException {
 
-        // Find all jars under WEB-INF/lib and deploy all resources from these jars
         long startTime = System.currentTimeMillis();
 
         ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
 
-        Enumeration en = classLoader.getResources("META-INF/web");
+        // Find all jars and directories on the classpath that contains the
+        // directory "META-INF/resources/", and deploy those resources
+        String resourceDirectory = "META-INF/resources/";
+        Enumeration<URL> en = classLoader.getResources(resourceDirectory);
         while (en.hasMoreElements()) {
-            URL url = (URL) en.nextElement();
-            String path = url.getFile();
+            URL url = en.nextElement();
+            deployResourcesOnClasspath(url, resourceDirectory);
+        }
 
-            // Decode the url, esp on Windows where file paths can have their
-            // spaces encoded. decodeURL will convert C:\Program%20Files\project
-            // to C:\Program Files\project
-            path = ClickUtils.decodeURL(path);
+        // For backward compatibility, find all jars and directories on the
+        // classpath that contains the directory "META-INF/web/", and deploy those
+        // resources
+        resourceDirectory = "META-INF/web/";
+        en = classLoader.getResources(resourceDirectory);
+        while (en.hasMoreElements()) {
+            URL url = en.nextElement();
+            deployResourcesOnClasspath(url, resourceDirectory);
+        }
 
-            // Strip file prefix
-            if (path.startsWith("file:")) {
-                path = path.substring(5);
-            }
+        //if (logService.isTraceEnabled()) {
+            logService.info("deployed files from jars and folders - "
+                + (System.currentTimeMillis() - startTime) + " ms");
+        //}
+    }
 
-            String jarPath = null;
+    /**
+     * Deploy from the url all resources found under the prefix.
+     *
+     * @param url the url of the jar or folder which resources to deploy
+     * @param resourceDirectory the directory under which resources are found
+     * @throws IOException if resources from the url cannot be deployed
+     */
+    private void deployResourcesOnClasspath(URL url, String resourceDirectory)
+        throws IOException {
 
-            // Check if path represents a jar
-            if (path.indexOf('!') > 0) {
-                jarPath = path.substring(0, path.indexOf('!'));
+        String path = url.getFile();
 
-                File jar = new File(jarPath);
+        // Decode the url, esp on Windows where file paths can have their
+        // spaces encoded. decodeURL will convert C:\Program%20Files\project
+        // to C:\Program Files\project
+        path = ClickUtils.decodeURL(path);
 
-                if (jar.exists()) {
-                    deployFilesInJar(jar);
+        // Strip file prefix
+        if (path.startsWith("file:")) {
+            path = path.substring(5);
+        }
+
+        String jarPath = null;
+
+        // Check if path represents a jar
+        if (path.indexOf('!') > 0) {
+            jarPath = path.substring(0, path.indexOf('!'));
+
+            File jar = new File(jarPath);
+
+            if (jar.exists()) {
+                deployFilesInJar(jar, resourceDirectory);
 
-                } else {
-                    logService.error("Could not deploy the jar '" + jarPath
-                        + "'. Please ensure this file exists in the specified"
-                        + " location.");
-                }
             } else {
-                File dir = new File(path);
-                deployFilesInDir(dir);
+                logService.error("Could not deploy the jar '" + jarPath +
+                    "'. Please ensure this file exists in the specified" +
+                    " location.");
             }
-        }
-
-        if (logService.isTraceEnabled()) {
-            logService.trace("deployed files from jars and folders - "
-                + (System.currentTimeMillis() - startTime) + " ms");
+        } else {
+            File dir = new File(path);
+            deployFilesInDir(dir, resourceDirectory);
         }
     }
 
     /**
-     * Deploy files from the specified directory.
-     * <p/>
-     * Only files specified in the folder 'META-INF/web' will be deployed.
+     * Deploy files from the specified directory which are stored under the given
+     * resourceDirectory.
      *
      * @param dir the directory which resources will be deployed
-     * @throws java.lang.Exception if for some reason the files cannot be
+     * @param resourceDirectory the directory under which resources are found
+     * @throws java.lang.IOException if for some reason the files cannot be
      * deployed
      */
-    private void deployFilesInDir(File dir) throws Exception {
+    private void deployFilesInDir(File dir, String resourceDirectory)
+        throws IOException {
+
         if (dir == null) {
             throw new IllegalArgumentException("Dir cannot be null");
         }
@@ -1329,12 +1357,12 @@
 
         boolean logFeedback = true;
         while (files.hasNext()) {
-            // file example -> META-INF/web/click/table.css
+            // file example -> META-INF/resources/click/table.css
             File file = (File) files.next();
             String fileName = file.getCanonicalPath().replace('\\', '/');
 
-            // Only deploy resources from "META-INF/web/"
-            int pathIndex = fileName.indexOf("META-INF/web/");
+            // Only deploy resources from "META-INF/resources/"
+            int pathIndex = fileName.indexOf(resourceDirectory);
             if (pathIndex != -1) {
                 if (logFeedback && logService.isTraceEnabled()) {
                     logService.trace("deploy files from folder -> "
@@ -1344,21 +1372,23 @@
                     logFeedback = false;
                 }
                 fileName = fileName.substring(pathIndex);
-                deployFile(fileName, "META-INF/web/");
+                deployFile(fileName, resourceDirectory);
             }
         }
     }
 
     /**
-     * Deploy files from the specified jar.
-     * <p/>
-     * Only files specified in the folder 'META-INF/web' will be deployed.
+     * Deploy files from the specified jar which are stored under the given
+     * resourceDirectory.
      *
      * @param jar the jar which resources will be deployed
-     * @throws java.lang.Exception if for some reason the files cannot be
+     * @param resourceDirectory the directory under which resources are found
+     * @throws java.lang.IOException if for some reason the files cannot be
      * deployed
      */
-    private void deployFilesInJar(File jar) throws Exception {
+    private void deployFilesInJar(File jar, String resourceDirectory)
+        throws IOException {
+
         if (jar == null) {
             throw new IllegalArgumentException("Jar cannot be null");
         }
@@ -1376,11 +1406,11 @@
             // from jar
             boolean logFeedback = true;
             while ((jarEntry = jarInputStream.getNextJarEntry()) != null) {
-                // jarEntryName example -> META-INF/web/click/table.css
+                // jarEntryName example -> META-INF/resources/click/table.css
                 String jarEntryName = jarEntry.getName();
 
-                // Only deploy resources from "META-INF/web/"
-                int pathIndex = jarEntryName.indexOf("META-INF/web/");
+                // Only deploy resources from "META-INF/resources/"
+                int pathIndex = jarEntryName.indexOf(resourceDirectory);
                 if (pathIndex == 0) {
                     if (logFeedback && logService.isTraceEnabled()) {
                         logService.trace("deploy files from jar -> "
@@ -1389,7 +1419,7 @@
                         // Only provide feedback once per jar
                         logFeedback = false;
                     }
-                    deployFile(jarEntryName, "META-INF/web/");
+                    deployFile(jarEntryName, resourceDirectory);
                 }
             }
         } finally {



Mime
View raw message