001 // Copyright 2006, 2008, 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;
016
017 import 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 */
031 public 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 version number 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/>
041 */
042 String toClientURL();
043
044 /**
045 * Returns the underlying Resource for the Asset.
046 */
047 Resource getResource();
048
049 }