    001// Copyright 2006, 2008, 2009, 2013 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
    015package org.apache.tapestry5;
    016
    017import org.apache.tapestry5.ioc.Resource;
    018
    019/**
    020 * An Asset is any kind of resource that can be exposed to the client web browser. Although quite often an Asset is a
    021 * resource in a web application's context folder, within Tapestry, Assets may also be resources on the classpath (i.e.,
    022 * packaged inside JARs).
    023 * <p/>
    024 * An Asset's toString() will return the URL for the resource (the same value as {@link #toClientURL()}).
    025 * <p/>
    026 * Release 5.1.0.0 introduced {@link org.apache.tapestry5.Asset2}, which extends this interface with an additional
    027 * method.
    028 *
    029 * @see org.apache.tapestry5.services.AssetPathConverter
    030 */
    031public interface Asset
    032{
    033    /**
    034     * Returns a URL that can be passed, unchanged, to the client in order for it to access the resource. The same value
    035     * is returned from <code>toString()</code>.
    036     * <p/>
    037     * Tapestry's built-in asset types (context and classpath) always incorporate a checksum as part of the path,
    038     * and alternate implementations are encouraged to do so as well. In addition, Tapestry ensures that context and
    039     * classpath assets have a far-future expires header (to ensure aggressive caching by the client).
    040     * <p/>Note that starting in Tapestry 5.4, it is expected that Asset instances recognize
    041     * when the underlying Resource's content has changed, and update the clientURL to reflect the new content's
    042     * checksum. This wasn't an issue in earlier releases where the clientURL incorporated a version number.
    043     * <p/>
    044     * Finally, starting in 5.4, this value will often be <em>variant</em>: the exact URL returned will depend on
    045     * whether the underlying resource content is compressable, whether the current {@link org.apache.tapestry5.services.Request}
    046     * supports compression.
    047     *
    048     * @see org.apache.tapestry5.services.AssetSource
    049     * @see org.apache.tapestry5.services.AssetPathConverter
    050     */
    051    String toClientURL();
    052
    053    /**
    054     * Returns the underlying Resource for the Asset.
    055     */
    056    Resource getResource();
    057
    058}