    001// Copyright 2011 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.services.pageload;
    016
    017import org.apache.tapestry5.ioc.Resource;
    018import org.apache.tapestry5.ioc.util.LocalizedNameGenerator;
    019import org.apache.tapestry5.model.ComponentModel;
    020
    021import java.util.List;
    022
    023/**
    024 * A central service that encapsulates the rules for locating resources for components. The service can be
    025 * overridden, or simply decorated, to implement customized rules for locating templates across
    026 * one or more {@linkplain ComponentResourceSelector#getAxis(Class) axes}; this is the approach used to skin
    027 * Tapestry applications.
    028 *
    029 * @see org.apache.tapestry5.services.templates.ComponentTemplateLocator
    030 * @since 5.3
    031 */
    032public interface ComponentResourceLocator
    033{
    034    /**
    035     * Locates the template for a component (including pages and base classes). The implementation takes into
    036     * account the locale and other axes specified by the selector. If the method returns null, then the component
    037     * will have no template (which is common for components, but rare for pages).
    038     *
    039     * @param model
    040     *         defines the component, including its {@linkplain ComponentModel#getBaseResource() base resource}.
    041     * @param selector
    042     *         used to identify locale, etc., for the template
    043     * @return Resource for component template, or null if not found
    044     */
    045    Resource locateTemplate(ComponentModel model, ComponentResourceSelector selector);
    046
    047    /**
    048     * Locates the properties files that make up the message catalog for a specific component. The properties
    049     * files are returned in order of specificity: the properties provided by the first resource override
    050     * properties in later resources. Only resources specific to the class associated with the model
    051     * should be concerned (message inheritance from base classes is handled by Tapestry).
    052     *
    053     * @param baseResource
    054     *         the resource for the base component properties file (i.e., with the ".properties" file extension)
    055     * @param selector
    056     *         defined the locale and other axes used to locate individual properties files
    057     * @return list of properties file Resources
    058     * @see LocalizedNameGenerator
    059     */
    060    List<Resource> locateMessageCatalog(Resource baseResource, ComponentResourceSelector selector);
    061}