Updated Branches:
  refs/heads/5.4-js-rewrite e9aa69362 -> 5b906dbc5

Reimplement Autocomplete mixin using Bootstrap's typeahead component
- Create a shim library to expose jQuery (working around apparent RequireJS 
bugs)
- Upgrade to jQuery 1.8.3
- Some tweaks concerning JavaScriptModuleConfiguration


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

Branch: refs/heads/5.4-js-rewrite
Commit: 5b906dbc57d2ffb0ba8383dd96dc3413f5ea5e67
Parents: e9aa693
Author: Howard M. Lewis Ship <[email protected]>
Authored: Mon Nov 19 15:47:40 2012 -0800
Committer: Howard M. Lewis Ship <[email protected]>
Committed: Mon Nov 19 15:47:40 2012 -0800

----------------------------------------------------------------------
 54_RELEASE_NOTES.txt                               |    8 +-
 .../META-INF/modules/core/autocomplete.coffee      |   40 +
 .../coffeescript/META-INF/modules/core/dom.coffee  |    4 +
 .../tapestry5/corelib/mixins/Autocomplete.java     |  146 +-
 .../services/javascript/ModuleManagerImpl.java     |   12 +-
 .../services/javascript/JavaScriptModule.java      |   17 +-
 .../javascript/JavaScriptModuleConfiguration.java  |  145 +
 .../services/javascript/ModuleManager.java         |    8 +-
 .../tapestry5/services/javascript/ShimModule.java  |  136 -
 .../META-INF/assets/tapestry5/jquery-1.8.2.js      | 9442 --------------
 .../META-INF/assets/tapestry5/jquery-1.8.3.js      | 9472 +++++++++++++++
 .../META-INF/assets/tapestry5/jquery-shim.js       |   17 +
 tapestry-core/src/test/app1/AutocompleteDemo.tml   |   16 +-
 13 files changed, 9738 insertions(+), 9725 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/5b906dbc/54_RELEASE_NOTES.txt
----------------------------------------------------------------------
diff --git a/54_RELEASE_NOTES.txt b/54_RELEASE_NOTES.txt
index b5d42da..785c1b1 100644
--- a/54_RELEASE_NOTES.txt
+++ b/54_RELEASE_NOTES.txt
@@ -146,4 +146,10 @@ You may want to consider adding `@Import(stack="core")` to 
your applications' ma
 
 ## Palette Component
 
-The selected property is now type `Collection`, not specifically type `List`. 
It is no longer allowed to be null.
\ No newline at end of file
+The selected property is now type `Collection`, not specifically type `List`. 
It is no longer allowed to be null.
+
+## Autocomplete Mixin
+
+The Autocomplete mixin has been rewritten to use Bootstrap; this implies it 
will also force jQuery onto the page,
+to support the Bootstrap JavaScript library. In addition, Bootstrap's 
typeahead component does not support multiple
+tokens, so this behavior has been removed.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/5b906dbc/tapestry-core/src/main/coffeescript/META-INF/modules/core/autocomplete.coffee
----------------------------------------------------------------------
diff --git 
a/tapestry-core/src/main/coffeescript/META-INF/modules/core/autocomplete.coffee 
b/tapestry-core/src/main/coffeescript/META-INF/modules/core/autocomplete.coffee
new file mode 100644
index 0000000..6261654
--- /dev/null
+++ 
b/tapestry-core/src/main/coffeescript/META-INF/modules/core/autocomplete.coffee
@@ -0,0 +1,40 @@
+# Copyright 2012 The Apache Software Foundation
+#
+# Licensed 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.
+
+# ##core/autocomplete
+#
+# Support for the core/Autocomplete Tapestry mixin.
+define ["core/dom", "core/ajax", "jquery", "bootstrap"],
+  (dom, ajax, $) ->
+
+    doLookup = ($field, url, query, process) ->
+      $field.addClass "ajax-wait"
+
+      ajax url,
+        parameters:
+          "t:input": query
+        onsuccess: (response) ->
+          $field.removeClass "ajax-wait"
+
+          process response.responseJSON.matches
+
+    init = (spec) ->
+      $field = $ document.getElementById spec.id
+
+      $field.typeahead
+        minLength: spec.minChars
+        source: (query, process) -> doLookup $field, spec.url, query, process
+
+
+    exports = init
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/5b906dbc/tapestry-core/src/main/coffeescript/META-INF/modules/core/dom.coffee
----------------------------------------------------------------------
diff --git 
a/tapestry-core/src/main/coffeescript/META-INF/modules/core/dom.coffee 
b/tapestry-core/src/main/coffeescript/META-INF/modules/core/dom.coffee
index fa0af7f..87309da 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/core/dom.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/core/dom.coffee
@@ -31,6 +31,10 @@
 # the abstract layer and gain the valuable benefit of not caring about the 
infrastructure framework.
 define ["_", "core/utils", "prototype"], (_, utils) ->
 
+  # Save a local reference to Prototype.$ ... see notes about some challenges 
using Prototype, jQuery,
+  # and RequireJS together, here: 
https://github.com/jrburke/requirejs/issues/534
+  $ = window.$
+
   # Fires a native event; something that Prototype does not normally do.
   fireNativeEvent = (element, eventName) ->
     if document.createEventObject

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/5b906dbc/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/Autocomplete.java
----------------------------------------------------------------------
diff --git 
a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/Autocomplete.java
 
b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/Autocomplete.java
index 309df96..54c349a 100644
--- 
a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/Autocomplete.java
+++ 
b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/Autocomplete.java
@@ -1,4 +1,4 @@
-// Copyright 2007, 2008, 2009, 2010, 2011 The Apache Software Foundation
+// Copyright 2007, 2008, 2009, 2010, 2011, 2012 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -15,16 +15,14 @@
 package org.apache.tapestry5.corelib.mixins;
 
 import org.apache.tapestry5.*;
-import org.apache.tapestry5.ContentType;
 import org.apache.tapestry5.annotations.*;
 import org.apache.tapestry5.internal.util.Holder;
 import org.apache.tapestry5.ioc.annotations.Inject;
 import org.apache.tapestry5.ioc.services.TypeCoercer;
+import org.apache.tapestry5.json.JSONArray;
 import org.apache.tapestry5.json.JSONObject;
-import org.apache.tapestry5.services.MarkupWriterFactory;
-import org.apache.tapestry5.services.ResponseRenderer;
+import org.apache.tapestry5.services.compatibility.DeprecationWarning;
 import org.apache.tapestry5.services.javascript.JavaScriptSupport;
-import org.apache.tapestry5.util.TextStreamResponse;
 
 import java.util.Collections;
 import java.util.List;
@@ -54,15 +52,11 @@ import java.util.List;
  *
  * @tapestrydoc
  */
-@Import(library =
-        {"${tapestry.scriptaculous}/controls.js", "autocomplete.js"})
 @Events(EventConstants.PROVIDE_COMPLETIONS)
 public class Autocomplete
 {
     static final String EVENT_NAME = "autocomplete";
 
-    private static final String PARAM_NAME = "t:input";
-
     /**
      * The field component to which this mixin is attached.
      */
@@ -78,25 +72,17 @@ public class Autocomplete
     @Inject
     private TypeCoercer coercer;
 
-    @Inject
-    private MarkupWriterFactory factory;
-
-    @Inject
-    @Path("${tapestry.spacer-image}")
-    private Asset spacerImage;
-
     /**
      * Overwrites the default minimum characters to trigger a server round 
trip (the default is 1).
      */
     @Parameter(defaultPrefix = BindingConstants.LITERAL)
-    private int minChars;
-
-    @Inject
-    private ResponseRenderer responseRenderer;
+    private int minChars = 1;
 
     /**
      * Overrides the default check frequency for determining whether to send a 
server request. The default is .4
      * seconds.
+     *
+     * @deprecated Deprecated in 5.4 with no replacement.
      */
     @Parameter(defaultPrefix = BindingConstants.LITERAL)
     private double frequency;
@@ -104,76 +90,30 @@ public class Autocomplete
     /**
      * If given, then the autocompleter will support multiple input values, 
seperated by any of the individual
      * characters in the string.
+     * @deprecated Deprecated in 5.4 with no replacement.
      */
     @Parameter(defaultPrefix = BindingConstants.LITERAL)
     private String tokens;
 
-    /**
-     * Mixin afterRender phrase occurs after the component itself. This is 
where we write the &lt;div&gt; element and
-     * the JavaScript.
-     *
-     * @param writer
-     */
-    void afterRender(MarkupWriter writer)
-    {
-        String id = field.getClientId();
-
-        String menuId = id + ":menu";
-        String loaderId = id + ":loader";
-
-        // The spacer image is used as a placeholder, allowing CSS to 
determine what image
-        // is actually displayed.
-
-        writer.element("img",
-
-                "src", spacerImage.toClientURL(),
-
-                "class", "t-autoloader-icon",
-
-                "style", "display:none;",
-
-                "alt", "",
-
-                "id", loaderId);
-        writer.end();
-
-        writer.element("div",
-
-                "id", menuId,
+    @Inject
+    private DeprecationWarning deprecationWarning;
 
-                "class", "t-autocomplete-menu");
-        writer.end();
+    void pageLoaded()
+    {
+        deprecationWarning.ignoredComponentParameters(resources, "frequency", 
"tokens");
+    }
 
+    void afterRender()
+    {
         Link link = resources.createEventLink(EVENT_NAME);
 
-        JSONObject config = new JSONObject();
-        config.put("paramName", PARAM_NAME);
-        config.put("indicator", loaderId);
-
-        if (resources.isBound("minChars"))
-            config.put("minChars", minChars);
-
-        if (resources.isBound("frequency"))
-            config.put("frequency", frequency);
-
-        if (resources.isBound("tokens"))
-        {
-            for (int i = 0; i < tokens.length(); i++)
-            {
-                config.accumulate("tokens", tokens.substring(i, i + 1));
-            }
-        }
+        JSONObject spec = new JSONObject("id", field.getClientId(),
+                "url", link.toString()).put("minChars", minChars);
 
-        // Let subclasses do more.
-        configure(config);
-
-        JSONObject spec = new JSONObject("elementId", id, "menuId", menuId, 
"url", link.toURI()).put("config",
-                config);
-
-        jsSupport.addInitializerCall("autocompleter", spec);
+        jsSupport.require("core/autocomplete").with(spec);
     }
 
-    Object onAutocomplete(@RequestParameter(PARAM_NAME)
+    Object onAutocomplete(@RequestParameter("t:input")
                           String input)
     {
         final Holder<List> matchesHolder = Holder.create();
@@ -197,51 +137,11 @@ public class Autocomplete
         resources.triggerEvent(EventConstants.PROVIDE_COMPLETIONS, new Object[]
                 {input}, callback);
 
-        ContentType contentType = responseRenderer.findContentType(this);
-
-        MarkupWriter writer = factory.newPartialMarkupWriter(contentType);
-
-        generateResponseMarkup(writer, matchesHolder.get());
-
-        return new TextStreamResponse(contentType.toString(), 
writer.toString());
-    }
+        JSONObject reply = new JSONObject();
 
-    /**
-     * Invoked to allow subclasses to further configure the parameters passed 
to the JavaScript Ajax.Autocompleter
-     * options. The values minChars, frequency and tokens my be 
pre-configured. Subclasses may override this method to
-     * configure additional features of the Ajax.Autocompleter.
-     * <p/>
-     * <p/>
-     * This implementation does nothing.
-     *
-     * @param config
-     *         parameters object
-     */
-    protected void configure(JSONObject config)
-    {
-    }
-
-    /**
-     * Generates the markup response that will be returned to the client; this 
should be an &lt;ul&gt; element with
-     * nested &lt;li&gt; elements. Subclasses may override this to produce 
more involved markup (including images and
-     * CSS class attributes).
-     *
-     * @param writer
-     *         to write the list to
-     * @param matches
-     *         list of matching objects, each should be converted to a string
-     */
-    protected void generateResponseMarkup(MarkupWriter writer, List matches)
-    {
-        writer.element("ul");
-
-        for (Object o : matches)
-        {
-            writer.element("li");
-            writer.write(o.toString());
-            writer.end();
-        }
+        reply.put("matches", JSONArray.from(matchesHolder.get()));
 
-        writer.end(); // ul
+        // A JSONObject response is always preferred, as that triggers the 
whole partial page render pipeline.
+        return reply;
     }
 }

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/5b906dbc/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 c4d8891..01a475e 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
@@ -32,8 +32,8 @@ import org.apache.tapestry5.services.AssetSource;
 import org.apache.tapestry5.services.ComponentClassResolver;
 import org.apache.tapestry5.services.assets.AssetPathConstructor;
 import org.apache.tapestry5.services.assets.StreamableResourceSource;
+import org.apache.tapestry5.services.javascript.JavaScriptModuleConfiguration;
 import org.apache.tapestry5.services.javascript.ModuleManager;
-import org.apache.tapestry5.services.javascript.ShimModule;
 
 import java.util.Comparator;
 import java.util.List;
@@ -65,7 +65,7 @@ public class ModuleManagerImpl implements ModuleManager
     public ModuleManagerImpl(AssetPathConstructor constructor, final 
ComponentClassResolver resolver, AssetSource assetSource,
                              @Path("${" + SymbolConstants.REQUIRE_JS + "}")
                              Asset requireJS,
-                             Map<String, ShimModule> configuration,
+                             Map<String, JavaScriptModuleConfiguration> 
configuration,
                              Messages globalMessages,
                              StreamableResourceSource streamableResourceSource,
                              @Symbol(SymbolConstants.COMPACT_JSON)
@@ -97,7 +97,7 @@ public class ModuleManagerImpl implements ModuleManager
         
extensions.addAll(streamableResourceSource.fileExtensionsForContentType("text/javascript"));
     }
 
-    private String buildRequireJSConfig(String baseURL, Map<String, 
ShimModule> configuration, boolean devMode)
+    private String buildRequireJSConfig(String baseURL, Map<String, 
JavaScriptModuleConfiguration> configuration, boolean devMode)
     {
         JSONObject config = new JSONObject("baseUrl", baseURL);
 
@@ -109,7 +109,7 @@ public class ModuleManagerImpl implements ModuleManager
 
         for (String name : configuration.keySet())
         {
-            ShimModule module = configuration.get(name);
+            JavaScriptModuleConfiguration module = configuration.get(name);
 
             shimModuleNameToResource.put(name, module.resource);
 
@@ -123,10 +123,10 @@ public class ModuleManagerImpl implements ModuleManager
             }
         }
 
-        return String.format("require.config(%s);\n", 
config.toString(compactJSON));
+        return String.format("requirejs.config(%s);\n", 
config.toString(compactJSON));
     }
 
-    private void addModuleToConfig(JSONObject config, String name, ShimModule 
module)
+    private void addModuleToConfig(JSONObject config, String name, 
JavaScriptModuleConfiguration module)
     {
         JSONObject shimConfig = config.in("shim");
 

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/5b906dbc/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/JavaScriptModule.java
----------------------------------------------------------------------
diff --git 
a/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/JavaScriptModule.java
 
b/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/JavaScriptModule.java
index 6feeacf..fd02ba0 100644
--- 
a/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/JavaScriptModule.java
+++ 
b/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/JavaScriptModule.java
@@ -218,19 +218,24 @@ public class JavaScriptModule
                                             @Inject 
@Path("${tapestry.asset.root}/underscore_1_4_2.js")
                                             Resource underscore,
 
+                                            @Inject 
@Path("${tapestry.asset.root}/jquery-shim.js")
+                                            Resource jqueryShim,
+
                                             @Inject 
@Path("${tapestry.scriptaculous}/prototype.js")
                                             Resource prototype,
 
-                                            @Inject 
@Path("${tapestry.asset.root}/jquery-1.8.2.js")
+                                            @Inject 
@Path("${tapestry.asset.root}/jquery-1.8.3.js")
                                             Resource jQuery,
 
                                             @Inject @Path("${" + 
SymbolConstants.BOOTSTRAP_ROOT + "}/js/bootstrap.js")
                                             Resource bootstrap)
     {
-        configuration.add("_", new ShimModule(underscore).exports("_"));
-        configuration.add("$", new 
ShimModule(jQuery).initializeWith("jQuery.noConflict()"));
-        configuration.add("prototype", new ShimModule(prototype));
-        configuration.add("bootstrap", new 
ShimModule(bootstrap).dependsOn("$"));
+        configuration.add("_", new 
JavaScriptModuleConfiguration(underscore).exports("_"));
+        // Hacking around https://github.com/jrburke/requirejs/issues/534
+        configuration.add("jquery-library", new 
JavaScriptModuleConfiguration(jQuery));
+        configuration.add("jquery", new 
JavaScriptModuleConfiguration(jqueryShim));
+        configuration.add("prototype", new 
JavaScriptModuleConfiguration(prototype));
+        configuration.add("bootstrap", new 
JavaScriptModuleConfiguration(bootstrap).dependsOn("jquery"));
     }
 
     @Contribute(ModuleManager.class)
@@ -244,7 +249,7 @@ public class JavaScriptModule
         {
             MessageCatalogResource resource = new 
MessageCatalogResource(locale, messagesSource, resourceChangeTracker, 
compactJSON);
 
-            configuration.add("core/messages/" + locale.toString(), new 
ShimModule(resource));
+            configuration.add("core/messages/" + locale.toString(), new 
JavaScriptModuleConfiguration(resource));
         }
     }
 

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/5b906dbc/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/JavaScriptModuleConfiguration.java
----------------------------------------------------------------------
diff --git 
a/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/JavaScriptModuleConfiguration.java
 
b/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/JavaScriptModuleConfiguration.java
new file mode 100644
index 0000000..f719b87
--- /dev/null
+++ 
b/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/JavaScriptModuleConfiguration.java
@@ -0,0 +1,145 @@
+// Copyright 2012 The Apache Software Foundation
+//
+// Licensed 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.tapestry5.services.javascript;
+
+import org.apache.tapestry5.ioc.Resource;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Used to define a <a 
href="http://requirejs.org/docs/api.html#config-shim";>module shim</a>, used to 
adapt non-AMD JavaScript libraries
+ * to operate like proper modules.  This information is used to build up a 
list of dependencies for the contributed JavaScript module,
+ * and to identify the resource to be streamed to the client.
+ * <p/>
+ * Instances of this class are contributed to the {@link ModuleManager} 
service;  the contribution key is the module name
+ * (typically, a single word).
+ * <p/>
+ * In some cases, an instance may be created and contributed to override a 
default module; if the module has no dependencies,
+ * exports, or initExpression (that is, if it is a proper AMD module, where 
such dependencies are provided inside
+ * the module itself), then no client-side shim configuration will be written 
for the module, but requests for the
+ * module will be satisfied by the resource.'
+ *
+ * @since 5.4
+ */
+public final class JavaScriptModuleConfiguration
+{
+    /**
+     * The resource for this shim module.
+     */
+    public final Resource resource;
+
+    /**
+     * The names of other shim modules that should be loaded before this shim 
module.
+     */
+    private List<String> dependencies;
+
+    /**
+     * Optional (but desirable) value exported by the shim module.
+     */
+    private String exports;
+
+    private String initExpression;
+
+    private boolean needsConfiguration;
+
+    public JavaScriptModuleConfiguration(Resource resource)
+    {
+        assert resource != null;
+
+        this.resource = resource;
+    }
+
+    /**
+     * A list of other module names the shim depends on.
+     *
+     * @param moduleNames
+     * @return this JavaScriptModuleConfiguration for further configuration
+     */
+    public JavaScriptModuleConfiguration dependsOn(String... moduleNames)
+    {
+        assert moduleNames.length > 0;
+
+        dependencies = Arrays.asList(moduleNames);
+
+        needsConfiguration = true;
+
+        return this;
+    }
+
+    public List<String> getDependencies()
+    {
+        return dependencies;
+    }
+
+    /**
+     * The name of a global variable exported by the module. This will be the 
value injected into
+     * modules that depend on the shim.
+     *
+     * @return this JavaScriptModuleConfiguration for further configuration
+     */
+    public JavaScriptModuleConfiguration exports(String exports)
+    {
+        assert exports != null;
+
+        this.exports = exports;
+
+        needsConfiguration = true;
+
+        return this;
+    }
+
+    public String getExports()
+    {
+        return exports;
+    }
+
+    /**
+     * Used as an alternative to {@linkplain #exports(String)}, this allows a 
short expression to be specified; the
+     * expression is used to initialize, clean up, and (usually) return the 
module's export value. For Underscore, this
+     * would be "_.noConflict()".  If the expression returns null, then the 
exports value is used.
+     * <p/>
+     * In RequireJS 2.1.1 (the version shipped with Tapestry, currently), an 
init function is not invoked unless
+     * the shim also defines an exports. See <a 
href="https://github.com/jrburke/requirejs/issues/517";>RequireJS issue 517</a>.
+     * At this time, you should specify {@link #exports} even if you provide a 
{@link #initializeWith(String)}}.
+     *
+     * @param expression
+     *         initialization expression
+     * @return this JavaScriptModuleConfiguration, for further configuration
+     */
+    public JavaScriptModuleConfiguration initializeWith(String expression)
+    {
+        assert expression != null;
+
+        this.initExpression = expression;
+
+        needsConfiguration = true;
+
+        return this;
+    }
+
+    public String getInitExpression()
+    {
+        return initExpression;
+    }
+
+    /**
+     * Returns true if the module contains any additional configuration beyond 
its {@link Resource}.
+     */
+    public boolean getNeedsConfiguration()
+    {
+        return needsConfiguration;
+    }
+}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/5b906dbc/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 523c864..6dcf4e9 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
@@ -24,12 +24,12 @@ import java.util.List;
  * Responsible for managing access to the JavaScript modules.
  * <p/>
  * The configuration of the service allows overrides of the default search 
path; the configuration keys
- * are module names, and the configuration values are the {@link ShimModule} 
definitions for those module names.
- * This is primarily used to wrap non-AMD compliant libraries for use with 
RequireJS (via contributed {@link ShimModule}s).
+ * are module names, and the configuration values are the {@link 
JavaScriptModuleConfiguration} definitions for those module names.
+ * This is primarily used to wrap non-AMD compliant libraries for use with 
RequireJS (via contributed {@link JavaScriptModuleConfiguration}s).
  *
  * @since 5.4
  */
-@UsesMappedConfiguration(ShimModule.class)
+@UsesMappedConfiguration(JavaScriptModuleConfiguration.class)
 public interface ModuleManager
 {
     /**
@@ -56,7 +56,7 @@ public interface ModuleManager
 
     /**
      * Given a module name (which may be a path of names separated by 
slashes), locates the corresponding {@link Resource}.
-     * First checks for {@linkplain ShimModule contributed shim modules}, then 
searches for possible matches among the
+     * First checks for {@linkplain JavaScriptModuleConfiguration contributed 
shim modules}, then searches for possible matches among the
      * {@linkplain 
org.apache.tapestry5.services.ComponentClassResolver#getLibraryNames() defined 
library names}.  As a special
      * case, the folder name "app" is mapped to the application's package.
      *

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/5b906dbc/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/ShimModule.java
----------------------------------------------------------------------
diff --git 
a/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/ShimModule.java
 
b/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/ShimModule.java
deleted file mode 100644
index 274c134..0000000
--- 
a/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/ShimModule.java
+++ /dev/null
@@ -1,136 +0,0 @@
-// Copyright 2012 The Apache Software Foundation
-//
-// Licensed 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.tapestry5.services.javascript;
-
-import org.apache.tapestry5.ioc.Resource;
-
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Used to define a <a 
href="http://requirejs.org/docs/api.html#config-shim";>module shim</a>, used to 
adapt non-AMD JavaScript libraries
- * to operate like proper modules.  This information is used to build up a 
list of dependencies for the contributed JavaScript module,
- * and to identify the resource to be streamed to the client.
- * <p/>
- * Instances of this class are contributed to the {@link ModuleManager} 
service;  the contribution key is the module name
- * (typically, a single word).
- *
- * @since 5.4
- */
-public final class ShimModule
-{
-    /**
-     * The resource for this shim module.
-     */
-    public final Resource resource;
-
-    /**
-     * The names of other shim modules that should be loaded before this shim 
module.
-     */
-    private List<String> dependencies;
-
-    /**
-     * Optional (but desirable) value exported by the shim module.
-     */
-    private String exports;
-
-    private String initExpression;
-
-    private boolean needsConfiguration;
-
-    public ShimModule(Resource resource)
-    {
-        assert resource != null;
-
-        this.resource = resource;
-    }
-
-    /**
-     * A list of other module names the shim depends on.
-     *
-     * @param moduleNames
-     * @return this ShimModule for further configuration
-     */
-    public ShimModule dependsOn(String... moduleNames)
-    {
-        assert moduleNames.length > 0;
-
-        dependencies = Arrays.asList(moduleNames);
-
-        needsConfiguration = true;
-
-        return this;
-    }
-
-    public List<String> getDependencies()
-    {
-        return dependencies;
-    }
-
-    /**
-     * The name of a global variable exported by the module. This will be the 
value injected into
-     * modules that depend on the shim.
-     *
-     * @return this ShimModule for further configuration
-     */
-    public ShimModule exports(String exports)
-    {
-        assert exports != null;
-
-        this.exports = exports;
-
-        needsConfiguration = true;
-
-        return this;
-    }
-
-    public String getExports()
-    {
-        return exports;
-    }
-
-    /**
-     * Used as an alternative to {@linkplain #exports(String)}, this allows a 
short expression to be specified; the
-     * expression is used to initialize, clean up, and (usually) return the 
module's export value. For Underscore, this
-     * would be "_.noConflict()".  If the expression returns null, then the 
exports value is used.
-     *
-     * @param expression
-     *         initialization expression
-     * @return this ShimModule, for further configuration
-     */
-    public ShimModule initializeWith(String expression)
-    {
-        assert expression != null;
-
-        this.initExpression = expression;
-
-        needsConfiguration = true;
-
-        return this;
-    }
-
-    public String getInitExpression()
-    {
-        return initExpression;
-    }
-
-    /**
-     * Returns true if the module contains any additional configuration beyond 
its {@link Resource}.
-     */
-    public boolean getNeedsConfiguration()
-    {
-        return needsConfiguration;
-    }
-}

Reply via email to