    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.services.templates;
    014
    015import org.apache.tapestry5.TapestryConstants;
    016import org.apache.tapestry5.ioc.Resource;
    017import org.apache.tapestry5.ioc.annotations.UsesOrderedConfiguration;
    018import org.apache.tapestry5.model.ComponentModel;
    019import org.apache.tapestry5.services.pageload.ComponentResourceSelector;
    020
    021import java.util.Locale;
    022
    023/**
    024 * Chain-of-command interface used to locate page and component templates. Contributions to this service support
    025 * alternate naming schemes for template files, or alternate locations in which to search for template files.
    026 *
    027 * This service was introduced in Tapestry 5.2, but deprecated in Tapestry 5.3. It is utilized by the default
    028 * implementation of {@link org.apache.tapestry5.services.pageload.ComponentResourceLocator}.
    029 *
    030 * @see TapestryConstants#TEMPLATE_EXTENSION
    031 * @since 5.2.0
    032 * @deprecated Deprecated in 5.3, override or decorate {@link ComponentResourceSelector} instead.
    033 */
    034@UsesOrderedConfiguration(ComponentTemplateLocator.class)
    035public interface ComponentTemplateLocator
    036{
    037    /**
    038     * Locates the template for the given model as a {@link Resource}.
    039     *
    040     * @param model
    041     *         defines the component, especially its {@linkplain ComponentModel#getBaseResource() base resource}
    042     * @param locale
    043     *         to which the
    044     * @return localized template resource if found, or null if not found
    045     */
    046    Resource locateTemplate(ComponentModel model, Locale locale);
    047}