You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2005/11/20 15:14:45 UTC

svn commit: r345745 [1/2] - in /jakarta/tapestry/trunk: ./ contrib/src/java/org/apache/tapestry/contrib/inspector/ examples/Vlib/src/java/org/apache/tapestry/vlib/pages/ framework/src/descriptor/META-INF/ framework/src/documentation/content/xdocs/tapes...

Author: hlship
Date: Sun Nov 20 06:14:14 2005
New Revision: 345745

URL: http://svn.apache.org/viewcvs?rev=345745&view=rev
Log:
Make the logic for localizing resources extensible
Refactor SessionPropertyPersistenceStrategy to make it easier to create similar strategies
More work on the QuickStart documentation

Added:
    jakarta/tapestry/trunk/framework/src/descriptor/META-INF/tapestry.l10n.xml
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/l10n/
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/l10n/DefaultResourceLocalizer.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/l10n/DefaultResourceLocalizerTest.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/l10n/ResourceLocalizer.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/RecordUtils.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/WebSessionAttributeCallback.java
    jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/engine/RequestCycleTest.java
      - copied, changed from r332813, jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/engine/TestRequestCycle.java
    jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/l10n/
    jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/record/PropertyPersistenceStrategySourceTest.java
      - copied, changed from r332813, jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/record/TestPropertyPersistenceStrategySource.java
    jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/record/SessionPropertyPersistenceStrategyTest.java
      - copied, changed from r332813, jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/record/TestSessionPropertyPersistenceStrategy.java
    jakarta/tapestry/trunk/src/documentation/resources/images/QuickStart/forms3.png   (with props)
Removed:
    jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/engine/TestRequestCycle.java
    jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/record/TestPropertyPersistenceStrategySource.java
    jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/record/TestSessionPropertyPersistenceStrategy.java
Modified:
    jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/inspector/ShowProperties.java
    jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/Home.java
    jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/Login.java
    jakarta/tapestry/trunk/framework/src/descriptor/META-INF/hivemodule.xml
    jakarta/tapestry/trunk/framework/src/descriptor/META-INF/tapestry.asset.xml
    jakarta/tapestry/trunk/framework/src/descriptor/META-INF/tapestry.parse.xml
    jakarta/tapestry/trunk/framework/src/descriptor/META-INF/tapestry.persist.xml
    jakarta/tapestry/trunk/framework/src/documentation/content/xdocs/tapestry/ComponentReference/index.xml
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/asset/ClasspathAssetFactory.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/asset/ContextAssetFactory.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/engine/RequestCycle.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/engine/RequestCycleEnvironment.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/ClientPropertyPersistenceStrategy.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/PageRecorderImpl.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/PropertyPersistenceStrategy.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/PropertyPersistenceStrategySource.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/PropertyPersistenceStrategySourceImpl.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/SessionPropertyPersistenceStrategy.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/request/RequestContext.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/services/CookieSource.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/services/impl/RequestCycleFactoryImpl.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/services/impl/TemplateSourceImpl.java
    jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/asset/ClasspathAssetFactoryTest.java
    jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/asset/ContextAssetFactoryTest.java
    jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/record/TestClientPropertyPersistenceStrategy.java
    jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/record/TestPageRecorder.java
    jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/services/impl/LinkFactoryTest.java
    jakarta/tapestry/trunk/src/documentation/content/xdocs/QuickStart/forms.xml
    jakarta/tapestry/trunk/src/documentation/content/xdocs/index.xml
    jakarta/tapestry/trunk/src/documentation/resources/images/QuickStart/forms2.png
    jakarta/tapestry/trunk/src/images/TapestryLogo.psp
    jakarta/tapestry/trunk/status.xml

Modified: jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/inspector/ShowProperties.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/inspector/ShowProperties.java?rev=345745&r1=345744&r2=345745&view=diff
==============================================================================
--- jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/inspector/ShowProperties.java (original)
+++ jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/inspector/ShowProperties.java Sun Nov 20 06:14:14 2005
@@ -46,8 +46,6 @@
 
     public void pageBeginRender(PageEvent event)
     {
-        IRequestCycle cycle = event.getRequestCycle();
-
         Inspector inspector = (Inspector) getPage();
 
         IPage inspectedPage = inspector.getInspectedPage();
@@ -56,7 +54,7 @@
 
         PropertyPersistenceStrategySource source = getPropertySource();
 
-        Collection properties = source.getAllStoredChanges(pageName, cycle);
+        Collection properties = source.getAllStoredChanges(pageName);
 
         // TODO: sorting
 

Modified: jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/Home.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/Home.java?rev=345745&r1=345744&r2=345745&view=diff
==============================================================================
--- jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/Home.java (original)
+++ jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/Home.java Sun Nov 20 06:14:14 2005
@@ -44,7 +44,7 @@
 
     /**
      * Listener method, invokes
-     * {@link BookMatches#performQuery(MasterQueryParameters, IRequestCycle)}.
+     * {@link BookMatches#performQuery(MasterQueryParameters)}.
      */
 
     public void search()

Modified: jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/Login.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/Login.java?rev=345745&r1=345744&r2=345745&view=diff
==============================================================================
--- jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/Login.java (original)
+++ jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/Login.java Sun Nov 20 06:14:14 2005
@@ -54,6 +54,8 @@
 
     private static final String COOKIE_NAME = "org.apache.tapestry.vlib.Login.email";
 
+    private static final int COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
+
     @Bean(VirtualLibraryDelegate.class)
     public abstract IValidationDelegate getValidationDelegate();
 
@@ -164,9 +166,7 @@
         else
             callback.performCallback(cycle);
 
-        // TODO: Set max age of cookie once TAPESTRY-438 is fixed.
-
-        getCookieSource().writeCookieValue(COOKIE_NAME, email);
+        getCookieSource().writeCookieValue(COOKIE_NAME, email, COOKIE_MAX_AGE);
 
         cycle.forgetPage(getPageName());
     }

Modified: jakarta/tapestry/trunk/framework/src/descriptor/META-INF/hivemodule.xml
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/descriptor/META-INF/hivemodule.xml?rev=345745&r1=345744&r2=345745&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/descriptor/META-INF/hivemodule.xml (original)
+++ jakarta/tapestry/trunk/framework/src/descriptor/META-INF/hivemodule.xml Sun Nov 20 06:14:14 2005
@@ -47,6 +47,7 @@
   <sub-module descriptor="tapestry.valid.xml"/>
   <sub-module descriptor="tapestry.listener.xml"/>
   <sub-module descriptor="tapestry.form.xml"/>
+  <sub-module descriptor="tapestry.l10n.xml"/>
   
   <service-point id="ClasspathResourceFactory">
   

Modified: jakarta/tapestry/trunk/framework/src/descriptor/META-INF/tapestry.asset.xml
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/descriptor/META-INF/tapestry.asset.xml?rev=345745&r1=345744&r2=345745&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/descriptor/META-INF/tapestry.asset.xml (original)
+++ jakarta/tapestry/trunk/framework/src/descriptor/META-INF/tapestry.asset.xml Sun Nov 20 06:14:14 2005
@@ -64,6 +64,7 @@
         <set-service property="classpathAssetFactory" service-id="ClasspathAssetFactory"/>
         <set-object property="contextPath" value="infrastructure:contextPath"/>
         <set-service property="webContext" service-id="tapestry.globals.WebContext"/>
+        <set-object property="localizer" value="infrastructure:resourceLocalizer"/>
       </construct>
     </invoke-factory>
     

Added: jakarta/tapestry/trunk/framework/src/descriptor/META-INF/tapestry.l10n.xml
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/descriptor/META-INF/tapestry.l10n.xml?rev=345745&view=auto
==============================================================================
--- jakarta/tapestry/trunk/framework/src/descriptor/META-INF/tapestry.l10n.xml (added)
+++ jakarta/tapestry/trunk/framework/src/descriptor/META-INF/tapestry.l10n.xml Sun Nov 20 06:14:14 2005
@@ -0,0 +1,51 @@
+<?xml version="1.0"?>
+<!-- 
+   Copyright 2005 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="tapestry.l10n" version="4.0.0" package="org.apache.tapestry.l10n">
+    
+  Extensible support for localization of resources.
+  
+    <configuration-point id="ResourceLocalizers" schema-id="hivemind.lib.ChainContribution">
+        
+        Defines the commands, each implementing ResourceLocalizer, that define how to localize
+        a Resource.
+        
+    </configuration-point>    
+    
+    <contribution configuration-id="ResourceLocalizers">
+        
+        <command id="default" after="*" object="instance:DefaultResourceLocalizer"/>
+        
+    </contribution>
+    
+    <service-point id="ResourceLocalizer">
+        
+        Service for localizing resources, based on the ResourceLocalizers configuration
+        point.
+        
+        <invoke-factory service-id="hivemind.lib.ChainFactory">
+            <construct configuration-id="ResourceLocalizers"/>
+        </invoke-factory>
+                
+    </service-point>
+    
+    
+    <contribution configuration-id="tapestry.Infrastructure">
+        <property name="resourceLocalizer" object="service:ResourceLocalizer"/>
+    </contribution>
+</module>
+    
\ No newline at end of file

Modified: jakarta/tapestry/trunk/framework/src/descriptor/META-INF/tapestry.parse.xml
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/descriptor/META-INF/tapestry.parse.xml?rev=345745&r1=345744&r2=345745&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/descriptor/META-INF/tapestry.parse.xml (original)
+++ jakarta/tapestry/trunk/framework/src/descriptor/META-INF/tapestry.parse.xml Sun Nov 20 06:14:14 2005
@@ -84,6 +84,7 @@
         <set-object property="contextRoot" value="infrastructure:contextRoot"/>
         <set-service property="componentSpecificationResolver" service-id="tapestry.page.ComponentSpecificationResolver"/>
         <set-object property="componentPropertySource"  value="infrastructure:componentPropertySource"/>
+        <set-object property="localizer" value="infrastructure:resourceLocalizer"/>
         <event-listener service-id="tapestry.ResetEventHub"/>
         <event-listener service-id="tapestry.describe.ReportStatusHub"/>
       </construct>

Modified: jakarta/tapestry/trunk/framework/src/descriptor/META-INF/tapestry.persist.xml
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/descriptor/META-INF/tapestry.persist.xml?rev=345745&r1=345744&r2=345745&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/descriptor/META-INF/tapestry.persist.xml (original)
+++ jakarta/tapestry/trunk/framework/src/descriptor/META-INF/tapestry.persist.xml Sun Nov 20 06:14:14 2005
@@ -44,7 +44,7 @@
   <service-point id="SessionPropertyPersistenceStrategy" interface="PropertyPersistenceStrategy">
     
     The standard persistence strategy, mapped to the name "session". Simply stores each property as
-    an HttpSession attribute.
+    a session attribute.
     
     <invoke-factory>
       <construct class="SessionPropertyPersistenceStrategy">
@@ -66,6 +66,8 @@
   <service-point id="PageClientPropertyPersistenceScope" interface="ClientPropertyPersistenceScope">
     
     Stores client persistent properties only if the page remains the same.
+    When a new page is activated and rendered, the values for other pages
+    are discarded.
     
     <invoke-factory>
       <construct class="PageClientPropertyPersistenceScope">

Modified: jakarta/tapestry/trunk/framework/src/documentation/content/xdocs/tapestry/ComponentReference/index.xml
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/documentation/content/xdocs/tapestry/ComponentReference/index.xml?rev=345745&r1=345744&r2=345745&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/documentation/content/xdocs/tapestry/ComponentReference/index.xml (original)
+++ jakarta/tapestry/trunk/framework/src/documentation/content/xdocs/tapestry/ComponentReference/index.xml Sun Nov 20 06:14:14 2005
@@ -1,18 +1,18 @@
 <?xml version="1.0"?>
 <!-- 
-    Copyright 2005 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.
+   Copyright 2005 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.
 -->
 
 <!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.2//EN" "./dtd/document-v12.dtd"

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/asset/ClasspathAssetFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/asset/ClasspathAssetFactory.java?rev=345745&r1=345744&r2=345745&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/asset/ClasspathAssetFactory.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/asset/ClasspathAssetFactory.java Sun Nov 20 06:14:14 2005
@@ -23,6 +23,7 @@
 import org.apache.hivemind.util.ClasspathResource;
 import org.apache.tapestry.IAsset;
 import org.apache.tapestry.engine.IEngineService;
+import org.apache.tapestry.l10n.ResourceLocalizer;
 
 /**
  * Creates instances of {@link org.apache.tapestry.asset.PrivateAsset}, which are the holders of
@@ -37,10 +38,12 @@
 
     private IEngineService _assetService;
 
+    private ResourceLocalizer _localizer;
+
     public IAsset createAsset(Resource baseResource, String path, Locale locale, Location location)
     {
         Resource asset = baseResource.getRelativeResource(path);
-        Resource localized = asset.getLocalization(locale);
+        Resource localized = _localizer.findLocalization(asset, locale);
 
         if (localized == null)
             throw new ApplicationRuntimeException(AssetMessages.missingAsset(path, baseResource),
@@ -52,7 +55,7 @@
     public IAsset createAbsoluteAsset(String path, Locale locale, Location location)
     {
         Resource base = new ClasspathResource(_classResolver, path);
-        Resource localized = base.getLocalization(locale);
+        Resource localized = _localizer.findLocalization(base, locale);
 
         if (localized == null)
             throw new ApplicationRuntimeException(AssetMessages.missingClasspathResource(path),
@@ -76,5 +79,10 @@
     public void setClassResolver(ClassResolver classResolver)
     {
         _classResolver = classResolver;
+    }
+
+    public void setLocalizer(ResourceLocalizer localizer)
+    {
+        _localizer = localizer;
     }
 }

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/asset/ContextAssetFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/asset/ContextAssetFactory.java?rev=345745&r1=345744&r2=345745&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/asset/ContextAssetFactory.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/asset/ContextAssetFactory.java Sun Nov 20 06:14:14 2005
@@ -20,6 +20,7 @@
 import org.apache.hivemind.Location;
 import org.apache.hivemind.Resource;
 import org.apache.tapestry.IAsset;
+import org.apache.tapestry.l10n.ResourceLocalizer;
 import org.apache.tapestry.web.WebContext;
 import org.apache.tapestry.web.WebContextResource;
 
@@ -38,6 +39,8 @@
 
     private WebContext _webContext;
 
+    private ResourceLocalizer _localizer;
+
     public void setWebContext(WebContext webContext)
     {
         _webContext = webContext;
@@ -59,7 +62,7 @@
         if (assetResource.getResourceURL() == null && path.startsWith("/"))
             return _classpathAssetFactory.createAbsoluteAsset(path, locale, location);
 
-        Resource localized = assetResource.getLocalization(locale);
+        Resource localized = _localizer.findLocalization(assetResource, locale);
 
         if (localized == null)
             throw new ApplicationRuntimeException(AssetMessages.missingAsset(path, baseResource),
@@ -71,7 +74,7 @@
     public IAsset createAbsoluteAsset(String path, Locale locale, Location location)
     {
         Resource base = new WebContextResource(_webContext, path);
-        Resource localized = base.getLocalization(locale);
+        Resource localized = _localizer.findLocalization(base, locale);
 
         if (localized == null)
             throw new ApplicationRuntimeException(AssetMessages.missingContextResource(path),
@@ -93,5 +96,10 @@
     public void setClasspathAssetFactory(AssetFactory classpathAssetFactory)
     {
         _classpathAssetFactory = classpathAssetFactory;
+    }
+
+    public void setLocalizer(ResourceLocalizer localizer)
+    {
+        _localizer = localizer;
     }
 }

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/engine/RequestCycle.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/engine/RequestCycle.java?rev=345745&r1=345744&r2=345745&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/engine/RequestCycle.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/engine/RequestCycle.java Sun Nov 20 06:14:14 2005
@@ -139,10 +139,12 @@
      *            informed of various events during the processing of the request
      * @param environment
      *            additional invariant services and objects needed by each RequestCycle instance
+     * @param context
+     *            Part of (partial) compatibility with Tapestry 3.0
      */
 
     public RequestCycle(IEngine engine, QueryParameterMap parameters, String serviceName,
-            IMonitor monitor, RequestCycleEnvironment environment)
+            IMonitor monitor, RequestCycleEnvironment environment, RequestContext context)
     {
         // Variant from instance to instance
 
@@ -157,7 +159,7 @@
         _pageSource = _infrastructure.getPageSource();
         _strategySource = environment.getStrategySource();
         _absoluteURLBuilder = environment.getAbsoluteURLBuilder();
-        _requestContext = environment.getRequestContext();
+        _requestContext = context;
         _log = new ErrorLogImpl(environment.getErrorHandler(), LOG);
 
     }
@@ -683,7 +685,7 @@
     {
         Defense.notNull(pageName, "pageName");
 
-        _strategySource.discardAllStoredChanged(pageName, this);
+        _strategySource.discardAllStoredChanged(pageName);
     }
 
     /** @since 4.0 */

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/engine/RequestCycleEnvironment.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/engine/RequestCycleEnvironment.java?rev=345745&r1=345744&r2=345745&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/engine/RequestCycleEnvironment.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/engine/RequestCycleEnvironment.java Sun Nov 20 06:14:14 2005
@@ -15,10 +15,11 @@
 package org.apache.tapestry.engine;
 
 import org.apache.hivemind.ErrorHandler;
+import org.apache.tapestry.IEngine;
 import org.apache.tapestry.record.PropertyPersistenceStrategySource;
-import org.apache.tapestry.request.RequestContext;
 import org.apache.tapestry.services.AbsoluteURLBuilder;
 import org.apache.tapestry.services.Infrastructure;
+import org.apache.tapestry.util.QueryParameterMap;
 
 /**
  * An object that contains all the invariant parameters to the
@@ -30,23 +31,19 @@
  */
 public class RequestCycleEnvironment
 {
-    private Infrastructure _infrastructure;
+    private final Infrastructure _infrastructure;
 
-    private PropertyPersistenceStrategySource _strategySource;
+    private final PropertyPersistenceStrategySource _strategySource;
 
-    private AbsoluteURLBuilder _absoluteURLBuilder;
+    private final AbsoluteURLBuilder _absoluteURLBuilder;
 
-    private ErrorHandler _errorHandler;
-
-    private RequestContext _requestContext;
+    private final ErrorHandler _errorHandler;
 
     public RequestCycleEnvironment(ErrorHandler errorHandler, Infrastructure infrastructure,
-            RequestContext requestContext, PropertyPersistenceStrategySource strategySource,
-            AbsoluteURLBuilder absoluteURLBuilder)
+            PropertyPersistenceStrategySource strategySource, AbsoluteURLBuilder absoluteURLBuilder)
     {
         _errorHandler = errorHandler;
         _infrastructure = infrastructure;
-        _requestContext = requestContext;
         _strategySource = strategySource;
         _absoluteURLBuilder = absoluteURLBuilder;
     }
@@ -69,10 +66,5 @@
     public PropertyPersistenceStrategySource getStrategySource()
     {
         return _strategySource;
-    }
-
-    public RequestContext getRequestContext()
-    {
-        return _requestContext;
     }
 }

Added: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/l10n/DefaultResourceLocalizer.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/l10n/DefaultResourceLocalizer.java?rev=345745&view=auto
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/l10n/DefaultResourceLocalizer.java (added)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/l10n/DefaultResourceLocalizer.java Sun Nov 20 06:14:14 2005
@@ -0,0 +1,39 @@
+// Copyright 2005 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.l10n;
+
+import java.util.Locale;
+
+import org.apache.hivemind.Resource;
+
+/**
+ * Default implementation of {@link org.apache.tapestry.l10n.ResourceLocalizer} that leverages the
+ * localization rules built into
+ * {@link org.apache.hivemind.Resource#getLocalization(java.util.Locale)}.
+ * 
+ * @author Howard M. Lewis Ship
+ * @since 4.0
+ */
+public class DefaultResourceLocalizer implements ResourceLocalizer
+{
+    /**
+     * Invokes {@link Resource#getLocalization(java.util.Locale)}.
+     */
+    public Resource findLocalization(Resource rootResource, Locale locale)
+    {
+        return rootResource.getLocalization(locale);
+    }
+
+}

Added: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/l10n/DefaultResourceLocalizerTest.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/l10n/DefaultResourceLocalizerTest.java?rev=345745&view=auto
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/l10n/DefaultResourceLocalizerTest.java (added)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/l10n/DefaultResourceLocalizerTest.java Sun Nov 20 06:14:14 2005
@@ -0,0 +1,52 @@
+// Copyright 2005 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.l10n;
+
+import java.util.Locale;
+
+import org.apache.hivemind.Resource;
+import org.apache.hivemind.test.HiveMindTestCase;
+
+/**
+ * Tests for {@link org.apache.tapestry.l10n.DefaultResourceLocalizer}.
+ * 
+ * @author Howard M. Lewis Ship
+ * @since 4.0
+ */
+public class DefaultResourceLocalizerTest extends HiveMindTestCase
+{
+    public void testLocalizer()
+    {
+        Resource root = newResource();
+        Resource localized = newResource();
+        Locale locale = Locale.getDefault();
+
+        root.getLocalization(locale);
+        setReturnValue(root, localized);
+
+        replayControls();
+
+        Resource actual = new DefaultResourceLocalizer().findLocalization(root, locale);
+
+        assertSame(localized, actual);
+
+        verifyControls();
+    }
+
+    private Resource newResource()
+    {
+        return (Resource) newMock(Resource.class);
+    }
+}

Added: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/l10n/ResourceLocalizer.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/l10n/ResourceLocalizer.java?rev=345745&view=auto
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/l10n/ResourceLocalizer.java (added)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/l10n/ResourceLocalizer.java Sun Nov 20 06:14:14 2005
@@ -0,0 +1,42 @@
+// Copyright 2005 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.l10n;
+
+import java.util.Locale;
+
+import org.apache.hivemind.Resource;
+
+/**
+ * An interface that defines how to localize a particular resource. A default implementation will
+ * use {@link org.apache.hivemind.Resource#getLocalization(java.util.Locale)}, but this interface
+ * (and associated chain of command configuration point) allows for alternative approaches to
+ * localizing a resource.
+ * 
+ * @author Howard M. Lewis Ship
+ * @since 4.0
+ */
+public interface ResourceLocalizer
+{
+    /**
+     * Finds and returns a localization of a root resource for the indicated locale.
+     * 
+     * @param rootResource
+     *            the base resource for which a localization is needed
+     * @param locale
+     *            the locale to find a localization for
+     * @return the localized version of the resource, or null if not found
+     */
+    Resource findLocalization(Resource rootResource, Locale locale);
+}

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/ClientPropertyPersistenceStrategy.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/ClientPropertyPersistenceStrategy.java?rev=345745&r1=345744&r2=345745&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/ClientPropertyPersistenceStrategy.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/ClientPropertyPersistenceStrategy.java Sun Nov 20 06:14:14 2005
@@ -22,7 +22,6 @@
 import java.util.Map;
 
 import org.apache.hivemind.util.Defense;
-import org.apache.tapestry.IRequestCycle;
 import org.apache.tapestry.engine.ServiceEncoding;
 import org.apache.tapestry.web.WebRequest;
 
@@ -92,7 +91,7 @@
         data.store(idPath, propertyName, newValue);
     }
 
-    public Collection getStoredChanges(String pageName, IRequestCycle cycle)
+    public Collection getStoredChanges(String pageName)
     {
         PersistentPropertyData data = (PersistentPropertyData) _data.get(pageName);
 
@@ -102,7 +101,7 @@
         return data.getPageChanges();
     }
 
-    public void discardStoredChanges(String pageName, IRequestCycle cycle)
+    public void discardStoredChanges(String pageName)
     {
         _data.remove(pageName);
     }

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/PageRecorderImpl.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/PageRecorderImpl.java?rev=345745&r1=345744&r2=345745&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/PageRecorderImpl.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/PageRecorderImpl.java Sun Nov 20 06:14:14 2005
@@ -65,7 +65,7 @@
 
     public Collection getChanges()
     {
-        return _strategySource.getAllStoredChanges(_pageName, _requestCycle);
+        return _strategySource.getAllStoredChanges(_pageName);
     }
 
     public void rollback(IPage page)

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/PropertyPersistenceStrategy.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/PropertyPersistenceStrategy.java?rev=345745&r1=345744&r2=345745&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/PropertyPersistenceStrategy.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/PropertyPersistenceStrategy.java Sun Nov 20 06:14:14 2005
@@ -16,7 +16,6 @@
 
 import java.util.Collection;
 
-import org.apache.tapestry.IRequestCycle;
 import org.apache.tapestry.engine.ServiceEncoding;
 
 /**
@@ -50,12 +49,12 @@
      * part of rolling back a page to a prior state, before any further changes are possible).
      */
 
-    public Collection getStoredChanges(String pageName, IRequestCycle cycle);
+    public Collection getStoredChanges(String pageName);
 
     /**
      * Invoked to discard any stored changes for the specified page.
      */
-    public void discardStoredChanges(String pageName, IRequestCycle cycle);
+    public void discardStoredChanges(String pageName);
 
     /**
      * Invoked by a {@link org.apache.tapestry.services.LinkFactory}&nbsp;, the parameters may be

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/PropertyPersistenceStrategySource.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/PropertyPersistenceStrategySource.java?rev=345745&r1=345744&r2=345745&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/PropertyPersistenceStrategySource.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/PropertyPersistenceStrategySource.java Sun Nov 20 06:14:14 2005
@@ -16,7 +16,6 @@
 
 import java.util.Collection;
 
-import org.apache.tapestry.IRequestCycle;
 import org.apache.tapestry.engine.ServiceEncoding;
 
 /**
@@ -41,16 +40,16 @@
      * Returns all changes ({@link PropertyChange}) collected by any persistence strategy for the
      * page. May return an empty list.
      * 
-     * @see PropertyPersistenceStrategy#getStoredChanges(String, IRequestCycle)
+     * @see PropertyPersistenceStrategy#getStoredChanges(String)
      */
 
-    public Collection getAllStoredChanges(String pageName, IRequestCycle cycle);
+    public Collection getAllStoredChanges(String pageName);
 
     /**
      * Discards any stored property changes for the named page.
      */
 
-    public void discardAllStoredChanged(String pageName, IRequestCycle cycle);
+    public void discardAllStoredChanged(String pageName);
 
     /**
      * Invoked by a {@link org.apache.tapestry.services.LinkFactory}&nbsp;, the parameters may be
@@ -59,7 +58,7 @@
      * 
      * @param encoding
      *            Service encoding, which indentifies the URL and the query parameters from which
-     *            the {@link org.apache.tapestry.engine.ILink}&nbsp;will be created.
+     *            the {@link org.apache.tapestry.engine.ILink} will be created.
      * @param post
      *            if true, then the link will be used for a post (not a get, i.e., for a HTML form);
      *            this may affect what information is encoded into the link

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/PropertyPersistenceStrategySourceImpl.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/PropertyPersistenceStrategySourceImpl.java?rev=345745&r1=345744&r2=345745&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/PropertyPersistenceStrategySourceImpl.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/PropertyPersistenceStrategySourceImpl.java Sun Nov 20 06:14:14 2005
@@ -22,7 +22,6 @@
 import java.util.Map;
 
 import org.apache.hivemind.ApplicationRuntimeException;
-import org.apache.tapestry.IRequestCycle;
 import org.apache.tapestry.engine.ServiceEncoding;
 
 /**
@@ -60,7 +59,7 @@
         return (PropertyPersistenceStrategy) _strategies.get(name);
     }
 
-    public Collection getAllStoredChanges(String pageName, IRequestCycle cycle)
+    public Collection getAllStoredChanges(String pageName)
     {
         Collection result = new ArrayList();
 
@@ -70,13 +69,13 @@
         {
             PropertyPersistenceStrategy s = (PropertyPersistenceStrategy) i.next();
 
-            result.addAll(s.getStoredChanges(pageName, cycle));
+            result.addAll(s.getStoredChanges(pageName));
         }
 
         return result;
     }
 
-    public void discardAllStoredChanged(String pageName, IRequestCycle cycle)
+    public void discardAllStoredChanged(String pageName)
     {
         Iterator i = _strategies.values().iterator();
 
@@ -84,7 +83,7 @@
         {
             PropertyPersistenceStrategy s = (PropertyPersistenceStrategy) i.next();
 
-            s.discardStoredChanges(pageName, cycle);
+            s.discardStoredChanges(pageName);
         }
     }
 

Added: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/RecordUtils.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/RecordUtils.java?rev=345745&view=auto
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/RecordUtils.java (added)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/RecordUtils.java Sun Nov 20 06:14:14 2005
@@ -0,0 +1,142 @@
+// Copyright 2005 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.record;
+
+import java.util.Iterator;
+
+import org.apache.hivemind.util.Defense;
+import org.apache.tapestry.TapestryUtils;
+import org.apache.tapestry.web.WebSession;
+
+/**
+ * Utility methods to support implementations of
+ * {@link org.apache.tapestry.record.PropertyPersistenceStrategy}. This consists of code refactored
+ * out of {@link org.apache.tapestry.record.SessionPropertyPersistenceStrategy} to support other,
+ * similar, persistence types with different rules for how long values are stored in the session.
+ * 
+ * @author Howard M. Lewis Ship
+ * @since 4.0
+ */
+public class RecordUtils
+{
+    /**
+     * Builds a {@link PropertyChange} instance for the given key and value pulled from the
+     * {@link org.apache.tapestry.web.WebSession}.
+     * 
+     * @param key
+     *            a key, previously created by
+     *            {@link #buildChangeKey(String, String, String, String, String)}, consisting of a
+     *            strategy id, application id, page name, id path (optional), and a property name,
+     *            all seperated by commas.
+     * @param value
+     *            the value stored in the session with this key
+     * @return a {@link PropertyChange} storing the property name and id path (if any), and the
+     *         value
+     */
+    public static PropertyChange buildChange(String key, Object value)
+    {
+        String[] tokens = TapestryUtils.split(key);
+
+        // Either strategy-id, app-name,page-name,id-path,property
+        // or strategy-id,app-name,page-name,property
+
+        String idPath = (tokens.length == 5) ? tokens[3] : null;
+        String propertyName = tokens[tokens.length - 1];
+
+        return new PropertyChangeImpl(idPath, propertyName, value);
+    }
+
+    /**
+     * Iterates over the attributes stored in the session, invoking a callback on each one that
+     * matches the given prefix, applicationid and page name. This is used to operate over all
+     * stored data for a particular combination of strategy, applicationId and page.
+     * 
+     * @param strategyId
+     *            a unique identifier for a particular implementation of
+     *            {@link PropertyPersistenceStrategy}
+     * @param applicationId
+     *            a unique id for the application
+     * @param pageName
+     *            the name of the page
+     * @param session
+     *            the session to search
+     * @param callback
+     *            the callback to invoke on each matching attibute name
+     */
+    public static void iterateOverMatchingAttributes(String strategyId, String applicationId,
+            String pageName, WebSession session, WebSessionAttributeCallback callback)
+    {
+        Defense.notNull(strategyId, "strategyId");
+        Defense.notNull(applicationId, "applicationId");
+        Defense.notNull(pageName, "pageName");
+        Defense.notNull(session, "session");
+
+        String prefix = strategyId + "," + applicationId + "," + pageName + ",";
+
+        Iterator i = session.getAttributeNames().iterator();
+        while (i.hasNext())
+        {
+            String name = (String) i.next();
+
+            if (name.startsWith(prefix))
+                callback.handleAttribute(session, name);
+        }
+    }
+
+    /**
+     * Builds a change key, used to identify the change within the {@link WebSession}. A change key
+     * can be used as a session attribute name, without reasonable fear of conflict.
+     * 
+     * @param strategyId
+     *            a unique identifier for a particular implementation of
+     *            {@link PropertyPersistenceStrategy}
+     * @param applicationId
+     *            a unique identifier for the application
+     * @param pageName
+     *            the name of the page containing the change
+     * @param idPath
+     *            the id path of the component within the page containing the page, possibly null
+     * @param propertyName
+     *            the name of the property
+     * @return the above values, seperated by commas (well, no comma between the prefix and the
+     *         application id)
+     */
+    public static String buildChangeKey(String strategyId, String applicationId, String pageName,
+            String idPath, String propertyName)
+    {
+        Defense.notNull(strategyId, "strategyId");
+        Defense.notNull(applicationId, "applicationId");
+        Defense.notNull(pageName, "pageName");
+        Defense.notNull(propertyName, "propertyName");
+
+        StringBuffer buffer = new StringBuffer(strategyId);
+
+        buffer.append(",");
+        buffer.append(applicationId);
+        buffer.append(",");
+        buffer.append(pageName);
+
+        if (idPath != null)
+        {
+            buffer.append(",");
+            buffer.append(idPath);
+        }
+
+        buffer.append(",");
+        buffer.append(propertyName);
+
+        return buffer.toString();
+    }
+}

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/SessionPropertyPersistenceStrategy.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/SessionPropertyPersistenceStrategy.java?rev=345745&r1=345744&r2=345745&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/SessionPropertyPersistenceStrategy.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/SessionPropertyPersistenceStrategy.java Sun Nov 20 06:14:14 2005
@@ -17,11 +17,8 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Iterator;
 
 import org.apache.hivemind.util.Defense;
-import org.apache.tapestry.IRequestCycle;
-import org.apache.tapestry.TapestryUtils;
 import org.apache.tapestry.engine.ServiceEncoding;
 import org.apache.tapestry.web.WebRequest;
 import org.apache.tapestry.web.WebSession;
@@ -35,6 +32,8 @@
  */
 public class SessionPropertyPersistenceStrategy implements PropertyPersistenceStrategy
 {
+    public static final String STRATEGY_ID = "session";
+
     // Really, the name of the servlet; used as a prefix on all HttpSessionAttribute keys
     // to keep things straight if multiple Tapestry apps are deployed
     // in the same WAR.
@@ -50,27 +49,17 @@
 
         WebSession session = _request.getSession(true);
 
-        StringBuffer buffer = new StringBuffer();
-
-        buffer.append(_applicationId);
-        buffer.append(",");
-        buffer.append(pageName);
-
-        if (idPath != null)
-        {
-            buffer.append(",");
-            buffer.append(idPath);
-        }
-
-        buffer.append(",");
-        buffer.append(propertyName);
+        String attributeName = RecordUtils.buildChangeKey(
+                STRATEGY_ID,
+                _applicationId,
+                pageName,
+                idPath,
+                propertyName);
 
-        String key = buffer.toString();
-
-        session.setAttribute(key, newValue);
+        session.setAttribute(attributeName, newValue);
     }
 
-    public Collection getStoredChanges(String pageName, IRequestCycle cycle)
+    public Collection getStoredChanges(String pageName)
     {
         Defense.notNull(pageName, "pageName");
 
@@ -79,58 +68,49 @@
         if (session == null)
             return Collections.EMPTY_LIST;
 
-        Collection result = new ArrayList();
-
-        String prefix = _applicationId + "," + pageName + ",";
+        final Collection result = new ArrayList();
 
-        Iterator i = session.getAttributeNames().iterator();
-        while (i.hasNext())
+        WebSessionAttributeCallback callback = new WebSessionAttributeCallback()
         {
-            String key = (String) i.next();
-
-            if (key.startsWith(prefix))
+            public void handleAttribute(WebSession session, String name)
             {
-                PropertyChange change = buildChange(key, session.getAttribute(key));
+                PropertyChange change = RecordUtils.buildChange(name, session.getAttribute(name));
 
                 result.add(change);
             }
-        }
-
-        return result;
-    }
-
-    private PropertyChange buildChange(String key, Object value)
-    {
-        String[] tokens = TapestryUtils.split(key);
+        };
 
-        // Either app-name,page-name,id-path,property
-        // or app-name,page-name,property
+        RecordUtils.iterateOverMatchingAttributes(
+                STRATEGY_ID,
+                _applicationId,
+                pageName,
+                session,
+                callback);
 
-        String idPath = (tokens.length == 4) ? tokens[2] : null;
-        String propertyName = tokens[tokens.length - 1];
-
-        return new PropertyChangeImpl(idPath, propertyName, value);
+        return result;
     }
 
-    public void discardStoredChanges(String pageName, IRequestCycle cycle)
+    public void discardStoredChanges(String pageName)
     {
-        Defense.notNull(pageName, "pageName");
-
         WebSession session = _request.getSession(false);
 
         if (session == null)
             return;
 
-        String prefix = _applicationId + "," + pageName + ",";
-
-        Iterator i = session.getAttributeNames().iterator();
-        while (i.hasNext())
+        WebSessionAttributeCallback callback = new WebSessionAttributeCallback()
         {
-            String key = (String) i.next();
+            public void handleAttribute(WebSession session, String name)
+            {
+                session.setAttribute(name, null);
+            }
+        };
 
-            if (key.startsWith(prefix))
-                session.setAttribute(key, null);
-        }
+        RecordUtils.iterateOverMatchingAttributes(
+                STRATEGY_ID,
+                _applicationId,
+                pageName,
+                session,
+                callback);
     }
 
     /**

Added: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/WebSessionAttributeCallback.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/WebSessionAttributeCallback.java?rev=345745&view=auto
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/WebSessionAttributeCallback.java (added)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/record/WebSessionAttributeCallback.java Sun Nov 20 06:14:14 2005
@@ -0,0 +1,37 @@
+// Copyright 2005 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.record;
+
+import org.apache.tapestry.web.WebSession;
+
+/**
+ * Callback interface used to operate on a subset of attributes stored within a
+ * {@link org.apache.tapestry.web.WebSession} whose names match a particular prefix.
+ * 
+ * @author Howard M. Lewis Ship
+ * @since 4.0
+ */
+public interface WebSessionAttributeCallback
+{
+    /**
+     * Invoked for each matching attribute.
+     * 
+     * @param session
+     *            session containing the attribute
+     * @param name
+     *            full name of the attribute
+     */
+    void handleAttribute(WebSession session, String name);
+}

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/request/RequestContext.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/request/RequestContext.java?rev=345745&r1=345744&r2=345745&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/request/RequestContext.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/request/RequestContext.java Sun Nov 20 06:14:14 2005
@@ -33,13 +33,9 @@
  * <p>
  * This is a limited and crippled version of the RequestContext as it was available in release 3.0,
  * that exists as a bridge for compatibility only. This saves developers from having to modify their
- * classes to have the {@link javax.servlet.http.HttpServletRequest}&nbsp;or
- * {@link org.apache.tapestry.web.WebRequest}injected into their pages, components, or services. It
+ * classes to have the {@link javax.servlet.http.HttpServletRequest} or (preferrably)
+ * {@link org.apache.tapestry.web.WebRequest} injected into their pages, components, or services. It
  * will be removed in the next release of Tapestry.
- * <p>
- * Interestingly, with the Tapestry 4.0 architecture, a single instance of RequestContext can be
- * shared by all request cycles (that's because the request and response are, in fact, threaded
- * proxies).
  * 
  * @author Howard Lewis Ship
  * @deprecated To be removed in 4.1. Use injection to gain access to the necessary objects.
@@ -53,7 +49,6 @@
 
     public RequestContext(HttpServletRequest request, HttpServletResponse response)
     {
-
         _request = request;
         _response = response;
     }

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/services/CookieSource.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/services/CookieSource.java?rev=345745&r1=345744&r2=345745&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/services/CookieSource.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/services/CookieSource.java Sun Nov 20 06:14:14 2005
@@ -28,7 +28,7 @@
      * not know about additional cookies added since then (via
      * {@link #writeCookieValue(String, String)}).
      */
-    public String readCookieValue(String name);
+    String readCookieValue(String name);
 
     /**
      * Creates or updates a cookie value. The value is stored using a max age (in seconds) defined
@@ -36,17 +36,24 @@
      * for this value is the equivalent of one week.
      */
 
-    public void writeCookieValue(String name, String value);
+    void writeCookieValue(String name, String value);
 
     /**
      * As with {@link #writeCookieValue(String, String)} but an explicit maximum age may be set.
+     * 
+     * @param name
+     *            the name of the cookie
+     * @param value
+     *            the value to be stored in the cookie
+     * @param maxAge
+     *            the maximum age, in seconds, to store the cookie
      */
 
-    public void writeCookieValue(String name, String value, int maxAge);
+    void writeCookieValue(String name, String value, int maxAge);
 
     /**
      * Removes a previously written cookie, by writing a new cookie with a maxAge of 0.
      */
 
-    public void removeCookieValue(String name);
+    void removeCookieValue(String name);
 }

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/services/impl/RequestCycleFactoryImpl.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/services/impl/RequestCycleFactoryImpl.java?rev=345745&r1=345744&r2=345745&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/services/impl/RequestCycleFactoryImpl.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/services/impl/RequestCycleFactoryImpl.java Sun Nov 20 06:14:14 2005
@@ -66,15 +66,15 @@
 
     public void initializeService()
     {
-        RequestContext context = new RequestContext(_requestGlobals.getRequest(), _requestGlobals
-                .getResponse());
-
-        _environment = new RequestCycleEnvironment(_errorHandler, _infrastructure, context,
-                _strategySource, _absoluteURLBuilder);
+        _environment = new RequestCycleEnvironment(_errorHandler, _infrastructure, _strategySource,
+                _absoluteURLBuilder);
     }
 
     public IRequestCycle newRequestCycle(IEngine engine)
     {
+        RequestContext context = new RequestContext(_requestGlobals.getRequest(), _requestGlobals
+                .getResponse());
+
         WebRequest request = _infrastructure.getRequest();
 
         IMonitor monitor = _monitorFactory.createMonitor(request);
@@ -86,7 +86,7 @@
         String serviceName = findService(parameters);
 
         IRequestCycle cycle = new RequestCycle(engine, parameters, serviceName, monitor,
-                _environment);
+                _environment, context);
 
         _requestGlobals.store(cycle);
 

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/services/impl/TemplateSourceImpl.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/services/impl/TemplateSourceImpl.java?rev=345745&r1=345744&r2=345745&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/services/impl/TemplateSourceImpl.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/services/impl/TemplateSourceImpl.java Sun Nov 20 06:14:14 2005
@@ -37,6 +37,7 @@
 import org.apache.tapestry.event.ReportStatusEvent;
 import org.apache.tapestry.event.ReportStatusListener;
 import org.apache.tapestry.event.ResetEventListener;
+import org.apache.tapestry.l10n.ResourceLocalizer;
 import org.apache.tapestry.parse.ComponentTemplate;
 import org.apache.tapestry.parse.ITemplateParser;
 import org.apache.tapestry.parse.ITemplateParserDelegate;
@@ -99,6 +100,10 @@
 
     private ComponentPropertySource _componentPropertySource;
 
+    /** @since 4.0 */
+
+    private ResourceLocalizer _localizer;
+
     /**
      * Clears the template cache. This is used during debugging.
      */
@@ -272,7 +277,7 @@
             _log.debug("Checking for " + templateBaseName + " in application root");
 
         Resource baseLocation = _contextRoot.getRelativeResource(templateBaseName);
-        Resource localizedLocation = baseLocation.getLocalization(locale);
+        Resource localizedLocation = _localizer.findLocalization(baseLocation, locale);
 
         if (localizedLocation == null)
             return null;
@@ -325,7 +330,9 @@
 
         Resource baseTemplateLocation = resource.getRelativeResource(templateBaseName);
 
-        Resource localizedTemplateLocation = baseTemplateLocation.getLocalization(locale);
+        Resource localizedTemplateLocation = _localizer.findLocalization(
+                baseTemplateLocation,
+                locale);
 
         if (localizedTemplateLocation == null)
             return null;
@@ -563,5 +570,11 @@
     public void setServiceId(String serviceId)
     {
         _serviceId = serviceId;
+    }
+
+    /** @since 4.0 */
+    public void setLocalizer(ResourceLocalizer localizer)
+    {
+        _localizer = localizer;
     }
 }

Modified: jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/asset/ClasspathAssetFactoryTest.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/asset/ClasspathAssetFactoryTest.java?rev=345745&r1=345744&r2=345745&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/asset/ClasspathAssetFactoryTest.java (original)
+++ jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/asset/ClasspathAssetFactoryTest.java Sun Nov 20 06:14:14 2005
@@ -23,6 +23,7 @@
 import org.apache.hivemind.util.ClasspathResource;
 import org.apache.tapestry.IAsset;
 import org.apache.tapestry.engine.IEngineService;
+import org.apache.tapestry.l10n.DefaultResourceLocalizer;
 
 /**
  * Tests for {@link org.apache.tapestry.asset.ClasspathAssetFactory}.
@@ -41,6 +42,7 @@
         ClasspathAssetFactory factory = new ClasspathAssetFactory();
         factory.setClassResolver(getClassResolver());
         factory.setAssetService(assetService);
+        factory.setLocalizer(new DefaultResourceLocalizer());
 
         Resource base = newBaseResource();
 
@@ -64,6 +66,7 @@
         ClasspathAssetFactory factory = new ClasspathAssetFactory();
         factory.setClassResolver(getClassResolver());
         factory.setAssetService(assetService);
+        factory.setLocalizer(new DefaultResourceLocalizer());
 
         Resource base = newBaseResource();
 
@@ -93,6 +96,7 @@
         ClasspathAssetFactory factory = new ClasspathAssetFactory();
         factory.setClassResolver(getClassResolver());
         factory.setAssetService(assetService);
+        factory.setLocalizer(new DefaultResourceLocalizer());
 
         IAsset asset = factory.createAbsoluteAsset(
                 "/org/apache/tapestry/asset/relative-resource.txt",
@@ -117,6 +121,7 @@
         ClasspathAssetFactory factory = new ClasspathAssetFactory();
         factory.setClassResolver(getClassResolver());
         factory.setAssetService(assetService);
+        factory.setLocalizer(new DefaultResourceLocalizer());
 
         try
         {

Modified: jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/asset/ContextAssetFactoryTest.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/asset/ContextAssetFactoryTest.java?rev=345745&r1=345744&r2=345745&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/asset/ContextAssetFactoryTest.java (original)
+++ jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/asset/ContextAssetFactoryTest.java Sun Nov 20 06:14:14 2005
@@ -22,6 +22,7 @@
 import org.apache.hivemind.Resource;
 import org.apache.hivemind.test.HiveMindTestCase;
 import org.apache.tapestry.IAsset;
+import org.apache.tapestry.l10n.DefaultResourceLocalizer;
 import org.apache.tapestry.web.WebContext;
 
 public class ContextAssetFactoryTest extends HiveMindTestCase
@@ -51,6 +52,7 @@
         replayControls();
 
         ContextAssetFactory factory = new ContextAssetFactory();
+        factory.setLocalizer(new DefaultResourceLocalizer());
 
         factory.setContextPath("/context");
 
@@ -75,7 +77,7 @@
         replayControls();
 
         ContextAssetFactory factory = new ContextAssetFactory();
-
+        factory.setLocalizer(new DefaultResourceLocalizer());
         factory.setContextPath("/context");
 
         try
@@ -131,7 +133,7 @@
         replayControls();
 
         ContextAssetFactory factory = new ContextAssetFactory();
-
+        factory.setLocalizer(new DefaultResourceLocalizer());
         factory.setContextPath("/context");
         factory.setWebContext(context);
 
@@ -155,7 +157,7 @@
         replayControls();
 
         ContextAssetFactory factory = new ContextAssetFactory();
-
+        factory.setLocalizer(new DefaultResourceLocalizer());
         factory.setContextPath("/context");
         factory.setWebContext(context);
 

Copied: jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/engine/RequestCycleTest.java (from r332813, jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/engine/TestRequestCycle.java)
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/engine/RequestCycleTest.java?p2=jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/engine/RequestCycleTest.java&p1=jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/engine/TestRequestCycle.java&r1=332813&r2=345745&rev=345745&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/engine/TestRequestCycle.java (original)
+++ jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/engine/RequestCycleTest.java Sun Nov 20 06:14:14 2005
@@ -26,7 +26,6 @@
 import org.apache.tapestry.services.Infrastructure;
 import org.apache.tapestry.services.ServiceMap;
 import org.apache.tapestry.util.QueryParameterMap;
-import org.easymock.MockControl;
 
 /**
  * Tests for {@link org.apache.tapestry.engine.RequestCycle}. Mostly just tests changes for 4.0
@@ -35,7 +34,7 @@
  * @author Howard M. Lewis Ship
  * @since 4.0
  */
-public class TestRequestCycle extends HiveMindTestCase
+public class RequestCycleTest extends HiveMindTestCase
 {
     private IEngine newEngine()
     {
@@ -74,11 +73,10 @@
 
     private Infrastructure newInfrastructure(PageSource source)
     {
-        MockControl control = newControl(Infrastructure.class);
-        Infrastructure infrastructure = (Infrastructure) control.getMock();
+        Infrastructure infrastructure = (Infrastructure) newMock(Infrastructure.class);
 
         infrastructure.getPageSource();
-        control.setReturnValue(source);
+        setReturnValue(infrastructure, source);
 
         return infrastructure;
     }
@@ -95,24 +93,20 @@
         IEngineService service = newService();
         ServiceMap map = newServiceMap("fred", service);
 
-        MockControl control = newControl(Infrastructure.class);
-        Infrastructure infrastructure = (Infrastructure) control.getMock();
-
-        infrastructure.getPageSource();
-        control.setReturnValue(newPageSource());
+        Infrastructure infrastructure = newInfrastructure(newPageSource());
 
         infrastructure.getServiceMap();
-        control.setReturnValue(map);
+        setReturnValue(infrastructure, map);
 
         RequestCycleEnvironment env = new RequestCycleEnvironment(newErrorHandler(),
-                infrastructure, context, newStrategySource(), newBuilder());
+                infrastructure, newStrategySource(), newBuilder());
         IEngine engine = newEngine();
         IMonitor monitor = newMonitor();
 
         replayControls();
 
         IRequestCycle cycle = new RequestCycle(engine, new QueryParameterMap(), "fred", monitor,
-                env);
+                env, context);
 
         assertSame(infrastructure, cycle.getInfrastructure());
         assertSame(context, cycle.getRequestContext());
@@ -125,11 +119,10 @@
 
     private ServiceMap newServiceMap(String serviceName, IEngineService service)
     {
-        MockControl control = newControl(ServiceMap.class);
-        ServiceMap map = (ServiceMap) control.getMock();
+        ServiceMap map = (ServiceMap) newMock(ServiceMap.class);
 
         map.getService(serviceName);
-        control.setReturnValue(service);
+        setReturnValue(map, service);
 
         return map;
     }
@@ -140,19 +133,20 @@
         Infrastructure infrastructure = newInfrastructure();
         PropertyPersistenceStrategySource source = newStrategySource();
         RequestCycleEnvironment env = new RequestCycleEnvironment(newErrorHandler(),
-                infrastructure, context, source, newBuilder());
+                infrastructure, source, newBuilder());
         IEngine engine = newEngine();
         IMonitor monitor = newMonitor();
 
         replayControls();
 
-        IRequestCycle cycle = new RequestCycle(engine, new QueryParameterMap(), null, monitor, env);
+        IRequestCycle cycle = new RequestCycle(engine, new QueryParameterMap(), null, monitor, env,
+                context);
 
         cycle.getEngine();
 
         verifyControls();
 
-        source.discardAllStoredChanged("MyPage", cycle);
+        source.discardAllStoredChanged("MyPage");
 
         replayControls();
 
@@ -160,7 +154,7 @@
 
         verifyControls();
 
-        source.discardAllStoredChanged("MyPage", cycle);
+        source.discardAllStoredChanged("MyPage");
 
         replayControls();
 

Copied: jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/record/PropertyPersistenceStrategySourceTest.java (from r332813, jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/record/TestPropertyPersistenceStrategySource.java)
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/record/PropertyPersistenceStrategySourceTest.java?p2=jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/record/PropertyPersistenceStrategySourceTest.java&p1=jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/record/TestPropertyPersistenceStrategySource.java&r1=332813&r2=345745&rev=345745&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/record/TestPropertyPersistenceStrategySource.java (original)
+++ jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/record/PropertyPersistenceStrategySourceTest.java Sun Nov 20 06:14:14 2005
@@ -20,9 +20,7 @@
 
 import org.apache.hivemind.ApplicationRuntimeException;
 import org.apache.hivemind.test.HiveMindTestCase;
-import org.apache.tapestry.IRequestCycle;
 import org.apache.tapestry.engine.ServiceEncoding;
-import org.easymock.MockControl;
 
 /**
  * Tests for {@link org.apache.tapestry.record.PropertyPersistenceStrategySourceImpl}.
@@ -30,18 +28,13 @@
  * @author Howard M. Lewis Ship
  * @since 4.0
  */
-public class TestPropertyPersistenceStrategySource extends HiveMindTestCase
+public class PropertyPersistenceStrategySourceTest extends HiveMindTestCase
 {
     private PropertyPersistenceStrategy newStrategy()
     {
         return (PropertyPersistenceStrategy) newMock(PropertyPersistenceStrategy.class);
     }
 
-    private IRequestCycle newCycle()
-    {
-        return (IRequestCycle) newMock(IRequestCycle.class);
-    }
-
     private List newContributions(String name, PropertyPersistenceStrategy strategy)
     {
         PropertyPersistenceStrategyContribution c = new PropertyPersistenceStrategyContribution();
@@ -82,17 +75,21 @@
         }
     }
 
-    public void testGetAllStoredChanges()
+    protected void trainGetStoredChanges(PropertyPersistenceStrategy strategy, String pageName,
+            Collection changes)
     {
-        IRequestCycle cycle = newCycle();
 
-        MockControl control = newControl(PropertyPersistenceStrategy.class);
-        PropertyPersistenceStrategy strategy = (PropertyPersistenceStrategy) control.getMock();
+        strategy.getStoredChanges(pageName);
+        setReturnValue(strategy, changes);
+    }
 
-        PropertyChange change = (PropertyChange) newMock(PropertyChange.class);
+    public void testGetAllStoredChanges()
+    {
+        PropertyPersistenceStrategy strategy = newStrategy();
 
-        strategy.getStoredChanges("MyPage", cycle);
-        control.setReturnValue(Collections.singleton(change));
+        PropertyChange change = newChange();
+
+        trainGetStoredChanges(strategy, "MyPage", Collections.singleton(change));
 
         replayControls();
 
@@ -100,7 +97,7 @@
         source.setContributions(newContributions("whatever", strategy));
         source.initializeService();
 
-        Collection result = source.getAllStoredChanges("MyPage", cycle);
+        Collection result = source.getAllStoredChanges("MyPage");
 
         assertEquals(1, result.size());
         assertSame(change, result.iterator().next());
@@ -108,10 +105,15 @@
         verifyControls();
     }
 
+    private PropertyChange newChange()
+    {
+        return (PropertyChange) newMock(PropertyChange.class);
+    }
+
     public void testAddParameters()
     {
         PropertyPersistenceStrategy strategy = newStrategy();
-        ServiceEncoding encoding = (ServiceEncoding) newMock(ServiceEncoding.class);
+        ServiceEncoding encoding = newEncoding();
 
         strategy.addParametersForPersistentProperties(encoding, false);
 
@@ -132,12 +134,16 @@
         source.addParametersForPersistentProperties(encoding, true);
     }
 
+    private ServiceEncoding newEncoding()
+    {
+        return (ServiceEncoding) newMock(ServiceEncoding.class);
+    }
+
     public void testDiscardStoredChanges()
     {
-        IRequestCycle cycle = newCycle();
         PropertyPersistenceStrategy strategy = newStrategy();
 
-        strategy.discardStoredChanges("Home", cycle);
+        strategy.discardStoredChanges("Home");
 
         replayControls();
 
@@ -145,7 +151,7 @@
         source.setContributions(newContributions("known", strategy));
         source.initializeService();
 
-        source.discardAllStoredChanged("Home", cycle);
+        source.discardAllStoredChanged("Home");
 
         verifyControls();
     }

Copied: jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/record/SessionPropertyPersistenceStrategyTest.java (from r332813, jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/record/TestSessionPropertyPersistenceStrategy.java)
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/record/SessionPropertyPersistenceStrategyTest.java?p2=jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/record/SessionPropertyPersistenceStrategyTest.java&p1=jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/record/TestSessionPropertyPersistenceStrategy.java&r1=332813&r2=345745&rev=345745&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/record/TestSessionPropertyPersistenceStrategy.java (original)
+++ jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/record/SessionPropertyPersistenceStrategyTest.java Sun Nov 20 06:14:14 2005
@@ -16,11 +16,12 @@
 
 import java.util.Collection;
 import java.util.Collections;
+import java.util.List;
 
 import org.apache.hivemind.test.HiveMindTestCase;
+import org.apache.tapestry.engine.ServiceEncoding;
 import org.apache.tapestry.web.WebRequest;
 import org.apache.tapestry.web.WebSession;
-import org.easymock.MockControl;
 
 /**
  * Tests for {@link SessionPropertyPersistenceStrategy}.
@@ -28,16 +29,20 @@
  * @author Howard M. Lewis Ship
  * @since 4.0
  */
-public class TestSessionPropertyPersistenceStrategy extends HiveMindTestCase
+public class SessionPropertyPersistenceStrategyTest extends HiveMindTestCase
 {
+    private ServiceEncoding newEncoding()
+    {
+        return (ServiceEncoding) newMock(ServiceEncoding.class);
+    }
+
     private WebRequest newRequest(boolean create, WebSession session)
     {
-        MockControl control = newControl(WebRequest.class);
-        WebRequest request = (WebRequest) control.getMock();
+        WebRequest request = (WebRequest) newMock(WebRequest.class);
 
         request.getSession(create);
 
-        control.setReturnValue(session);
+        setReturnValue(request, session);
 
         return request;
     }
@@ -47,56 +52,41 @@
         return (WebSession) newMock(WebSession.class);
     }
 
-    private WebSession newSession(String attributeName, Object value)
+    private WebSession newSession(String attributeName, boolean remove)
     {
-        MockControl control = newControl(WebSession.class);
-        WebSession session = (WebSession) control.getMock();
-
-        session.getAttributeNames();
+        WebSession session = newSession();
 
-        control.setReturnValue(Collections.singletonList(attributeName));
+        trainGetAttributeNames(session, Collections.singletonList(attributeName));
 
-        if (value != null)
-        {
-            session.getAttribute(attributeName);
-            control.setReturnValue(value);
-        }
+        if (remove)
+            session.setAttribute(attributeName, null);
 
         return session;
     }
 
-    private WebSession newSession(String attributeName, boolean remove)
+    private WebSession newSession(String attributeName, Object value)
     {
-        MockControl control = newControl(WebSession.class);
-        WebSession session = (WebSession) control.getMock();
+        WebSession session = (WebSession) newMock(WebSession.class);
 
         session.getAttributeNames();
 
-        control.setReturnValue(Collections.singletonList(attributeName));
+        setReturnValue(session, Collections.singletonList(attributeName));
 
-        if (remove)
-            session.setAttribute(attributeName, null);
+        if (value != null)
+            trainGetAttribute(session, attributeName, value);
 
         return session;
     }
 
-    public void testStorePageProperty()
+    public void testAddParametersDoesNothing()
     {
-        WebSession session = newSession();
-        WebRequest request = newRequest(true, session);
-
-        Object value = new Object();
-
-        session.setAttribute("myapp,Home,foo", value);
+        ServiceEncoding encoding = newEncoding();
 
         replayControls();
 
-        SessionPropertyPersistenceStrategy s = new SessionPropertyPersistenceStrategy();
+        SessionPropertyPersistenceStrategy strategy = new SessionPropertyPersistenceStrategy();
 
-        s.setApplicationId("myapp");
-        s.setRequest(request);
-
-        s.store("Home", null, "foo", value);
+        strategy.addParametersForPersistentProperties(encoding, false);
 
         verifyControls();
     }
@@ -106,7 +96,7 @@
         WebSession session = newSession();
         WebRequest request = newRequest(true, session);
 
-        session.setAttribute("myapp,Help,bar", null);
+        session.setAttribute("session,myapp,Help,bar", null);
 
         replayControls();
 
@@ -120,44 +110,54 @@
         verifyControls();
     }
 
-    public void testStoreComponentProperty()
+    public void testDiscardChangesNoMatch()
     {
-        WebSession session = newSession();
-        WebRequest request = newRequest(true, session);
+        WebSession session = newSession("session,myapp,Home,foo", false);
+        WebRequest request = newRequest(false, session);
 
-        Object value = new Object();
+        replayControls();
+
+        SessionPropertyPersistenceStrategy s = new SessionPropertyPersistenceStrategy();
+        s.setRequest(request);
+        s.setApplicationId("myapp");
 
-        session.setAttribute("gloop,Nerf,zip.zap,spaz", value);
+        s.discardStoredChanges("Foo");
+        verifyControls();
+    }
+
+    public void testDiscardChangesNoSession()
+    {
+        WebRequest request = newRequest(false, null);
 
         replayControls();
 
         SessionPropertyPersistenceStrategy s = new SessionPropertyPersistenceStrategy();
-
-        s.setApplicationId("gloop");
         s.setRequest(request);
 
-        s.store("Nerf", "zip.zap", "spaz", value);
+        s.discardStoredChanges("Foo");
 
         verifyControls();
     }
 
-    public void testGetStoredChangesNoSession()
+    public void testDiscardChangesWithMatch()
     {
-        WebRequest request = newRequest(false, null);
+        WebSession session = newSession("session,myapp,Home,foo", true);
+        WebRequest request = newRequest(false, session);
 
         replayControls();
 
         SessionPropertyPersistenceStrategy s = new SessionPropertyPersistenceStrategy();
         s.setRequest(request);
+        s.setApplicationId("myapp");
 
-        assertTrue(s.getStoredChanges("Foo", null).isEmpty());
+        s.discardStoredChanges("Home");
 
         verifyControls();
     }
 
     public void testGetStoreChangesNoMatch()
     {
-        WebSession session = newSession("myapp,Home,foo,bar", null);
+        WebSession session = newSession("session,myapp,Home,foo,bar", null);
         WebRequest request = newRequest(false, session);
 
         replayControls();
@@ -166,17 +166,31 @@
         s.setRequest(request);
         s.setApplicationId("myapp");
 
-        Collection actual = s.getStoredChanges("Help", null);
+        Collection actual = s.getStoredChanges("Help");
 
         assertTrue(actual.isEmpty());
 
         verifyControls();
     }
 
-    public void testGetStoredPageProperty()
+    public void testGetStoredChangesNoSession()
+    {
+        WebRequest request = newRequest(false, null);
+
+        replayControls();
+
+        SessionPropertyPersistenceStrategy s = new SessionPropertyPersistenceStrategy();
+        s.setRequest(request);
+
+        assertTrue(s.getStoredChanges("Foo").isEmpty());
+
+        verifyControls();
+    }
+
+    public void testGetStoredComponentProperty()
     {
         Object value = new Object();
-        WebSession session = newSession("myapp,Help,bar", value);
+        WebSession session = newSession("session,myapp,Help,zap.biff,bar", value);
         WebRequest request = newRequest(false, session);
 
         replayControls();
@@ -185,23 +199,23 @@
         s.setRequest(request);
         s.setApplicationId("myapp");
 
-        Collection actual = s.getStoredChanges("Help", null);
+        Collection actual = s.getStoredChanges("Help");
 
         assertEquals(1, actual.size());
 
         PropertyChange pc = (PropertyChange) actual.iterator().next();
 
-        assertNull(pc.getComponentPath());
+        assertEquals("zap.biff", pc.getComponentPath());
         assertEquals("bar", pc.getPropertyName());
         assertSame(value, pc.getNewValue());
 
         verifyControls();
     }
 
-    public void testGetStoredComponentProperty()
+    public void testGetStoredPageProperty()
     {
         Object value = new Object();
-        WebSession session = newSession("myapp,Help,zap.biff,bar", value);
+        WebSession session = newSession("session,myapp,Help,bar", value);
         WebRequest request = newRequest(false, session);
 
         replayControls();
@@ -210,60 +224,70 @@
         s.setRequest(request);
         s.setApplicationId("myapp");
 
-        Collection actual = s.getStoredChanges("Help", null);
+        Collection actual = s.getStoredChanges("Help");
 
         assertEquals(1, actual.size());
 
         PropertyChange pc = (PropertyChange) actual.iterator().next();
 
-        assertEquals("zap.biff", pc.getComponentPath());
+        assertNull(pc.getComponentPath());
         assertEquals("bar", pc.getPropertyName());
         assertSame(value, pc.getNewValue());
 
         verifyControls();
     }
 
-    public void testDiscardChangesNoSession()
+    public void testStoreComponentProperty()
     {
-        WebRequest request = newRequest(false, null);
+        WebSession session = newSession();
+        WebRequest request = newRequest(true, session);
+
+        Object value = new Object();
+
+        session.setAttribute("session,gloop,Nerf,zip.zap,spaz", value);
 
         replayControls();
 
         SessionPropertyPersistenceStrategy s = new SessionPropertyPersistenceStrategy();
+
+        s.setApplicationId("gloop");
         s.setRequest(request);
 
-        s.discardStoredChanges("Foo", null);
+        s.store("Nerf", "zip.zap", "spaz", value);
 
         verifyControls();
     }
 
-    public void testDiscardChangesNoMatch()
+    public void testStorePageProperty()
     {
-        WebSession session = newSession("myapp,Home,foo", false);
-        WebRequest request = newRequest(false, session);
+        WebSession session = newSession();
+        WebRequest request = newRequest(true, session);
+
+        Object value = new Object();
+
+        session.setAttribute("session,myapp,Home,foo", value);
 
         replayControls();
 
         SessionPropertyPersistenceStrategy s = new SessionPropertyPersistenceStrategy();
+
+        s.setApplicationId("myapp");
         s.setRequest(request);
 
-        s.discardStoredChanges("Foo", null);
+        s.store("Home", null, "foo", value);
+
         verifyControls();
     }
 
-    public void testDiscardChangesWithMatch()
+    private void trainGetAttribute(WebSession session, String attributeName, Object value)
     {
-        WebSession session = newSession("myapp,Home,foo", true);
-        WebRequest request = newRequest(false, session);
-
-        replayControls();
-
-        SessionPropertyPersistenceStrategy s = new SessionPropertyPersistenceStrategy();
-        s.setRequest(request);
-        s.setApplicationId("myapp");
-
-        s.discardStoredChanges("Home", null);
+        session.getAttribute(attributeName);
+        setReturnValue(session, value);
+    }
 
-        verifyControls();
+    private void trainGetAttributeNames(WebSession session, List names)
+    {
+        session.getAttributeNames();
+        setReturnValue(session, names);
     }
 }

Modified: jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/record/TestClientPropertyPersistenceStrategy.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/record/TestClientPropertyPersistenceStrategy.java?rev=345745&r1=345744&r2=345745&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/record/TestClientPropertyPersistenceStrategy.java (original)
+++ jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/record/TestClientPropertyPersistenceStrategy.java Sun Nov 20 06:14:14 2005
@@ -74,7 +74,7 @@
 
         strategy.initializeService();
 
-        assertSame(changes, strategy.getStoredChanges("MyPage", null));
+        assertSame(changes, strategy.getStoredChanges("MyPage"));
 
         verifyControls();
     }
@@ -83,7 +83,7 @@
     {
         ClientPropertyPersistenceStrategy strategy = new ClientPropertyPersistenceStrategy();
 
-        assertTrue(strategy.getStoredChanges("UnknownPage", null).isEmpty());
+        assertTrue(strategy.getStoredChanges("UnknownPage").isEmpty());
     }
 
     public void testStoreAndRetrieve()
@@ -95,11 +95,11 @@
 
         strategy.store("MyPage", "foo", "bar", "baz");
 
-        assertEquals(Collections.singletonList(pc), strategy.getStoredChanges("MyPage", null));
+        assertEquals(Collections.singletonList(pc), strategy.getStoredChanges("MyPage"));
 
-        strategy.discardStoredChanges("MyPage", null);
+        strategy.discardStoredChanges("MyPage");
 
-        assertEquals(Collections.EMPTY_LIST, strategy.getStoredChanges("MyPage", null));
+        assertEquals(Collections.EMPTY_LIST, strategy.getStoredChanges("MyPage"));
     }
 
     public void testAddParametersForPersistentProperties()

Modified: jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/record/TestPageRecorder.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/record/TestPageRecorder.java?rev=345745&r1=345744&r2=345745&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/record/TestPageRecorder.java (original)
+++ jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/record/TestPageRecorder.java Sun Nov 20 06:14:14 2005
@@ -61,7 +61,7 @@
 
         Collection expected = new ArrayList();
 
-        source.getAllStoredChanges("Foo", cycle);
+        source.getAllStoredChanges("Foo");
         sourcec.setReturnValue(expected);
 
         replayControls();
@@ -194,7 +194,7 @@
 
         PropertyChange pc = new PropertyChangeImpl(null, "cartoonName", "Dexter's Laboratory");
 
-        source.getAllStoredChanges("MyPage", cycle);
+        source.getAllStoredChanges("MyPage");
         sourcec.setReturnValue(Collections.singletonList(pc));
 
         replayControls();
@@ -224,7 +224,7 @@
 
         PropertyChange pc = new PropertyChangeImpl("fred.barney", "id", "ziff");
 
-        source.getAllStoredChanges("MyPage", cycle);
+        source.getAllStoredChanges("MyPage");
         sourcec.setReturnValue(Collections.singletonList(pc));
 
         page.getNestedComponent("fred.barney");

Modified: jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/services/impl/LinkFactoryTest.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/services/impl/LinkFactoryTest.java?rev=345745&r1=345744&r2=345745&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/services/impl/LinkFactoryTest.java (original)
+++ jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/services/impl/LinkFactoryTest.java Sun Nov 20 06:14:14 2005
@@ -78,12 +78,12 @@
             return null;
         }
 
-        public Collection getAllStoredChanges(String pageName, IRequestCycle cycle)
+        public Collection getAllStoredChanges(String pageName)
         {
             return null;
         }
 
-        public void discardAllStoredChanged(String pageName, IRequestCycle cycle)
+        public void discardAllStoredChanged(String pageName)
         {
         }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org