001// Licensed under the Apache License, Version 2.0 (the "License"); 002// you may not use this file except in compliance with the License. 003// You may obtain a copy of the License at 004// 005// http://www.apache.org/licenses/LICENSE-2.0 006// 007// Unless required by applicable law or agreed to in writing, software 008// distributed under the License is distributed on an "AS IS" BASIS, 009// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 010// See the License for the specific language governing permissions and 011// limitations under the License. 012 013package org.apache.tapestry5.services; 014 015/** 016 * Converts the {@linkplain org.apache.tapestry5.Asset#toClientURL() path (or URI) of an asset} into a new format. This 017 * is the <em>hook</em> needed to make use of a <a href="http://en.wikipedia.org/wiki/Content_Delivery_Network">Content 018 * Delivery Network</a>. 019 * 020 * The default implementation of this is <em>identity</em>, the URI is passed through unchanged. Using a contribution to 021 * the {@link org.apache.tapestry5.ioc.services.ServiceOverride} service, you may override the default implementation. 022 * 023 * @since 5.1.0.0 024 */ 025public interface AssetPathConverter 026{ 027 /** 028 * Returns true if the converter returns the exact same converted path for any specific asset path (in which case, the 029 * converted asset path may be cached in component instance variables more aggressively). This value should be false 030 * if the converted path can vary for the same input path ... that is, if external factors (such as the identity of 031 * the user, or information obtained from the request) is involved in generating the final client URI. With a CDN 032 * this can sometimes be the case, where the user's identity may indicate which CDN server to vend the asset from. 033 * 034 * @return true if invariant (and therefore cacheable) 035 */ 036 boolean isInvariant(); 037 038 /** 039 * Converts the default asset client URI to its final form, ready to be sent to the client. The default asset path 040 * is an absolute path (it starts with a leading slash) and incorporates the context path if any. 041 * 042 * @param assetPath default asset path 043 * @return a URI that can be sent to the client 044 */ 045 String convertAssetPath(String assetPath); 046}