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