001    // Copyright 2007, 2008 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.tapestry.services;
016    
017    import org.apache.tapestry.ComponentResources;
018    
019    /**
020     * Used to lookup meta data concerning a particular component. The primary source of meta data is the meta data defined
021     * for the component, accessed via {@link org.apache.tapestry.model.ComponentModel#getMeta(String)}. This includes meta
022     * data defined by base classes. When meta-data for a particular component can not be found, a search works up the
023     * containment hierarchy (to the component's container, and the container's container, and so on). If <em>that</em>
024     * proves unfruitful, a system of defaults is provided by configuration and matched against the containing page's
025     * logical name.
026     * <p/>
027     * Finally, if no metadata is available, then {@link org.apache.tapestry.ioc.services.SymbolSource#valueForSymbol(String)}
028     * is used to obtain a value.
029     */
030    public interface MetaDataLocator
031    {
032        /**
033         * Searches for the value for the corresponding key.  The value, if located, will have symbols expanded, and will be
034         * type coerced to the desired type.
035         *
036         * @param key       the key used to locate the meta data (case insensitive)
037         * @param resources the resources of the initial component used in the search
038         * @return the value if found (in the component, the component's container, etc. or via a folder default) or null if
039         *         not found anywhere
040         * @throws RuntimeException if the value for the key is not present as meta data of the component, as an override,
041         *                          or as a symbol
042         */
043        <T> T findMeta(String key, ComponentResources resources, Class<T> expectedType);
044    }