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 2013/04/16 04:12:52 UTC
[13/16] git commit: Break out RandomDataSource into its own new
module, tapestry-test-data
Break out RandomDataSource into its own new module, tapestry-test-data
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/dc7da886
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/dc7da886
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/dc7da886
Branch: refs/heads/master
Commit: dc7da88681c8f4333b515bcc5f3455db16acbf2d
Parents: 309822a
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Tue Apr 16 02:57:08 2013 +0100
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Tue Apr 16 02:57:08 2013 +0100
----------------------------------------------------------------------
.../internal/services/javascript/MARH.java | 94 +++++++++++++++
.../javascript/MOduleAssetRequestHandler.java | 94 ---------------
2 files changed, 94 insertions(+), 94 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/dc7da886/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/MARH.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/MARH.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/MARH.java
new file mode 100644
index 0000000..b87d08d
--- /dev/null
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/MARH.java
@@ -0,0 +1,94 @@
+// Copyright 2012, 2013 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.internal.services.AssetDispatcher;
+import org.apache.tapestry5.internal.services.ResourceStreamer;
+import org.apache.tapestry5.ioc.IOOperation;
+import org.apache.tapestry5.ioc.OperationTracker;
+import org.apache.tapestry5.ioc.Resource;
+import org.apache.tapestry5.services.Request;
+import org.apache.tapestry5.services.Response;
+import org.apache.tapestry5.services.assets.AssetRequestHandler;
+import org.apache.tapestry5.services.javascript.ModuleManager;
+
+import java.io.IOException;
+import java.util.EnumSet;
+import java.util.Set;
+
+/**
+ * Handler contributed to {@link AssetDispatcher} with key "modules". It interprets the extra path as a module name,
+ * and searches for the corresponding JavaScript module. Unlike normal assets, modules do not include any kind of checksum
+ * in the URL, and do not set a far-future expires header.
+ *
+ * @see ModuleManager
+ */
+public class MARH implements AssetRequestHandler
+{
+ private final ModuleManager moduleManager;
+
+ private final ResourceStreamer streamer;
+
+ private final OperationTracker tracker;
+
+ private final Set<ResourceStreamer.Options> omitExpiration = EnumSet.of(ResourceStreamer.Options.OMIT_EXPIRATION);
+
+ public MARH(ModuleManager moduleManager,
+ ResourceStreamer streamer,
+ OperationTracker tracker)
+ {
+ this.moduleManager = moduleManager;
+ this.streamer = streamer;
+ this.tracker = tracker;
+ }
+
+ @Override
+ public boolean handleAssetRequest(Request request, Response response, String extraPath) throws IOException
+ {
+ // Ensure request ends with '.js'. That's the extension tacked on by RequireJS because it expects there
+ // to be a hierarchy of static JavaScript files here. In reality, we may be cross-compiling CoffeeScript to
+ // JavaScript, or generating modules on-the-fly, or exposing arbitrary Resources from somewhere on the classpath
+ // as a module.
+
+ int dotx = extraPath.lastIndexOf('.');
+
+ if (dotx < 0)
+ {
+ return false;
+ }
+
+ if (!extraPath.substring(dotx + 1).equals("js"))
+ {
+ return false;
+ }
+
+ final String moduleName = extraPath.substring(0, dotx);
+
+ return tracker.perform(String.format("Streaming module %s", extraPath), new IOOperation<Boolean>()
+ {
+ public Boolean perform() throws IOException
+ {
+ Resource resource = moduleManager.findResourceForModule(moduleName);
+
+ if (resource != null)
+ {
+ return streamer.streamResource(resource, "", omitExpiration);
+ }
+
+ return false;
+ }
+ });
+ }
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/dc7da886/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/MOduleAssetRequestHandler.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/MOduleAssetRequestHandler.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/MOduleAssetRequestHandler.java
deleted file mode 100644
index d809556..0000000
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/MOduleAssetRequestHandler.java
+++ /dev/null
@@ -1,94 +0,0 @@
-// Copyright 2012, 2013 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.internal.services.AssetDispatcher;
-import org.apache.tapestry5.internal.services.ResourceStreamer;
-import org.apache.tapestry5.ioc.IOOperation;
-import org.apache.tapestry5.ioc.OperationTracker;
-import org.apache.tapestry5.ioc.Resource;
-import org.apache.tapestry5.services.Request;
-import org.apache.tapestry5.services.Response;
-import org.apache.tapestry5.services.assets.AssetRequestHandler;
-import org.apache.tapestry5.services.javascript.ModuleManager;
-
-import java.io.IOException;
-import java.util.EnumSet;
-import java.util.Set;
-
-/**
- * Handler contributed to {@link AssetDispatcher} with key "modules". It interprets the extra path as a module name,
- * and searches for the corresponding JavaScript module. Unlike normal assets, modules do not include any kind of checksum
- * in the URL, and do not set a far-future expires header.
- *
- * @see ModuleManager
- */
-public class ModuleAssetRequestHandler implements AssetRequestHandler
-{
- private final ModuleManager moduleManager;
-
- private final ResourceStreamer streamer;
-
- private final OperationTracker tracker;
-
- private final Set<ResourceStreamer.Options> omitExpiration = EnumSet.of(ResourceStreamer.Options.OMIT_EXPIRATION);
-
- public ModuleAssetRequestHandler(ModuleManager moduleManager,
- ResourceStreamer streamer,
- OperationTracker tracker)
- {
- this.moduleManager = moduleManager;
- this.streamer = streamer;
- this.tracker = tracker;
- }
-
- @Override
- public boolean handleAssetRequest(Request request, Response response, String extraPath) throws IOException
- {
- // Ensure request ends with '.js'. That's the extension tacked on by RequireJS because it expects there
- // to be a hierarchy of static JavaScript files here. In reality, we may be cross-compiling CoffeeScript to
- // JavaScript, or generating modules on-the-fly, or exposing arbitrary Resources from somewhere on the classpath
- // as a module.
-
- int dotx = extraPath.lastIndexOf('.');
-
- if (dotx < 0)
- {
- return false;
- }
-
- if (!extraPath.substring(dotx + 1).equals("js"))
- {
- return false;
- }
-
- final String moduleName = extraPath.substring(0, dotx);
-
- return tracker.perform(String.format("Streaming module %s", extraPath), new IOOperation<Boolean>()
- {
- public Boolean perform() throws IOException
- {
- Resource resource = moduleManager.findResourceForModule(moduleName);
-
- if (resource != null)
- {
- return streamer.streamResource(resource, "", omitExpiration);
- }
-
- return false;
- }
- });
- }
-}