You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by jo...@apache.org on 2010/03/09 03:04:29 UTC

svn commit: r920618 - in /shindig/trunk/java/gadgets/src: main/java/org/apache/shindig/gadgets/rewrite/ScriptConcatContentRewriter.java test/java/org/apache/shindig/gadgets/rewrite/ScriptConcatContentRewriterTest.java

Author: johnh
Date: Tue Mar  9 02:04:29 2010
New Revision: 920618

URL: http://svn.apache.org/viewvc?rev=920618&view=rev
Log:
Introduces ContentRewriter that concatenates consecutive external <script> elements using ConcatVisitor.Js under the hood. Stub put in place for integration test of rewriter.


Added:
    shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/ScriptConcatContentRewriter.java
    shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/ScriptConcatContentRewriterTest.java

Added: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/ScriptConcatContentRewriter.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/ScriptConcatContentRewriter.java?rev=920618&view=auto
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/ScriptConcatContentRewriter.java (added)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/ScriptConcatContentRewriter.java Tue Mar  9 02:04:29 2010
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.shindig.gadgets.rewrite;
+
+import com.google.inject.Inject;
+
+import org.apache.shindig.common.uri.Uri;
+import org.apache.shindig.gadgets.Gadget;
+import org.apache.shindig.gadgets.rewrite.DomWalker;
+import org.apache.shindig.gadgets.rewrite.DomWalker.Visitor;
+import org.apache.shindig.gadgets.uri.ConcatUriManager;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class ScriptConcatContentRewriter extends DomWalker.Rewriter {
+  private final ContentRewriterFeature.Factory featureConfigFactory;
+  private final ConcatUriManager concatUriManager;
+  
+  @Inject
+  public ScriptConcatContentRewriter(ContentRewriterFeature.Factory featureConfigFactory,
+      ConcatUriManager concatUriManager) {
+    this.featureConfigFactory = featureConfigFactory;
+    this.concatUriManager = concatUriManager;
+  }
+  
+  @Override
+  protected List<Visitor> makeVisitors(Gadget context, Uri gadgetUri) {
+    ContentRewriterFeature.Config config = featureConfigFactory.get(gadgetUri);
+    return Arrays.<Visitor>asList(new ConcatVisitor.Js(config, concatUriManager));
+  }
+}

Added: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/ScriptConcatContentRewriterTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/ScriptConcatContentRewriterTest.java?rev=920618&view=auto
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/ScriptConcatContentRewriterTest.java (added)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/ScriptConcatContentRewriterTest.java Tue Mar  9 02:04:29 2010
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.shindig.gadgets.rewrite;
+
+import org.junit.Test;
+
+public class ScriptConcatContentRewriterTest {
+  @Test
+  public void implementIntegrationTests() throws Exception {
+    // TODO: what the method says
+  }
+}