You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2012/11/02 18:16:24 UTC

[3/4] git commit: Deprecate InitializationPriority.IMMEDIATE and simplify some other APIs

Deprecate InitializationPriority.IMMEDIATE and simplify some other APIs


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/fdeec355
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/fdeec355
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/fdeec355

Branch: refs/heads/5.4-js-rewrite
Commit: fdeec355f17d7b2a581de95402e8b8a7c4d91220
Parents: 23d4bb8
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Fri Nov 2 10:08:27 2012 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Fri Nov 2 10:08:27 2012 -0700

----------------------------------------------------------------------
 .../META-INF/modules/core/pageinit.coffee          |   10 +++-------
 .../internal/services/DocumentLinkerImpl.java      |    3 +--
 .../services/javascript/ModuleManagerImpl.java     |    5 ++---
 .../javascript/InitializationPriority.java         |   12 +++++++-----
 .../services/javascript/ModuleManager.java         |   12 +++++++-----
 .../resources/org/apache/tapestry5/core.properties |    2 +-
 6 files changed, 21 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/fdeec355/tapestry-core/src/main/coffeescript/META-INF/modules/core/pageinit.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/core/pageinit.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/core/pageinit.coffee
index d0e35f6..8b552b3 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/core/pageinit.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/core/pageinit.coffee
@@ -116,7 +116,7 @@ define ["_", "core/console", "core/spi", "core/events"],
           callbackCountdown--
 
           if callbackCountdown is 0
-            console.debug "Inits completed"
+            console.debug "All inits executed"
             callback() if callback
 
         # First value in each init is the qualified module name; anything after
@@ -141,13 +141,9 @@ define ["_", "core/console", "core/spi", "core/events"],
       # any free-standing libraries). It then executes the immediate initializations. After that, it waits for the DOM to be
       # ready (which, given typical Tapestry page structure, it almost certainly is at the point this function
       # executed), and then executes the other initializations.
-      loadLibrariesAndInitialize: (libraries, immediateInits, otherInits) ->
+      loadLibrariesAndInitialize: (libraries, inits) ->
         console.debug "Loading #{libraries?.length or 0} libraries"
-        exports.loadLibraries libraries, ->
-          console.debug "Executing immediate inits"
-          exports.initialize immediateInits, ->
-            console.debug "Executing ordinary inits"
-            exports.initialize otherInits
+        exports.loadLibraries libraries, -> exports.initialize inits
 
       evalJavaScript: (js) ->
         console.debug "Evaluating: #{js}"

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/fdeec355/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DocumentLinkerImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DocumentLinkerImpl.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DocumentLinkerImpl.java
index 3fa1157..7622d80 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DocumentLinkerImpl.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DocumentLinkerImpl.java
@@ -190,8 +190,7 @@ public class DocumentLinkerImpl implements DocumentLinker
         // Eventually, (nearly) everything will be loaded as modules.
 
         moduleManager.writeInitialization(body, libraryURLs,
-                initsManager.forPriority(InitializationPriority.IMMEDIATE),
-                initsManager.forPriority(InitializationPriority.EARLY, InitializationPriority.NORMAL, InitializationPriority.LATE));
+                initsManager.forPriority(InitializationPriority.IMMEDIATE, InitializationPriority.EARLY, InitializationPriority.NORMAL, InitializationPriority.LATE));
     }
 
     private static Element createTemporaryContainer(Element headElement, String existingElementName, String newElementName)

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/fdeec355/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/ModuleManagerImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/ModuleManagerImpl.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/ModuleManagerImpl.java
index 39cecf8..8a2d7fe 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/ModuleManagerImpl.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/ModuleManagerImpl.java
@@ -169,7 +169,7 @@ public class ModuleManagerImpl implements ModuleManager
         tracker.clearOnInvalidation(cache);
     }
 
-    public void writeInitialization(Element body, List<String> libraryURLs, List<JSONArray> immediateInits, List<JSONArray> deferredInits)
+    public void writeInitialization(Element body, List<String> libraryURLs, List<JSONArray> inits)
     {
         body.element("script", "src", requireJS.toClientURL());
 
@@ -181,8 +181,7 @@ public class ModuleManagerImpl implements ModuleManager
 
         content.append(globalMessages.format("core-page-initialization-template",
                 convert(libraryURLs),
-                convert(immediateInits),
-                convert(deferredInits)));
+                convert(inits)));
 
         element.raw(content.toString());
     }

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/fdeec355/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/InitializationPriority.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/InitializationPriority.java b/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/InitializationPriority.java
index 608efed..31848d2 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/InitializationPriority.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/InitializationPriority.java
@@ -18,7 +18,8 @@ package org.apache.tapestry5.services.javascript;
  * Sets the priority for JavaScript initialization scripting. InitializationPriority allows coarse-grained control
  * over the order in which initialization occurs on the client. The default is normally {@link #NORMAL}. Starting in 5.4,
  * these values have less meaning, as the {@linkplain JavaScriptSupport#require(String) dynamic loading of modules} may
- * have unexpected effects on the exact order in which initialization occurs.
+ * have unexpected effects on the exact order in which initialization occurs as some initializations may be deferred until
+ * a referenced module, or a dependency of a referenced module, has been loaded.
  *
  * @since 5.2.0
  */
@@ -29,22 +30,23 @@ public enum InitializationPriority
      * JavaScript's {@code eval}, and occurs once all {@linkplain JavaScriptSupport#importJavaScriptLibrary(org.apache.tapestry5.Asset) JavaScript libraries}
      * (but not modules) for the page have been loaded.
      * <p/>
-     * In an Ajax update, IMMEDIATE code is executed after the DOM is updated and before EARLY.
+     *
+     * @deprecated Deprecated in 5.4; this is now treated as "earlier than {@linkplain #EARLY early}".
      */
     IMMEDIATE,
 
     /**
-     * Execution is deferred until the page loads. All early execution occurs before {@link #NORMAL}.
+     * All early execution occurs before {@link #NORMAL}.
      */
     EARLY,
 
     /**
-     * Execution is deferred until the page loads. This is the typical priority.
+     * This is the typical priority.
      */
     NORMAL,
 
     /**
-     * Execution is deferred until the page loads. Execution occurs after {@link #NORMAL}.
+     * Execution occurs after {@link #NORMAL}.
      */
     LATE
 }

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/fdeec355/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/ModuleManager.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/ModuleManager.java b/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/ModuleManager.java
index d0c2667..e6fb7c5 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/ModuleManager.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/ModuleManager.java
@@ -41,15 +41,17 @@ public interface ModuleManager
      * is constructed to load static scripts and perform page initializations.
      *
      * @param body
-     *         {@code <body>} element of the page, to which new {@code <script>>} element(s) will be added.
+     *         {@code <body>} element of the page, to which new {@code <script>} element(s) will be added.
      * @param libraryURLs
      *         list of additional static JavaScript library URLs that must be loaded on the page, after the
      *         coreLibraryURLs, and before an initializations
-     * @param immediateInits
- *         list of immediate initializations that occur as soon as the static JavaScript libraries are loaded
-     * @param deferredInits
+     * @param inits
+     *         initializations for the page, in the desired execution order. Each element consists of a
+     *         qualified function name, followed by parameters to pass to the function. A qualified function name
+     *         is either a module name, or a module name suffixed with the name of a function property exported by the module
+     *         (separated by a ':', e.g. "myapp/mymodule:myfunc").
      */
-    void writeInitialization(Element body, List<String> libraryURLs, List<JSONArray> immediateInits, List<JSONArray> deferredInits);
+    void writeInitialization(Element body, List<String> libraryURLs, List<JSONArray> inits);
 
     /**
      * Given a module name (which may be a path of names separated by slashes), locates the corresponding {@link Resource}.

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/fdeec355/tapestry-core/src/main/resources/org/apache/tapestry5/core.properties
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/resources/org/apache/tapestry5/core.properties b/tapestry-core/src/main/resources/org/apache/tapestry5/core.properties
index ccd2b39..4d571bc 100644
--- a/tapestry-core/src/main/resources/org/apache/tapestry5/core.properties
+++ b/tapestry-core/src/main/resources/org/apache/tapestry5/core.properties
@@ -49,7 +49,7 @@ required=You must provide a value for %s.
 
 core-page-initialization-template=\
 require(["core/pageinit"], function(pageinit) {\
-  pageinit.loadLibrariesAndInitialize(%s, %s, %s); \
+  pageinit.loadLibrariesAndInitialize(%s, %s); \
 });
 
 # Default values for selected core component parameters.