You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by jk...@apache.org on 2006/05/26 19:51:19 UTC

svn commit: r409706 - in /tapestry/tapestry4/trunk: ./ framework/src/descriptor/META-INF/ framework/src/java/org/apache/tapestry/services/ framework/src/test/org/apache/tapestry/services/

Author: jkuhnert
Date: Fri May 26 10:51:18 2006
New Revision: 409706

URL: http://svn.apache.org/viewvc?rev=409706&view=rev
Log:
Fixes TAPESTRY-947 patch from james, changed eclipse checkstyle config to be a local project config so people don't have to add the config 
to the workspace

Added:
    tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/services/DataSqueezerFilter.java
    tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/services/DummyFilter.java
    tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/services/TestDataSqueezer.java
    tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/services/squeezer-pipeline.xml   (with props)
Modified:
    tapestry/tapestry4/trunk/.checkstyle
    tapestry/tapestry4/trunk/framework/src/descriptor/META-INF/tapestry.data.xml
    tapestry/tapestry4/trunk/status.xml

Modified: tapestry/tapestry4/trunk/.checkstyle
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/.checkstyle?rev=409706&r1=409705&r2=409706&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/.checkstyle (original)
+++ tapestry/tapestry4/trunk/.checkstyle Fri May 26 10:51:18 2006
@@ -1,6 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <fileset-config file-format-version="1.2.0" simple-config="true">
-    <fileset name="all" enabled="true" check-config-name="tapestry" local="false">
+    <local-check-config name="tapestry" location="tapestry-checkstyle.xml" type="project" description="The core tapestry checkstyle configuration">
+        <additional-data name="protect-config-file" value="false"/>
+    </local-check-config>
+    <fileset name="all" enabled="true" check-config-name="tapestry" local="true">
         <file-match-pattern match-pattern="." include-pattern="true"/>
     </fileset>
     <filter name="FilesFromPackage" enabled="true">

Modified: tapestry/tapestry4/trunk/framework/src/descriptor/META-INF/tapestry.data.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/descriptor/META-INF/tapestry.data.xml?rev=409706&r1=409705&r2=409706&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/descriptor/META-INF/tapestry.data.xml (original)
+++ tapestry/tapestry4/trunk/framework/src/descriptor/META-INF/tapestry.data.xml Fri May 26 10:51:18 2006
@@ -22,14 +22,29 @@
   <service-point id="DataSqueezer" interface="org.apache.tapestry.services.DataSqueezer">
     
     Converts back and forth between primitive and object types and encoded strings.
+    <invoke-factory service-id="hivemind.lib.PipelineFactory">
+      <create-pipeline filter-interface="org.apache.tapestry.services.DataSqueezerFilter"
+                       configuration-id="DataSqueezerFilters"
+                       terminator="service:DataSqueezerTerminator" />    
+    </invoke-factory>
+    
     
+  </service-point>
+  
+  <configuration-point id="DataSqueezerFilters" schema-id="hivemind.lib.Pipeline">
+  Allows you to plug in your own custom data squeezers in front of the default Tapestry
+  data squeezer.
+  </configuration-point>
+  
+  <service-point id="DataSqueezerTerminator" 
+                 visibility="private" 
+                 interface="org.apache.tapestry.services.DataSqueezer">
     <invoke-factory>
       <construct class="DataSqueezerImpl">
         <set-configuration property="squeezeAdaptors"
                            configuration-id="SqueezeAdaptors"/>
       </construct>
     </invoke-factory>
-    
   </service-point>
   
   <configuration-point id="SqueezeAdaptors" occurs="1..n">

Added: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/services/DataSqueezerFilter.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/services/DataSqueezerFilter.java?rev=409706&view=auto
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/services/DataSqueezerFilter.java (added)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/services/DataSqueezerFilter.java Fri May 26 10:51:18 2006
@@ -0,0 +1,57 @@
+// Copyright 2006 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.tapestry.services;
+
+/**
+ * @author James Carman
+ */
+public interface DataSqueezerFilter {
+
+    /**
+     * Optionally squeezes the data object into a String.
+     * @param data the data to squeeze
+     * @param dataSqueezer the next squeezer in the pipeline
+     * @return the string representation
+     */
+    String squeeze(Object data, DataSqueezer dataSqueezer);
+
+    /**
+     * A convenience; invokes {@link #squeeze(Object)}for each element in the
+     * data array. If data is null, returns null.
+     * @param data the data to squeeze
+     * @param dataSqueezer the next squeezer in the pipeline
+     * @return the string representation
+     */
+    String[] squeeze(Object[] data, DataSqueezer dataSqueezer);
+
+    /**
+     * Unsqueezes the string. Note that in a special case, where the first
+     * character of the string is not a recognized prefix, it is assumed that
+     * the string is simply a string, and returned with no change.
+     * @param string the string representation of the data
+     * @param dataSqueezer the next squeezer in the pipeline
+     * @return the unsqueezed data object
+     */
+    Object unsqueeze(String string, DataSqueezer dataSqueezer);
+
+    /**
+     * Convenience method for unsqueezing many strings (back into objects).
+     * <p>
+     * If strings is null, returns null.
+     * @param strings the string representation of the data
+     * @param dataSqueezer the next squeezer in the pipeline
+     * @return the unsqueezed data object
+     */
+    Object[] unsqueeze(String[] strings, DataSqueezer dataSqueezer);
+}

Added: tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/services/DummyFilter.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/services/DummyFilter.java?rev=409706&view=auto
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/services/DummyFilter.java (added)
+++ tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/services/DummyFilter.java Fri May 26 10:51:18 2006
@@ -0,0 +1,42 @@
+// Copyright May 12, 2006 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.tapestry.services;
+
+
+/**
+ * @author jcarman
+ *
+ */
+public class DummyFilter implements DataSqueezerFilter
+{
+    public String squeeze(Object data, DataSqueezer dataSqueezer) {
+        return "dummy:" + dataSqueezer.squeeze( data );
+    }
+
+    public String[] squeeze(Object[] data, DataSqueezer dataSqueezer) {
+        return null;
+    }
+
+    public Object unsqueeze(String string, DataSqueezer dataSqueezer) {
+    
+        return null;
+    }
+
+    public Object[] unsqueeze(String[] strings, DataSqueezer dataSqueezer)
+    {
+        return null;
+    }
+    
+
+}

Added: tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/services/TestDataSqueezer.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/services/TestDataSqueezer.java?rev=409706&view=auto
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/services/TestDataSqueezer.java (added)
+++ tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/services/TestDataSqueezer.java Fri May 26 10:51:18 2006
@@ -0,0 +1,33 @@
+// Copyright May 12, 2006 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.tapestry.services;
+
+import org.apache.hivemind.Registry;
+import org.apache.hivemind.test.HiveMindTestCase;
+
+
+/**
+ * 
+ *
+ */
+public class TestDataSqueezer extends HiveMindTestCase {
+
+    public void testPipeline() throws Exception {
+        final Registry reg = buildFrameworkRegistry( "squeezer-pipeline.xml" );
+        final DataSqueezer squeezer = ( DataSqueezer )reg.getService( DataSqueezer.class );
+        final String squeezedValue = squeezer.squeeze( "Hello, World!" );
+        assertTrue( squeezedValue.startsWith( "dummy:" ) );
+        
+    }
+}

Added: tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/services/squeezer-pipeline.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/services/squeezer-pipeline.xml?rev=409706&view=auto
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/services/squeezer-pipeline.xml (added)
+++ tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/services/squeezer-pipeline.xml Fri May 26 10:51:18 2006
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<!-- 
+   Copyright 2006 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.
+-->
+
+<module id="squeezer.pipeline" version="1.0.0">
+  <contribution configuration-id="tapestry.data.DataSqueezerFilters">
+    <filter name="dummy" object="instance:org.apache.tapestry.services.DummyFilter" />
+  </contribution>
+</module>

Propchange: tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/services/squeezer-pipeline.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: tapestry/tapestry4/trunk/status.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/status.xml?rev=409706&r1=409705&r2=409706&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/status.xml (original)
+++ tapestry/tapestry4/trunk/status.xml Fri May 26 10:51:18 2006
@@ -89,6 +89,9 @@
         Asset service incorrectly calculating expiration time, was causing numeric overflow
         operations.
       </action>
+      <action type="add" dev="JK" due-to="James Carman" fixes-bug="TAPESTRY-947">
+        Changed data squeezer to be a pipeline, allowing for a more flexible contribution/configuration.
+      </action>
     </release>
     <release version="4.0.1" date="unreleased" >
       <action type="fix" dev="JK" fixes-bug="TAPESTRY-863" due-to="unknown contributor">