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