tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject [1/9] git commit: Remove support for JavaScriptWrapper (.jsw) files
Date Mon, 31 Dec 2012 01:28:38 GMT
Remove support for JavaScriptWrapper (.jsw) files


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

Branch: refs/heads/master
Commit: 89f9bce41aff1e76bd8a5d4a6af61e946ee73882
Parents: 32848b2
Author: Howard M. Lewis Ship <hlship@apache.org>
Authored: Sun Dec 30 17:03:44 2012 -0800
Committer: Howard M. Lewis Ship <hlship@apache.org>
Committed: Sun Dec 30 17:03:44 2012 -0800

----------------------------------------------------------------------
 .../JavaScriptWrapperResourceTransformer.java      |  101 ---------------
 .../services/javascript/JavaScriptModule.java      |    6 -
 2 files changed, 0 insertions(+), 107 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/89f9bce4/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/JavaScriptWrapperResourceTransformer.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/JavaScriptWrapperResourceTransformer.java
b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/JavaScriptWrapperResourceTransformer.java
deleted file mode 100644
index e94f0c7..0000000
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/JavaScriptWrapperResourceTransformer.java
+++ /dev/null
@@ -1,101 +0,0 @@
-package org.apache.tapestry5.internal.services.javascript;
-
-import org.apache.tapestry5.ioc.Resource;
-import org.apache.tapestry5.ioc.internal.util.InternalUtils;
-import org.apache.tapestry5.services.assets.*;
-
-import java.io.*;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Contributed to to the {@link StreamableResourceSource} service, this  transformer converts
files with the extension ".jsw" (JavaScript Wrapper) into
- * simple JavaScript. JavaScript Wrapper files consist of normal JavaScript, with a special
{@code @include} directive.
- * The include directive must appear on a line by itself, and is of the form: {@code @include("relative-resource-path")}
where the <em>relative-resource-path</em>
- * identifies another Resource to insert at that line.  The directive may be indented, and
have whitespace around the before and after the parenthesis, but must
- * be one a single line.
- * <p/>
- * Currently, only resources in the same domain are supported (resource prefixes are not
currently supported).
- * <p/>
- * The identified resource is obtained via the
- * StreamableResourceSource service(meaning that other resource transformations may occur).
- * <p/>
- * JavaScript Wrapper files are primarily used to adapt JavaScript libraries that are not
compatible with the <a href="http://requirejs.org/docs/whyamd.html">AMD</a> format
- * (used by <a href="http://requirejs.org/">RequireJS</a>).
- * <p/>
- * JavaScript Wrapper files are expected to be encoded in utf-8.
- *
- * @since 5.4
- */
-public class JavaScriptWrapperResourceTransformer implements ResourceTransformer
-{
-    private final StreamableResourceSource streamableResourceSource;
-
-    private final Pattern includePattern = Pattern.compile("^\\s*@include\\s*\\(\\s*\"(.*?)\"\\s*\\)\\s*$");
-
-    public JavaScriptWrapperResourceTransformer(StreamableResourceSource streamableResourceSource)
-    {
-        this.streamableResourceSource = streamableResourceSource;
-    }
-
-    public String getTransformedContentType()
-    {
-        return "text/javascript";
-    }
-
-    @Override
-    public InputStream transform(Resource source, ResourceDependencies dependencies) throws
IOException
-    {
-        InputStream is = source.openStream();
-
-        ByteArrayOutputStream bos = new ByteArrayOutputStream(5000);
-        PrintWriter pw = new PrintWriter(new OutputStreamWriter(bos, "utf-8"));
-
-        try
-        {
-            LineNumberReader reader = new LineNumberReader(new InputStreamReader(is, "utf-8"));
-
-            while (true)
-            {
-                String line = reader.readLine();
-
-                if (line == null)
-                {
-                    break;
-                }
-
-                Matcher matcher = includePattern.matcher(line);
-
-                if (matcher.matches())
-                {
-                    String path = matcher.group(1);
-
-                    // TODO: Checks for recursive includes!
-
-                    Resource includedResource = source.forFile(path);
-
-                    dependencies.addDependency(includedResource);
-
-                    StreamableResource includedStreamable = streamableResourceSource.getStreamableResource(includedResource,
StreamableResourceProcessing.FOR_AGGREGATION, dependencies);
-
-                    pw.flush();
-
-                    includedStreamable.streamTo(bos);
-
-                } else
-                {
-                    pw.println(line);
-                }
-            }
-
-            pw.close();
-            reader.close();
-
-        } finally
-        {
-            InternalUtils.close(is);
-        }
-
-        return new ByteArrayInputStream(bos.toByteArray());
-    }
-}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/89f9bce4/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 0480da9..9c1f184 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
@@ -207,12 +207,6 @@ public class JavaScriptModule
         configuration.addInstance("module-root", ModuleAssetRequestHandler.class);
     }
 
-    @Contribute(StreamableResourceSource.class)
-    public static void setupJavaScriptWrapper(MappedConfiguration<String, ResourceTransformer>
configuration)
-    {
-        configuration.addInstance("jsw", JavaScriptWrapperResourceTransformer.class);
-    }
-
     @Contribute(ModuleManager.class)
     public static void setupBaseModuleShims(MappedConfiguration<String, Object> configuration,
                                             @Inject @Path("${tapestry.asset.root}/underscore_1_4_2.js")


Mime
View raw message