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