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 2009/02/05 21:03:49 UTC

svn commit: r741272 - in /tapestry/tapestry5/trunk: src/site/ src/site/apt/ tapestry-core/src/main/java/org/apache/tapestry5/ tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/ tapestry-core/src/main/java/org/apache/tapestry5/internal/...

Author: hlship
Date: Thu Feb  5 20:03:48 2009
New Revision: 741272

URL: http://svn.apache.org/viewvc?rev=741272&view=rev
Log:
TAP5-489: The comment inside AssetBinding concerning invariant is out of date, in that all Assets now use complete URLs
TAP5-472: Make it possible and easy to use a content delivery network

Added:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AbstractAsset.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/IdentityAssetPathConverter.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/AssetPathConverter.java
Modified:
    tapestry/tapestry5/trunk/src/site/apt/index.apt
    tapestry/tapestry5/trunk/src/site/apt/upgrade.apt
    tapestry/tapestry5/trunk/src/site/site.xml
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/Asset.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/AssetBinding.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/AssetBindingFactory.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/ContextBindingFactory.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ClasspathAssetFactory.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ContextAssetFactory.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ClasspathAssetFactoryTest.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ContextAssetFactoryTest.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ServiceOverride.java

Modified: tapestry/tapestry5/trunk/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/src/site/apt/index.apt?rev=741272&r1=741271&r2=741272&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/src/site/apt/index.apt (original)
+++ tapestry/tapestry5/trunk/src/site/apt/index.apt Thu Feb  5 20:03:48 2009
@@ -74,6 +74,8 @@
 *--+--+--+
 | {{{http://www.localhost.nu/java/tapestry5-acegi/}tapestry5-acegi}} | Robin Helgelin  | Integration with the Acegi path-based security framework. |
 *--+--+--+
+| {{{http://tapestry.formos.com/nightly/tapestry-templating/}tapestry-templating}} | Howard M. Lewis Ship |  Use Tapestry pages off-line to generate content (such as email) |
+*--+--+--+
 | {{{http://code.google.com/p/tapestry5-treegrid/}tapestry5-treegrid}} | Gabriel Landais |  Combination tree navigation and data grid, based on sstree. |
 *--+--+--+
 
@@ -96,6 +98,9 @@
   * IoC Service contributions may now be made in terms of classes (that are automatically instantiated) as well as
     instances.
 
+  * A simpler method of {{{apidocs/org/apache/tapestry5/ioc/services/ServiceOverride}overriding built-in services}}
+    has been added.
+
   []
 
 Adaptive API

Modified: tapestry/tapestry5/trunk/src/site/apt/upgrade.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/src/site/apt/upgrade.apt?rev=741272&r1=741271&r2=741272&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/src/site/apt/upgrade.apt (original)
+++ tapestry/tapestry5/trunk/src/site/apt/upgrade.apt Thu Feb  5 20:03:48 2009
@@ -15,6 +15,8 @@
 
 Release 5.1.0.0
 
+* Performance Improvements
+
   As part of the changes related to
   {{{https://issues.apache.org/jira/browse/TAP5-417}TAP5-417: Tapestry 5.0 Performance Improvements}},
   you should be aware that Tapestry will now optimize the render phase state machine.
@@ -23,14 +25,30 @@
   {{{apidocs/org/apache/tapestry5/model/MutableComponentModel.html#addRenderPhase(Class)}inform
   Tapestry that the render phase should be invoked}}.
 
+* Tapestry/Spring
+
   There have been some significant changes to the {{{tapestry-spring/}tapestry-spring}} module, to
   support injection of Tapestry services into Springbeans.
 
+* Session Persisted Objects
+
   Tapestry is now more aggressive about automatically re-storing any session persisted object
   back into the session at the end of the request (this used to only apply to application state objects).  See the 
   {{{guide/persist.html}persistent page data}} notes for more details.
 
+* Module Classes
+
   Many questionable practices in Tapestry module classes that used to produce warnings (which were
   ignored, leading to more difficult questions) have been changed to fail early with exceptions. This includes
   extra public methods on a module class that are not used by Tapestry IoC, and several other similar
-  scenarios.
\ No newline at end of file
+  scenarios.
+
+  Extra public methods on module classes (methods that do not define services, contribute to services,
+  or decorate or advise services) are now errors.
+
+* Asset Interface
+
+  The {{{apidocs/org/apache/tapestry5/Asset.html}Asset}} interface has added a new method,
+  isInvariant().  This should only concern developers who have created their own Asset
+  implementations.
+

Modified: tapestry/tapestry5/trunk/src/site/site.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/src/site/site.xml?rev=741272&r1=741271&r2=741272&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/src/site/site.xml (original)
+++ tapestry/tapestry5/trunk/src/site/site.xml Thu Feb  5 20:03:48 2009
@@ -47,6 +47,7 @@
             <item name="Nightly Docs" href="http://tapestry.formos.com/nightly/tapestry5/"/>
             <item name="Issues" href="https://issues.apache.org/jira/browse/TAP5"/>
             <item name="FAQ" href="faq/general.html"/>
+            <item name="Refcard" href="http://refcardz.dzone.com/refcardz/apache-tapestry-50?oid=hom7545"/>
         </menu>
 
         <menu name="Upgrade Notes">

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/Asset.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/Asset.java?rev=741272&r1=741271&r2=741272&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/Asset.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/Asset.java Thu Feb  5 20:03:48 2009
@@ -1,4 +1,4 @@
-// Copyright 2006, 2008 The Apache Software Foundation
+// Copyright 2006, 2008, 2009 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.
@@ -29,8 +29,11 @@
      * Returns a URL that can be passed, unchanged, to the client in order for it to access the resource. The same value
      * is returned from <code>toString()</code>.
      * <p/>
-     * Note that the returned value may be {@linkplain SymbolConstants#FORCE_ABSOLUTE_URIS request dependent}. You may
-     * cache instances of Asset, but do not cache the client URL path as it may change.
+     * Tapestry's built-in asset types (context and classpath) always incorporate a version number as part of the path,
+     * and alternate implementation are encouraged to do so as well. In addition, Tapestry ensures that context and
+     * classpath assets have a far-future expires header (to ensure aggresive caching by the client).
+     *
+     * @see org.apache.tapestry5.services.AssetPathConverter
      */
     String toClientURL();
 
@@ -38,4 +41,14 @@
      * Returns the underlying Resource for the Asset.
      */
     Resource getResource();
+
+    /**
+     * Determines if an asset is variant or invariant: a normal asset is invariant, and always return the same value
+     * from {@link #toClientURL()}.  All the builtin types of assets are invariant. Variant assets calculate their
+     * clientURL dynamically, possibly incorporating user-specific details.
+     *
+     * @return true if the asset's client URL does not change, false if the clientURL is calculated more dynamically.
+     * @since 5.1.0.0
+     */
+    boolean isInvariant();
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/AssetBinding.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/AssetBinding.java?rev=741272&r1=741271&r2=741272&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/AssetBinding.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/AssetBinding.java Thu Feb  5 20:03:48 2009
@@ -23,15 +23,12 @@
 
     private final Asset asset;
 
-    private final boolean invariant;
-
-    AssetBinding(Location location, String description, Asset asset, boolean invariant)
+    AssetBinding(Location location, String description, Asset asset)
     {
         super(location);
 
         this.description = description;
         this.asset = asset;
-        this.invariant = invariant;
     }
 
     public Object get()
@@ -40,18 +37,13 @@
     }
 
     /**
-     * Asset bindings are invariant only if full URIs are being used.  This is complicated ... basically, if the Asset
-     * is invariant, then any value coerced from the Asset is also invariant (such as a String version of an Asset's
-     * path).  Thus, the invariant String gets cached inside component parameter fields.  However, when the path is
-     * dynamic (i.e., because of {@link org.apache.tapestry5.internal.services.RequestPathOptimizer}), we need to ensure
-     * that the Assets aren't cached.
-     *
-     * @return true if full URIs are enabled, false otherwise
+     * Queries the underlying Asset to determine if {@linkplain org.apache.tapestry5.Asset#isInvariant() it is
+     * invariant}.
      */
     @Override
     public boolean isInvariant()
     {
-        return invariant;
+        return asset.isInvariant();
     }
 
     @Override

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/AssetBindingFactory.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/AssetBindingFactory.java?rev=741272&r1=741271&r2=741272&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/AssetBindingFactory.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/AssetBindingFactory.java Thu Feb  5 20:03:48 2009
@@ -17,10 +17,8 @@
 import org.apache.tapestry5.Asset;
 import org.apache.tapestry5.Binding;
 import org.apache.tapestry5.ComponentResources;
-import org.apache.tapestry5.SymbolConstants;
 import org.apache.tapestry5.ioc.Location;
 import org.apache.tapestry5.ioc.Resource;
-import org.apache.tapestry5.ioc.annotations.Symbol;
 import org.apache.tapestry5.services.AssetSource;
 import org.apache.tapestry5.services.BindingFactory;
 
@@ -34,15 +32,9 @@
 {
     private final AssetSource source;
 
-    private final boolean forceAbsoluteURIs;
-
-    public AssetBindingFactory(AssetSource source,
-
-                               @Symbol(SymbolConstants.FORCE_ABSOLUTE_URIS)
-                               boolean forceAbsoluteURIs)
+    public AssetBindingFactory(AssetSource source)
     {
         this.source = source;
-        this.forceAbsoluteURIs = forceAbsoluteURIs;
     }
 
     public Binding newBinding(String description, ComponentResources container, ComponentResources component,
@@ -52,6 +44,6 @@
 
         Asset asset = source.getAsset(baseResource, expression, container.getLocale());
 
-        return new AssetBinding(location, description, asset, forceAbsoluteURIs);
+        return new AssetBinding(location, description, asset);
     }
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/ContextBindingFactory.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/ContextBindingFactory.java?rev=741272&r1=741271&r2=741272&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/ContextBindingFactory.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/ContextBindingFactory.java Thu Feb  5 20:03:48 2009
@@ -17,9 +17,7 @@
 import org.apache.tapestry5.Asset;
 import org.apache.tapestry5.Binding;
 import org.apache.tapestry5.ComponentResources;
-import org.apache.tapestry5.SymbolConstants;
 import org.apache.tapestry5.ioc.Location;
-import org.apache.tapestry5.ioc.annotations.Symbol;
 import org.apache.tapestry5.services.AssetSource;
 import org.apache.tapestry5.services.BindingFactory;
 
@@ -33,15 +31,9 @@
 {
     private final AssetSource source;
 
-    private final boolean forceAbsoluteURIs;
-
-    public ContextBindingFactory(AssetSource source,
-
-                                 @Symbol(SymbolConstants.FORCE_ABSOLUTE_URIS)
-                                 boolean forceAbsoluteURIs)
+    public ContextBindingFactory(AssetSource source)
     {
         this.source = source;
-        this.forceAbsoluteURIs = forceAbsoluteURIs;
     }
 
     public Binding newBinding(String description, ComponentResources container, ComponentResources component,
@@ -49,6 +41,6 @@
     {
         Asset asset = source.getContextAsset(expression, container.getLocale());
 
-        return new AssetBinding(location, description, asset, forceAbsoluteURIs);
+        return new AssetBinding(location, description, asset);
     }
 }

Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AbstractAsset.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AbstractAsset.java?rev=741272&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AbstractAsset.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AbstractAsset.java Thu Feb  5 20:03:48 2009
@@ -0,0 +1,39 @@
+// Copyright 2009 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry5.internal.services;
+
+import org.apache.tapestry5.Asset;
+
+/**
+ * Base class for an <em>invariant</em> asset.
+ *
+ * @since 5.1.0.0
+ */
+public abstract class AbstractAsset implements Asset
+{
+    /**
+     * Returns true which is correct for most Asset types.
+     */
+    public boolean isInvariant()
+    {
+        return true;
+    }
+
+    @Override
+    public String toString()
+    {
+        return toClientURL();
+    }
+}

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ClasspathAssetFactory.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ClasspathAssetFactory.java?rev=741272&r1=741271&r2=741272&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ClasspathAssetFactory.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ClasspathAssetFactory.java Thu Feb  5 20:03:48 2009
@@ -17,10 +17,11 @@
 import org.apache.tapestry5.Asset;
 import org.apache.tapestry5.ioc.Resource;
 import org.apache.tapestry5.ioc.internal.util.ClasspathResource;
-import static org.apache.tapestry5.ioc.internal.util.CollectionFactory.newConcurrentMap;
+import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
 import org.apache.tapestry5.services.AssetFactory;
 import org.apache.tapestry5.services.ClasspathAssetAliasManager;
 import org.apache.tapestry5.services.InvalidationListener;
+import org.apache.tapestry5.services.AssetPathConverter;
 
 import java.util.Map;
 
@@ -36,14 +37,18 @@
 
     private final ClasspathAssetAliasManager aliasManager;
 
-    private final Map<Resource, String> resourceToClientURL = newConcurrentMap();
+    private final Map<Resource, String> resourceToClientURL = CollectionFactory.newConcurrentMap();
 
     private final ClasspathResource rootResource;
 
-    public ClasspathAssetFactory(final ResourceCache cache, final ClasspathAssetAliasManager aliasManager)
+    private final AssetPathConverter converter;
+
+    public ClasspathAssetFactory(final ResourceCache cache, final ClasspathAssetAliasManager aliasManager,
+                                 AssetPathConverter converter)
     {
         this.cache = cache;
         this.aliasManager = aliasManager;
+        this.converter = converter;
 
         rootResource = new ClasspathResource("");
     }
@@ -84,12 +89,12 @@
             path = path.substring(0, lastdotx + 1) + cache.getDigest(resource) + path.substring(lastdotx);
         }
 
-        return path;
+        return converter.convertAssetPath(path);
     }
 
     public Asset createAsset(final Resource resource)
     {
-        return new Asset()
+        return new AbstractAsset()
         {
             public Resource getResource()
             {
@@ -100,12 +105,6 @@
             {
                 return clientURL(resource);
             }
-
-            @Override
-            public String toString()
-            {
-                return toClientURL();
-            }
         };
     }
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ContextAssetFactory.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ContextAssetFactory.java?rev=741272&r1=741271&r2=741272&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ContextAssetFactory.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ContextAssetFactory.java Thu Feb  5 20:03:48 2009
@@ -22,6 +22,7 @@
 import org.apache.tapestry5.services.AssetFactory;
 import org.apache.tapestry5.services.Context;
 import org.apache.tapestry5.services.Request;
+import org.apache.tapestry5.services.AssetPathConverter;
 
 /**
  * Implementation of {@link AssetFactory} for assets that are part of the web application context.
@@ -36,12 +37,15 @@
 
     private final Resource rootResource;
 
+    private final AssetPathConverter assetPathConverter;
+
     public ContextAssetFactory(Request request, Context context,
 
                                @Inject @Symbol(SymbolConstants.APPLICATION_VERSION)
-                               String applicationVersion)
+                               String applicationVersion, AssetPathConverter assetPathConverter)
     {
         this.request = request;
+        this.assetPathConverter = assetPathConverter;
 
         pathPrefix = RequestConstants.ASSET_PATH_PREFIX + RequestConstants.CONTEXT_FOLDER
                 + applicationVersion + "/";
@@ -51,9 +55,11 @@
 
     public Asset createAsset(final Resource resource)
     {
-        final String completePath = request.getContextPath() + pathPrefix + resource.getPath();
+        String defaultPath = request.getContextPath() + pathPrefix + resource.getPath();
+        
+        final String completePath = assetPathConverter.convertAssetPath(defaultPath);
 
-        return new Asset()
+        return new AbstractAsset()
         {
             public Resource getResource()
             {
@@ -64,16 +70,6 @@
             {
                 return completePath;
             }
-
-            /**
-             * Returns the client URL, which is essential to allow informal parameters of type
-             * Asset to generate a proper value.
-             */
-            @Override
-            public String toString()
-            {
-                return toClientURL();
-            }
         };
     }
 

Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/IdentityAssetPathConverter.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/IdentityAssetPathConverter.java?rev=741272&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/IdentityAssetPathConverter.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/IdentityAssetPathConverter.java Thu Feb  5 20:03:48 2009
@@ -0,0 +1,34 @@
+// Copyright 2009 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry5.internal.services;
+
+import org.apache.tapestry5.services.AssetPathConverter;
+
+/**
+ * Returns the default asset path unchanged.
+ *
+ * @since 5.1.0.0
+ */
+public class IdentityAssetPathConverter implements AssetPathConverter
+{
+    /**
+     * @param assetPath default asset path
+     * @return assetPath unchanged
+     */
+    public String convertAssetPath(String assetPath)
+    {
+        return assetPath;
+    }
+}

Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/AssetPathConverter.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/AssetPathConverter.java?rev=741272&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/AssetPathConverter.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/AssetPathConverter.java Thu Feb  5 20:03:48 2009
@@ -0,0 +1,37 @@
+// Copyright 2009 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry5.services;
+
+/**
+ * Converts the {@linkplain org.apache.tapestry5.Asset#toClientURL() path (or URI) of an asset} into a new format. This
+ * is the <em>hook</em> needed to make use of a <a href="http://en.wikipedia.org/wiki/Content_Delivery_Network">Content
+ * Delivery Network</a>.
+ * <p/>
+ * The default implementation of this is <em>identity</em>, the URI is passed through unchanged. Using a contribution to
+ * the {@link org.apache.tapestry5.ioc.services.ServiceOverride} service, you may override the default implementation.
+ *
+ * @since 5.1.0.0
+ */
+public interface AssetPathConverter
+{
+    /**
+     * Converts the default asset client URI to its final form, ready to be sent to the client. The default asset path
+     * is an absolute path (it starts with a leading slash) and incorporates the context path if any.
+     *
+     * @param assetPath default asset path
+     * @return a URI that can be sent to the client
+     */
+    String convertAssetPath(String assetPath);
+}

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java?rev=741272&r1=741271&r2=741272&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java Thu Feb  5 20:03:48 2009
@@ -292,6 +292,7 @@
         binder.bind(UpdateListenerHub.class, UpdateListenerHubImpl.class);
         binder.bind(ApplicationStatePersistenceStrategy.class, SessionApplicationStatePersistenceStrategy.class).withId(
                 "SessionApplicationStatePersistenceStrategy");
+        binder.bind(AssetPathConverter.class, IdentityAssetPathConverter.class);
     }
 
     // ========================================================================
@@ -975,7 +976,8 @@
     @Marker(ClasspathProvider.class)
     public AssetFactory buildClasspathAssetFactory(ResourceCache resourceCache, ClasspathAssetAliasManager aliasManager)
     {
-        ClasspathAssetFactory factory = new ClasspathAssetFactory(resourceCache, aliasManager);
+        ClasspathAssetFactory factory = new ClasspathAssetFactory(resourceCache, aliasManager,
+                                                                  new IdentityAssetPathConverter());
 
         resourceCache.addInvalidationListener(factory);
 
@@ -988,7 +990,8 @@
                                                  @Inject @Symbol(SymbolConstants.APPLICATION_VERSION)
                                                  String applicationVersion)
     {
-        return new ContextAssetFactory(request, globals.getContext(), applicationVersion);
+        return new ContextAssetFactory(request, globals.getContext(), applicationVersion,
+                                       new IdentityAssetPathConverter());
     }
 
     /**

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ClasspathAssetFactoryTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ClasspathAssetFactoryTest.java?rev=741272&r1=741271&r2=741272&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ClasspathAssetFactoryTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ClasspathAssetFactoryTest.java Thu Feb  5 20:03:48 2009
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007, 2008 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 2009 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.
@@ -44,7 +44,7 @@
 
         replay();
 
-        ClasspathAssetFactory factory = new ClasspathAssetFactory(cache, aliasManager);
+        ClasspathAssetFactory factory = new ClasspathAssetFactory(cache, aliasManager, new IdentityAssetPathConverter());
 
         Asset asset = factory.createAsset(r);
 
@@ -88,7 +88,7 @@
 
         replay();
 
-        AssetFactory factory = new ClasspathAssetFactory(cache, aliasManager);
+        AssetFactory factory = new ClasspathAssetFactory(cache, aliasManager, new IdentityAssetPathConverter());
 
         Asset asset = factory.createAsset(r);
 
@@ -119,7 +119,7 @@
 
         replay();
 
-        AssetFactory factory = new ClasspathAssetFactory(cache, aliasManager);
+        AssetFactory factory = new ClasspathAssetFactory(cache, aliasManager, new IdentityAssetPathConverter());
 
         Asset asset = factory.createAsset(r);
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ContextAssetFactoryTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ContextAssetFactoryTest.java?rev=741272&r1=741271&r2=741272&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ContextAssetFactoryTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ContextAssetFactoryTest.java Thu Feb  5 20:03:48 2009
@@ -33,7 +33,7 @@
 
         replay();
 
-        AssetFactory factory = new ContextAssetFactory(request, context, "1.2.3");
+        AssetFactory factory = new ContextAssetFactory(request, context, "1.2.3", new IdentityAssetPathConverter());
 
         assertEquals(factory.getRootResource().toString(), "context:/");
 
@@ -52,7 +52,7 @@
 
         replay();
 
-        AssetFactory factory = new ContextAssetFactory(request, context, "4.5.6");
+        AssetFactory factory = new ContextAssetFactory(request, context, "4.5.6", new IdentityAssetPathConverter());
 
         Asset asset = factory.createAsset(r);
 

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ServiceOverride.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ServiceOverride.java?rev=741272&r1=741271&r2=741272&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ServiceOverride.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ServiceOverride.java Thu Feb  5 20:03:48 2009
@@ -18,10 +18,18 @@
 import org.apache.tapestry5.ioc.annotations.UsesMappedConfiguration;
 
 /**
- * Used to override built in services.
+ * Used to override built in services.  Simply contribute a mapping from a type to an instance of that type. Anywhere
+ * that exact type is injected, without specifying markers or other annotations, the contributed instance will be
+ * injected, even if there is already a service that implements the interface.
+ *
+ * @since 5.1.0.0
  */
 @UsesMappedConfiguration(key = Class.class, value = Object.class)
 public interface ServiceOverride
 {
+    /**
+     * Returns a provider based on the configuration; this is wired into the {@link
+     * org.apache.tapestry5.ioc.services.MasterObjectProvider}'s configuration.
+     */
     ObjectProvider getServiceOverrideProvider();
 }