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/01 22:08:41 UTC
git commit: Remove CoreJavaScriptStack,
use ExtensibleJavaScriptStack instead
Updated Branches:
refs/heads/5.4-js-rewrite 8131b9a8d -> e067e5519
Remove CoreJavaScriptStack, use ExtensibleJavaScriptStack instead
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/e067e551
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/e067e551
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/e067e551
Branch: refs/heads/5.4-js-rewrite
Commit: e067e5519328fd50a29e9dd32b10f59664cc8633
Parents: 8131b9a
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Thu Nov 1 14:06:21 2012 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Thu Nov 1 14:06:21 2012 -0700
----------------------------------------------------------------------
.../services/javascript/CoreJavaScriptStack.java | 133 ---------------
.../java/org/apache/tapestry5/services/Core.java | 9 +-
.../services/javascript/JavaScriptModule.java | 41 +++++-
3 files changed, 44 insertions(+), 139 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/e067e551/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/CoreJavaScriptStack.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/CoreJavaScriptStack.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/CoreJavaScriptStack.java
deleted file mode 100644
index 91899be..0000000
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/CoreJavaScriptStack.java
+++ /dev/null
@@ -1,133 +0,0 @@
-// Copyright 2010-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.internal.services.javascript;
-
-import org.apache.tapestry5.Asset;
-import org.apache.tapestry5.func.F;
-import org.apache.tapestry5.func.Flow;
-import org.apache.tapestry5.func.Mapper;
-import org.apache.tapestry5.internal.TapestryInternalUtils;
-import org.apache.tapestry5.ioc.services.SymbolSource;
-import org.apache.tapestry5.services.AssetSource;
-import org.apache.tapestry5.services.javascript.JavaScriptStack;
-import org.apache.tapestry5.services.javascript.StylesheetLink;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Locale;
-
-/**
- * JavaScriptStack for core components.
- *
- * @since 5.2.0
- */
-public class CoreJavaScriptStack implements JavaScriptStack
-{
- private final SymbolSource symbolSource;
-
- private final AssetSource assetSource;
-
- private final Flow<Asset> javaScriptStack, stylesheetStack;
-
- private static final String ROOT = "${tapestry.asset.root}";
-
- private static final String[] CORE_JAVASCRIPT = new String[]
- {
- // Core scripts added to any page that uses scripting
-
- // TODO: Only include these two when in compatibility mode ...
- // after the t5-* and tapestry libraries have been stripped
- // of Scriptaculous code.
-
- "${tapestry.scriptaculous}/scriptaculous.js",
-
- "${tapestry.scriptaculous}/effects.js",
-
- // TODO: Include jQuery based on configuration
- // .... probably be generally available as module "$"
-
- // TODO: Possibly extract prototype/scriptaculous/jquery from the stack
- // (as has been done with Underscore), and convert to a shimmed module.
-
- ROOT + "/t53-compatibility.js"
- };
-
- // Because of changes to the logic of how stylesheets get incorporated, the default stylesheet
- // was removed, the logic for it is now in TapestryModule.contributeMarkupRenderer().
-
- private static final String[] CORE_STYLESHEET = new String[]
- {
- "${tapestry.bootstrap-root}/css/bootstrap.css",
-
- // The following are mostly temporary:
-
- ROOT + "/tapestry-console.css",
-
- ROOT + "/t5-alerts.css",
-
- ROOT + "/tree.css"
- };
-
- public CoreJavaScriptStack(SymbolSource symbolSource, AssetSource assetSource)
- {
- this.symbolSource = symbolSource;
- this.assetSource = assetSource;
-
- Flow<String> coreJavascript = F.flow(CORE_JAVASCRIPT);
-
- javaScriptStack = convertToAssets(coreJavascript);
- stylesheetStack = convertToAssets(F.flow(CORE_STYLESHEET));
-
- }
-
- public String getInitialization()
- {
- return null;
- }
-
- public List<String> getStacks()
- {
- return Collections.emptyList();
- }
-
- private Flow<Asset> convertToAssets(Flow<String> paths)
- {
- return paths.map(new Mapper<String, Asset>()
- {
- @Override
- public Asset map(String element)
- {
- return expand(element, null);
- }
- });
- }
-
- private Asset expand(String path, Locale locale)
- {
- String expanded = symbolSource.expandSymbols(path);
-
- return assetSource.getAsset(null, expanded, locale);
- }
-
- public List<Asset> getJavaScriptLibraries()
- {
- return javaScriptStack.toList();
- }
-
- public List<StylesheetLink> getStylesheets()
- {
- return stylesheetStack.map(TapestryInternalUtils.assetToStylesheetLink).toList();
- }
-}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/e067e551/tapestry-core/src/main/java/org/apache/tapestry5/services/Core.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/services/Core.java b/tapestry-core/src/main/java/org/apache/tapestry5/services/Core.java
index f9b904e..7d68081 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/services/Core.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/services/Core.java
@@ -1,4 +1,4 @@
-// Copyright 2007, 2010 The Apache Software Foundation
+// Copyright 2007, 2010, 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.
@@ -14,15 +14,16 @@
package org.apache.tapestry5.services;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
/**
- * Marker annotation for services that are provided by the Tapestry core module.
+ * Marker annotation for services that are provided by the Tapestry core module. Also, used as
+ * the marker annotation for the core {@link org.apache.tapestry5.services.javascript.JavaScriptStack}.
*/
@Target(
{ ElementType.PARAMETER, ElementType.FIELD, ElementType.METHOD })
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/e067e551/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 e909750..e80e26f 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
@@ -61,6 +61,7 @@ public class JavaScriptModule
{
binder.bind(ModuleManager.class, ModuleManagerImpl.class);
binder.bind(JavaScriptStackSource.class, JavaScriptStackSourceImpl.class);
+ binder.bind(JavaScriptStack.class, ExtensibleJavaScriptStack.class).withMarker(Core.class).withId("CoreJavaScriptStack");
}
/**
@@ -68,12 +69,48 @@ public class JavaScriptModule
*
* @since 5.2.0
*/
- public static void contributeJavaScriptStackSource(MappedConfiguration<String, JavaScriptStack> configuration)
+ @Contribute(JavaScriptStackSource.class)
+ public static void provideBuiltinJavaScriptStacks(MappedConfiguration<String, JavaScriptStack> configuration, @Core JavaScriptStack coreStack)
{
- configuration.addInstance(InternalConstants.CORE_STACK_NAME, CoreJavaScriptStack.class);
+ configuration.add(InternalConstants.CORE_STACK_NAME, coreStack);
configuration.addInstance("core-datefield", DateFieldStack.class);
}
+ @Contribute(JavaScriptStack.class)
+ @Core
+ public static void setupCoreJavaScriptStack(OrderedConfiguration<StackExtension> configuration)
+ {
+ final String ROOT = "${tapestry.asset.root}";
+
+ add(configuration, StackExtensionType.LIBRARY, "${tapestry.scriptaculous}/scriptaculous.js",
+ "${tapestry.scriptaculous}/effects.js",
+ ROOT + "/t53-compatibility.js"
+ );
+
+ add(configuration, StackExtensionType.STYLESHEET,
+ "${tapestry.bootstrap-root}/css/bootstrap.css",
+
+ // The following are mostly temporary:
+
+ ROOT + "/tapestry-console.css",
+
+ ROOT + "/t5-alerts.css",
+
+ ROOT + "/tree.css");
+ }
+
+ private static void add(OrderedConfiguration<StackExtension> configuration, StackExtensionType type, String... paths)
+ {
+ for (String path : paths)
+ {
+ int slashx = path.lastIndexOf('/');
+ String id = path.substring(slashx + 1);
+
+ configuration.add(id, new StackExtension(type, path));
+ }
+ }
+
+
/**
* Builds a proxy to the current {@link JavaScriptSupport} inside this thread's {@link org.apache.tapestry5.services.Environment}.
*